From 81d8eda2419e7a23088a98cdfc52a305c9ceac0d Mon Sep 17 00:00:00 2001 From: Martin Ebourne Date: Wed, 7 Dec 2005 16:34:47 +0000 Subject: Merged martin/autoconf at r35 to trunk --- bin/bbackupd/BackupClientDirectoryRecord.cpp | 8 +-- bin/bbackupd/BackupClientInodeToIDMap.cpp | 8 +-- bin/bbackupd/BackupClientInodeToIDMap.h | 2 +- bin/bbackupd/BackupDaemon.cpp | 94 ++++++++++++++-------------- 4 files changed, 53 insertions(+), 59 deletions(-) (limited to 'bin/bbackupd') diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp index 89226eef..307c72c4 100755 --- a/bin/bbackupd/BackupClientDirectoryRecord.cpp +++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp @@ -26,10 +26,6 @@ #include "BackupDaemon.h" #include "BackupStoreException.h" -#ifdef PLATFORM_LINUX - #include "LinuxWorkaround.h" -#endif - #include "MemLeakFindOn.h" typedef std::map DecryptedEntriesMap_t; @@ -151,9 +147,9 @@ void BackupClientDirectoryRecord::SyncDirectory(BackupClientDirectoryRecord::Syn currentStateChecksum.Add(&st.st_gid, sizeof(st.st_gid)); // Inode to be paranoid about things moving around currentStateChecksum.Add(&st.st_ino, sizeof(st.st_ino)); -#ifndef PLATFORM_stat_NO_st_flags +#ifdef HAVE_STRUCT_STAT_ST_FLAGS currentStateChecksum.Add(&st.st_flags, sizeof(st.st_flags)); -#endif // n PLATFORM_stat_NO_st_flags +#endif StreamableMemBlock xattr; BackupClientFileAttributes::FillExtendedAttr(xattr, rLocalPath.c_str()); diff --git a/bin/bbackupd/BackupClientInodeToIDMap.cpp b/bin/bbackupd/BackupClientInodeToIDMap.cpp index 23e91eba..7141d5f4 100755 --- a/bin/bbackupd/BackupClientInodeToIDMap.cpp +++ b/bin/bbackupd/BackupClientInodeToIDMap.cpp @@ -9,16 +9,12 @@ #include "Box.h" -#ifndef PLATFORM_BERKELEY_DB_NOT_SUPPORTED +#ifdef HAVE_DB // Include db headers and other OS files if they're needed for the disc implementation #include #include #include - #ifdef PLATFORM_LINUX - #include "../../local/_linux_db.h" - #else - #include - #endif + #include DB_HEADER #include #endif diff --git a/bin/bbackupd/BackupClientInodeToIDMap.h b/bin/bbackupd/BackupClientInodeToIDMap.h index 1ea7755d..121e88fd 100755 --- a/bin/bbackupd/BackupClientInodeToIDMap.h +++ b/bin/bbackupd/BackupClientInodeToIDMap.h @@ -16,7 +16,7 @@ #include // Use in memory implementation if there isn't access to the Berkely DB on this platform -#ifdef PLATFORM_BERKELEY_DB_NOT_SUPPORTED +#ifndef HAVE_DB #define BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION #endif diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index bc07ee21..f22de591 100755 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -12,15 +12,16 @@ #include #include #include -#include #include -#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS - #ifdef PLATFORM_SUNOS - #include - #include - #else - #include - #endif +#ifdef HAVE_SYS_MOUNT_H + #include +#endif +#ifdef HAVE_MNTENT_H + #include +#endif +#ifdef HAVE_SYS_MNTTAB_H + #include + #include #endif #include @@ -894,7 +895,7 @@ void BackupDaemon::SendSyncStartOrFinish(bool SendStart) -#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS +#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME // string comparison ordering for when mount points are handled // by code, rather than the OS. typedef struct @@ -957,16 +958,21 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con std::map mounts; int numIDMaps = 0; -#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS +#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME // 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 + +#ifdef HAVE_STRUCT_MNTENT_MNT_DIR // Open mounts file - mountPointsFile = ::fopen("/etc/mnttab", "r"); + mountPointsFile = ::setmntent("/proc/mounts", "r"); + if(mountPointsFile == 0) + { + mountPointsFile = ::setmntent("/etc/mtab", "r"); + } if(mountPointsFile == 0) { THROW_EXCEPTION(CommonException, OSFileError); @@ -974,51 +980,47 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con try { - // Read all the entries, and put them in the set - struct mnttab entry; - while(getmntent(mountPointsFile, &entry) == 0) + struct mntent *entry = 0; + while((entry = ::getmntent(mountPointsFile)) != 0) { - TRACE1("Found mount point at %s\n", entry.mnt_mountp); - mountPoints.insert(std::string(entry.mnt_mountp)); + TRACE1("Found mount point at %s\n", entry->mnt_dir); + mountPoints.insert(std::string(entry->mnt_dir)); } // Close mounts file - ::fclose(mountPointsFile); + ::endmntent(mountPointsFile); } catch(...) { - ::fclose(mountPointsFile); + ::endmntent(mountPointsFile); throw; } #else - // Open mounts file - mountPointsFile = ::setmntent("/proc/mounts", "r"); + // Open mounts file + mountPointsFile = ::fopen("/etc/mnttab", "r"); if(mountPointsFile == 0) { - mountPointsFile = ::setmntent("/etc/mtab", "r"); + THROW_EXCEPTION(CommonException, OSFileError); } - 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) + struct mnttab entry; + while(getmntent(mountPointsFile, &entry) == 0) { - TRACE1("Found mount point at %s\n", entry->mnt_dir); - mountPoints.insert(std::string(entry->mnt_dir)); + TRACE1("Found mount point at %s\n", entry.mnt_mountp); + mountPoints.insert(std::string(entry.mnt_mountp)); } - + // Close mounts file - ::endmntent(mountPointsFile); + ::fclose(mountPointsFile); } catch(...) { - ::endmntent(mountPointsFile); + ::fclose(mountPointsFile); throw; } #endif @@ -1030,7 +1032,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con ASSERT(*i == "/"); } #endif // n NDEBUG -#endif // PLATFORM_USES_MTAB_FILE_FOR_MOUNTS +#endif // n HAVE_STRUCT_STATFS_F_MNTONNAME // Then... go through each of the entries in the configuration, // making sure there's a directory created for it. @@ -1052,7 +1054,17 @@ TRACE0("new location\n"); // Do a fsstat on the pathname to find out which mount it's on { -#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS +#ifdef HAVE_STRUCT_STATFS_F_MNTONNAME + // BSD style statfs -- includes mount point, which is nice. + struct statfs s; + if(::statfs(ploc->mPath.c_str(), &s) != 0) + { + THROW_EXCEPTION(CommonException, OSFileError) + } + + // Where the filesystem is mounted + std::string mountName(s.f_mntonname); +#else // Warn in logs if the directory isn't absolute if(ploc->mPath[0] != '/') { @@ -1078,16 +1090,6 @@ TRACE0("new location\n"); } TRACE2("mount point chosen for %s is %s\n", ploc->mPath.c_str(), mountName.c_str()); } -#else - // BSD style statfs -- includes mount point, which is nice. - struct statfs s; - if(::statfs(ploc->mPath.c_str(), &s) != 0) - { - THROW_EXCEPTION(CommonException, OSFileError) - } - - // Where the filesystem is mounted - std::string mountName(s.f_mntonname); #endif // Got it? -- cgit v1.2.3