From 01ca97865fa9d6ed1a967e970927265f1c348289 Mon Sep 17 00:00:00 2001 From: Martin Ebourne Date: Wed, 30 Nov 2005 23:14:40 +0000 Subject: Merged martin/solaris at r9 to trunk --- bin/bbackupd/BackupDaemon.cpp | 49 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index 7aa21a87..bc07ee21 100755 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -15,7 +15,12 @@ #include #include #ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS - #include + #ifdef PLATFORM_SUNOS + #include + #include + #else + #include + #endif #endif #include @@ -953,21 +958,53 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con int numIDMaps = 0; #ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS - // Linux can't tell you where a directory is mounted. So we have to - // read the mount entries from /etc/mtab! Bizarre that the OS itself - // can't tell you, but there you go. + // Linux and others can't tell you where a directory is mounted. So we + // have to read the mount entries from /etc/mtab! Bizarre that the OS + // itself can't tell you, but there you go. std::set mountPoints; // BLOCK FILE *mountPointsFile = 0; +#ifdef PLATFORM_SUNOS + // Open mounts file + mountPointsFile = ::fopen("/etc/mnttab", "r"); + if(mountPointsFile == 0) + { + THROW_EXCEPTION(CommonException, OSFileError); + } + try { + + // Read all the entries, and put them in the set + struct mnttab entry; + while(getmntent(mountPointsFile, &entry) == 0) + { + TRACE1("Found mount point at %s\n", entry.mnt_mountp); + mountPoints.insert(std::string(entry.mnt_mountp)); + } + + // Close mounts file + ::fclose(mountPointsFile); + } + catch(...) + { + ::fclose(mountPointsFile); + throw; + } +#else // Open mounts file + mountPointsFile = ::setmntent("/proc/mounts", "r"); + if(mountPointsFile == 0) + { mountPointsFile = ::setmntent("/etc/mtab", "r"); + } if(mountPointsFile == 0) { THROW_EXCEPTION(CommonException, OSFileError); } + try + { // Read all the entries, and put them in the set struct mntent *entry = 0; while((entry = ::getmntent(mountPointsFile)) != 0) @@ -981,12 +1018,10 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con } catch(...) { - if(mountPointsFile != 0) - { ::endmntent(mountPointsFile); - } throw; } +#endif // Check sorting and that things are as we expect ASSERT(mountPoints.size() > 0); #ifndef NDEBUG -- cgit v1.2.3