diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bbackupd/BackupClientDirectoryRecord.cpp | 8 | ||||
-rwxr-xr-x | bin/bbackupd/BackupClientInodeToIDMap.cpp | 8 | ||||
-rwxr-xr-x | bin/bbackupd/BackupClientInodeToIDMap.h | 2 | ||||
-rwxr-xr-x | bin/bbackupd/BackupDaemon.cpp | 94 | ||||
-rwxr-xr-x | bin/bbackupquery/BackupQueries.cpp | 4 | ||||
-rwxr-xr-x | bin/bbackupquery/bbackupquery.cpp | 26 |
6 files changed, 76 insertions, 66 deletions
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<std::string, BackupStoreDirectory::Entry *> 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 <sys/types.h> #include <fcntl.h> #include <limits.h> - #ifdef PLATFORM_LINUX - #include "../../local/_linux_db.h" - #else - #include <db.h> - #endif + #include DB_HEADER #include <sys/stat.h> #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 <utility> // 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 <unistd.h> #include <syslog.h> #include <sys/param.h> -#include <sys/mount.h> #include <signal.h> -#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS - #ifdef PLATFORM_SUNOS - #include <cstdio> - #include <sys/mnttab.h> - #else - #include <mntent.h> - #endif +#ifdef HAVE_SYS_MOUNT_H + #include <sys/mount.h> +#endif +#ifdef HAVE_MNTENT_H + #include <mntent.h> +#endif +#ifdef HAVE_SYS_MNTTAB_H + #include <cstdio> + #include <sys/mnttab.h> #endif #include <sys/wait.h> @@ -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<std::string, int> 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<std::string, mntLenCompare> 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? diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 0d08f1eb..27b5fa76 100755 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -1163,7 +1163,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s continue; } -#ifdef PLATFORM_dirent_BROKEN_d_type +#ifndef HAVE_VALID_DIRENT_D_TYPE std::string fn(rLocalDir); fn += '/'; fn += localDirEn->d_name; @@ -1196,7 +1196,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s // Directory localDirs.insert(std::string(localDirEn->d_name)); } -#endif // PLATFORM_dirent_BROKEN_d_type +#endif } // Close directory if(::closedir(dirhandle) != 0) diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp index aea0faa8..1eb86db6 100755 --- a/bin/bbackupquery/bbackupquery.cpp +++ b/bin/bbackupquery/bbackupquery.cpp @@ -12,12 +12,18 @@ #include <unistd.h> #include <stdio.h> #include <sys/types.h> -#ifndef PLATFORM_READLINE_NOT_SUPPORTED - #ifdef PLATFORM_LINUX - #include "../../local/_linux_readline.h" - #else +#ifdef HAVE_LIBREADLINE + #ifdef HAVE_READLINE_READLINE_H #include <readline/readline.h> + #elif defined(HAVE_READLINE_H) + #include <readline.h> + #endif +#endif +#ifdef HAVE_READLINE_HISTORY + #ifdef HAVE_READLINE_HISTORY_H #include <readline/history.h> + #elif defined(HAVE_HISTORY_H) + #include <history.h> #endif #endif @@ -185,8 +191,10 @@ int main(int argc, const char *argv[]) } // Get commands from input -#ifndef PLATFORM_READLINE_NOT_SUPPORTED +#ifdef HAVE_LIBREADLINE +#ifdef HAVE_READLINE_HISTORY using_history(); +#endif char *last_cmd = 0; while(!context.Stop()) { @@ -203,10 +211,18 @@ int main(int argc, const char *argv[]) } else { +#ifdef HAVE_READLINE_HISTORY add_history(command); +#else + free(last_cmd); +#endif last_cmd = command; } } +#ifndef HAVE_READLINE_HISTORY + free(last_cmd); + last_cmd = 0; +#endif #else // Version for platforms which don't have readline by default FdGetLine getLine(fileno(stdin)); |