diff options
author | Reinhard Tartler <siretart@tauware.de> | 2009-04-13 09:36:22 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2009-04-13 09:36:22 +0200 |
commit | b591c86a418e8d5a0d1c1afd319d9acdad6fd4e3 (patch) | |
tree | dbd40985e2ad6fd3bee55c4613f55ed29ecda7ce | |
parent | a84d45498bd861c9225080232948a99c2e317bb8 (diff) |
Import upstream version 0.11~rc3~r2502
33 files changed, 273 insertions, 117 deletions
diff --git a/.svnrevision b/.svnrevision index 951ba797..232941f6 100644 --- a/.svnrevision +++ b/.svnrevision @@ -1 +1 @@ -2491 +2502 diff --git a/bin/bbackupctl/bbackupctl.cpp b/bin/bbackupctl/bbackupctl.cpp index 2c41f614..8dc8f30e 100644 --- a/bin/bbackupctl/bbackupctl.cpp +++ b/bin/bbackupctl/bbackupctl.cpp @@ -9,7 +9,8 @@ #include "Box.h" -#include <stdio.h> +#include <cstdio> +#include <cstdlib> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/bin/bbackupd/bbackupd-config.in b/bin/bbackupd/bbackupd-config.in index 925dcc3e..98dc8b6e 100755 --- a/bin/bbackupd/bbackupd-config.in +++ b/bin/bbackupd/bbackupd-config.in @@ -19,7 +19,7 @@ Usage: working-dir [backup directories] Parameters: - config-dir is usually @sysconfdir_expanded@/box + config-dir is usually @sysconfdir_expanded@/boxbackup backup-mode is lazy or snapshot: lazy mode runs continously, uploading files over a specified age snapshot mode uploads a snapshot of the filesystem when instructed @@ -57,7 +57,7 @@ __E } # default locations -my $default_config_location = '@sysconfdir_expanded@/box/bbackupd.conf'; +my $default_config_location = '@sysconfdir_expanded@/boxbackup/bbackupd.conf'; # command line parameters my ($config_dir,$backup_mode,$account_num,$server,$working_dir,@tobackup) = @ARGV; diff --git a/bin/bbackupobjdump/bbackupobjdump.cpp b/bin/bbackupobjdump/bbackupobjdump.cpp index 74fff510..5b6c44f7 100644 --- a/bin/bbackupobjdump/bbackupobjdump.cpp +++ b/bin/bbackupobjdump/bbackupobjdump.cpp @@ -9,7 +9,8 @@ #include "Box.h" -#include <stdio.h> +#include <cstdio> +#include <cstring> #include "MainHelper.h" #include "FileStream.h" diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp index 33860dcf..bab697b8 100644 --- a/bin/bbackupquery/bbackupquery.cpp +++ b/bin/bbackupquery/bbackupquery.cpp @@ -14,7 +14,8 @@ #endif #include <errno.h> -#include <stdio.h> +#include <cstdio> +#include <cstdlib> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> diff --git a/bin/bbstoreaccounts/bbstoreaccounts.cpp b/bin/bbstoreaccounts/bbstoreaccounts.cpp index 71114ef4..e377b661 100644 --- a/bin/bbstoreaccounts/bbstoreaccounts.cpp +++ b/bin/bbstoreaccounts/bbstoreaccounts.cpp @@ -36,6 +36,8 @@ #include "MemLeakFindOn.h" +#include <cstring> + // max size of soft limit as percent of hard limit #define MAX_SOFT_LIMIT_SIZE 97 diff --git a/bin/bbstored/bbstored-config.in b/bin/bbstored/bbstored-config.in index 5ad96d50..83305c4f 100755 --- a/bin/bbstored/bbstored-config.in +++ b/bin/bbstored/bbstored-config.in @@ -19,7 +19,7 @@ Usage: bbstored-config config-dir server-hostname username [raidfile-config] Parameters: - config-dir is usually @sysconfdir_expanded@/box + config-dir is usually @sysconfdir_expanded@/boxbackup server-hostname is the hostname that clients will use to connect to this server username is the user to run the server under @@ -47,7 +47,7 @@ __E } # default locations -my $default_config_location = '@sysconfdir_expanded@/box/bbstored.conf'; +my $default_config_location = '@sysconfdir_expanded@/boxbackup/bbstored.conf'; # command line parameters my ($config_dir,$server,$username,$raidfile_config) = @ARGV; diff --git a/configure.ac b/configure.ac index a6e8c812..e171d4ad 100644 --- a/configure.ac +++ b/configure.ac @@ -241,14 +241,20 @@ AC_CHECK_DECLS([XATTR_NOFOLLOW],,, [[#include <sys/xattr.h>]]) ## Check for large file support active. AC_SYS_LARGEFILE has already worked ## out how to enable it if necessary, we just use this to report to the user -AC_CACHE_CHECK([if we have large file support enabled], [box_cv_have_large_file_support], - [AC_TRY_RUN([AC_LANG_PROGRAM([[$ac_includes_default]], [[ +AC_CACHE_CHECK([if we have large file support enabled], + [box_cv_have_large_file_support], + [AC_TRY_RUN([ + $ac_includes_default + int main() + { return sizeof(off_t)==4; - ]])], + } + ], [box_cv_have_large_file_support=yes], [box_cv_have_large_file_support=no], [box_cv_have_large_file_support=no # safe for cross-compile] - )]) + ) + ]) if test "x$box_cv_have_large_file_support" = "xyes"; then AC_DEFINE([HAVE_LARGE_FILE_SUPPORT], [1], diff --git a/contrib/debian/bbackupd.in b/contrib/debian/bbackupd.in index bb7536b5..c340939a 100644 --- a/contrib/debian/bbackupd.in +++ b/contrib/debian/bbackupd.in @@ -7,7 +7,7 @@ NAME=bbackupd LONGNAME="Box Backup Client daemon" BINARY=@sbindir_expanded@/$NAME -CONFIG=@sysconfdir_expanded@/box/$NAME.conf +CONFIG=@sysconfdir_expanded@/boxbackup/$NAME.conf PIDFILE=@localstatedir_expanded@/bbackupd/$NAME.pid test -x $BINARY || exit 0 diff --git a/contrib/debian/bbstored.in b/contrib/debian/bbstored.in index 48fc47f1..c9214537 100644 --- a/contrib/debian/bbstored.in +++ b/contrib/debian/bbstored.in @@ -7,7 +7,7 @@ NAME=bbstored LONGNAME="Box Backup Server daemon" BINARY=@sbindir_expanded@/$NAME -CONFIG=@sysconfdir_expanded@/box/$NAME.conf +CONFIG=@sysconfdir_expanded@/boxbackup/$NAME.conf PIDFILE=@localstatedir_expanded@/run/$NAME.pid test -x $BINARY || exit 0 diff --git a/infrastructure/m4/ax_check_dirent_d_type.m4 b/infrastructure/m4/ax_check_dirent_d_type.m4 index 9c08d391..078a39ee 100644 --- a/infrastructure/m4/ax_check_dirent_d_type.m4 +++ b/infrastructure/m4/ax_check_dirent_d_type.m4 @@ -17,15 +17,17 @@ AC_DEFUN([AX_CHECK_DIRENT_D_TYPE], [ if test "x$ac_cv_member_struct_dirent_d_type" = "xyes"; then AC_CACHE_CHECK([[whether struct dirent.d_type is valid]], [box_cv_have_valid_dirent_d_type], [AC_TRY_RUN( - [AC_LANG_PROGRAM([[ + [ $ac_includes_default #include <dirent.h> - ]], [[ + int main() + { DIR* dir = opendir("."); struct dirent* res = NULL; if(dir) res = readdir(dir); return res ? (res->d_type != DT_FILE && res->d_type != DT_DIR) : 1; - ]])], + } + ], [box_cv_have_valid_dirent_d_type=yes], [box_cv_have_valid_dirent_d_type=no], [box_cv_have_valid_dirent_d_type=cross] diff --git a/infrastructure/m4/ax_check_syscall_lseek.m4 b/infrastructure/m4/ax_check_syscall_lseek.m4 index 6c26e025..9fd04c81 100644 --- a/infrastructure/m4/ax_check_syscall_lseek.m4 +++ b/infrastructure/m4/ax_check_syscall_lseek.m4 @@ -17,7 +17,7 @@ AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [ if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then AC_CACHE_CHECK([[whether syscall lseek requires dummy parameter]], [box_cv_have_lseek_dummy_param], [AC_TRY_RUN( - [AC_LANG_PROGRAM([[ + [ $ac_includes_default #include <fcntl.h> #include <sys/syscall.h> @@ -28,7 +28,8 @@ AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [ #undef syscall #define syscall __syscall #endif - ]], [[ + int main() + { int fh = creat("lseektest", 0600); int res = 0; if(fh>=0) @@ -49,7 +50,8 @@ AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [ } unlink("lseektest"); return res!=-1; - ]])], + } + ], [box_cv_have_lseek_dummy_param=yes], [box_cv_have_lseek_dummy_param=no], [box_cv_have_lseek_dummy_param=no # assume not for cross-compiling] diff --git a/infrastructure/makeparcels.pl.in b/infrastructure/makeparcels.pl.in index e9e240db..cc54b23f 100755 --- a/infrastructure/makeparcels.pl.in +++ b/infrastructure/makeparcels.pl.in @@ -25,6 +25,13 @@ sub os_matches ($) return 0; } +my $copy_command = "cp -p"; + +if ($build_os eq 'CYGWIN') +{ + $copy_command = "cp -pu"; # faster +} + open PARCELS,"parcels.txt" or die "Can't open parcels file"; { my $cur_parcel = ''; @@ -168,7 +175,7 @@ for my $parcel (@parcels) print MAKE <<EOF; $dir/$name$exeext: release/bin/$name/$name$exeext mkdir -p $dir - cp -p release/bin/$name/$name$exeext $dir + $copy_command release/bin/$name/$name$exeext $dir .PHONY: release/bin/$name/$name$exeext release/bin/$name/$name$exeext: @@ -192,11 +199,11 @@ EOF if ($optional) { print MAKE "\ttest -r $fullpath " . - "&& cp -p $fullpath $dir || true\n"; + "&& $copy_command $fullpath $dir || true\n"; } else { - print MAKE "\tcp -p $fullpath $dir\n"; + print MAKE "\t$copy_command $fullpath $dir\n"; } print MAKE "\n"; @@ -208,7 +215,7 @@ EOF print MAKE <<EOF; $dir/${name}.gz: docs/man/${name}.gz mkdir -p $dir - cp -p docs/man/${name}.gz $dir + $copy_command docs/man/${name}.gz $dir EOF # Releases have the docs pre-made, but users diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index bb17d41f..d896a363 100644 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -28,6 +28,8 @@ #include <sys/xattr.h> #endif +#include <cstring> + #include "BackupClientFileAttributes.h" #include "CommonException.h" #include "FileModificationTime.h" diff --git a/lib/backupclient/BackupStoreFile.h b/lib/backupclient/BackupStoreFile.h index f38cd821..f4c60919 100644 --- a/lib/backupclient/BackupStoreFile.h +++ b/lib/backupclient/BackupStoreFile.h @@ -12,6 +12,7 @@ #include <cstdlib> #include <memory> +#include <cstdlib> #include "BackupClientFileAttributes.h" #include "BackupStoreFilename.h" diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp index e9da1ee7..5705c3aa 100644 --- a/lib/backupclient/BackupStoreFileDiff.cpp +++ b/lib/backupclient/BackupStoreFileDiff.cpp @@ -35,6 +35,8 @@ #include "MemLeakFindOn.h" +#include <cstring> + using namespace BackupStoreFileCryptVar; using namespace BackupStoreFileCreation; diff --git a/lib/backupclient/BackupStoreFileEncodeStream.cpp b/lib/backupclient/BackupStoreFileEncodeStream.cpp index b2d44697..54c2463d 100644 --- a/lib/backupclient/BackupStoreFileEncodeStream.cpp +++ b/lib/backupclient/BackupStoreFileEncodeStream.cpp @@ -26,6 +26,8 @@ #include "MemLeakFindOn.h" +#include <cstring> + using namespace BackupStoreFileCryptVar; diff --git a/lib/common/BoxPortsAndFiles.h.in b/lib/common/BoxPortsAndFiles.h.in index fcc0ddce..e30dcf90 100644 --- a/lib/common/BoxPortsAndFiles.h.in +++ b/lib/common/BoxPortsAndFiles.h.in @@ -31,9 +31,12 @@ #define BOX_GET_DEFAULT_BBSTORED_CONFIG_FILE \ GetDefaultConfigFilePath("bbstored.conf").c_str() #else -#define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "@sysconfdir_expanded@/box/bbackupd.conf" -#define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "@sysconfdir_expanded@/box/raidfile.conf" -#define BOX_FILE_BBSTORED_DEFAULT_CONFIG "@sysconfdir_expanded@/box/bbstored.conf" +#define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "@sysconfdir_expanded@/boxbackup/bbackupd.conf" +#define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "@sysconfdir_expanded@/boxbackup/raidfile.conf" +#define BOX_FILE_BBSTORED_DEFAULT_CONFIG "@sysconfdir_expanded@/boxbackup/bbstored.conf" +#define BOX_FILE_BBACKUPD_OLD_CONFIG "@sysconfdir_expanded@/box/bbackupd.conf" +#define BOX_FILE_RAIDFILE_OLD_CONFIG "@sysconfdir_expanded@/box/raidfile.conf" +#define BOX_FILE_BBSTORED_OLD_CONFIG "@sysconfdir_expanded@/box/bbstored.conf" #endif #endif // BOXPORTSANDFILES__H diff --git a/lib/common/Configuration.cpp b/lib/common/Configuration.cpp index 7d2e0bac..2eb5fbca 100644 --- a/lib/common/Configuration.cpp +++ b/lib/common/Configuration.cpp @@ -22,6 +22,8 @@ #include "MemLeakFindOn.h" +#include <cstring> + // utility whitespace function inline bool iw(int c) { diff --git a/lib/common/DebugMemLeakFinder.cpp b/lib/common/DebugMemLeakFinder.cpp index 230d7163..72891cd1 100644 --- a/lib/common/DebugMemLeakFinder.cpp +++ b/lib/common/DebugMemLeakFinder.cpp @@ -24,6 +24,7 @@ #include <stdio.h> #include <string.h> #include <set> +#include <cstdlib> // for std::atexit #include "MemLeakFinder.h" @@ -130,7 +131,7 @@ void *memleakfinder_malloc(size_t size, const char *file, int line) { InternalAllocGuard guard; - void *b = ::malloc(size); + void *b = std::malloc(size); if(!memleakfinder_global_enable) return b; if(!memleakfinder_initialised) return b; @@ -146,7 +147,7 @@ void *memleakfinder_realloc(void *ptr, size_t size) if(!memleakfinder_global_enable || !memleakfinder_initialised) { - return ::realloc(ptr, size); + return std::realloc(ptr, size); } // Check it's been allocated @@ -158,7 +159,7 @@ void *memleakfinder_realloc(void *ptr, size_t size) "objects?"); } - void *b = ::realloc(ptr, size); + void *b = std::realloc(ptr, size); if(ptr && i!=sMallocBlocks.end()) { @@ -215,7 +216,7 @@ void memleakfinder_free(void *ptr) } //TRACE1("free(), %08x\n", ptr); - ::free(ptr); + std::free(ptr); } @@ -426,7 +427,7 @@ void memleakfinder_setup_exit_report(const char *filename, const char *markertex atexit_markertext[sizeof(atexit_markertext)-1] = 0; if(!atexit_registered) { - atexit(memleakfinder_atexit); + std::atexit(memleakfinder_atexit); atexit_registered = true; } } @@ -490,7 +491,7 @@ static void *internal_new(size_t size, const char *file, int line) { InternalAllocGuard guard; - r = ::malloc(size); + r = std::malloc(size); } if (sInternalAllocDepth == 0) @@ -533,7 +534,7 @@ void internal_delete(void *ptr) { InternalAllocGuard guard; - ::free(ptr); + std::free(ptr); remove_object_block(ptr); //TRACE1("delete[]() called, %08x\n", ptr); } diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index 1f872d93..1666b487 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -11,6 +11,10 @@ #include <errno.h> #include <time.h> +#include <string.h> // for stderror + +// c.f. http://bugs.debian.org/512510 +#include <cstdio> #ifdef HAVE_SYSLOG_H #include <syslog.h> diff --git a/lib/common/MemLeakFinder.h b/lib/common/MemLeakFinder.h index 450d42f8..ca207bd5 100644 --- a/lib/common/MemLeakFinder.h +++ b/lib/common/MemLeakFinder.h @@ -12,7 +12,7 @@ #ifdef MEMLEAKFINDER_FULL_MALLOC_MONITORING // include stdlib now, to avoid problems with having the macros defined already - #include <stdlib.h> + #include <cstdlib> #endif // global enable flag diff --git a/lib/common/StreamableMemBlock.cpp b/lib/common/StreamableMemBlock.cpp index 7700152d..cf431022 100644 --- a/lib/common/StreamableMemBlock.cpp +++ b/lib/common/StreamableMemBlock.cpp @@ -10,7 +10,7 @@ #include "Box.h" #include <new> -#include <stdlib.h> +#include <cstdlib> #include <string.h> #include "StreamableMemBlock.h" diff --git a/lib/common/Test.cpp b/lib/common/Test.cpp index 04d778c1..e903f41e 100644 --- a/lib/common/Test.cpp +++ b/lib/common/Test.cpp @@ -229,7 +229,14 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) #endif // time for it to start up - ::fprintf(stdout, "Waiting for server to start: "); + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_TRACE("Waiting for server to start"); + } + else + { + ::fprintf(stdout, "Waiting for server to start: "); + } for (int i = 0; i < 15; i++) { @@ -243,8 +250,12 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) break; } - ::fprintf(stdout, "."); - ::fflush(stdout); + if (Logging::GetGlobalLevel() < Log::TRACE) + { + ::fprintf(stdout, "."); + ::fflush(stdout); + } + ::sleep(1); } @@ -253,19 +264,42 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) if (pidIfKnown && !ServerIsAlive(pidIfKnown)) { - ::fprintf(stdout, " server died!\n"); + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_ERROR("server died!"); + } + else + { + ::fprintf(stdout, " server died!\n"); + } + TEST_FAIL_WITH_MESSAGE("Server died!"); return -1; } if (!TestFileNotEmpty(pidFile)) { - ::fprintf(stdout, " timed out!\n"); + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_ERROR("timed out!"); + } + else + { + ::fprintf(stdout, " timed out!\n"); + } + TEST_FAIL_WITH_MESSAGE("Server didn't save PID file"); return -1; } - ::fprintf(stdout, " done.\n"); + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_TRACE("Server started"); + } + else + { + ::fprintf(stdout, " done.\n"); + } // wait a second for the pid to be written to the file ::sleep(1); @@ -278,8 +312,9 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) if (pidIfKnown && pid != pidIfKnown) { - printf("Server wrote wrong pid to file (%s): expected %d " - "but found %d\n", pidFile, pidIfKnown, pid); + BOX_ERROR("Server wrote wrong pid to file (" << pidFile << + "): expected " << pidIfKnown << " but found " << + pid); TEST_FAIL_WITH_MESSAGE("Server wrote wrong pid to file"); return -1; } @@ -381,22 +416,43 @@ void terminate_bbackupd(int pid) // Wait a given number of seconds for something to complete -void wait_for_operation(int seconds) +void wait_for_operation(int seconds, char* message) { - printf("Waiting: "); - fflush(stdout); + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_TRACE("Waiting " << seconds << " seconds for " << message); + } + else + { + printf("Waiting for %s: ", message); + fflush(stdout); + } + for(int l = 0; l < seconds; ++l) { sleep(1); - printf("."); + if (Logging::GetGlobalLevel() < Log::TRACE) + { + printf("."); + fflush(stdout); + } + } + + if (Logging::GetGlobalLevel() >= Log::TRACE) + { + BOX_TRACE("Finished waiting for " << message); + } + else + { + printf(" done.\n"); fflush(stdout); } - printf(" done.\n"); - fflush(stdout); } void safe_sleep(int seconds) { + BOX_TRACE("sleeping for " << seconds << " seconds"); + #ifdef WIN32 Sleep(seconds * 1000); #else @@ -404,7 +460,6 @@ void safe_sleep(int seconds) memset(&ts, 0, sizeof(ts)); ts.tv_sec = seconds; ts.tv_nsec = 0; - BOX_TRACE("sleeping for " << seconds << " seconds"); while (nanosleep(&ts, &ts) == -1 && errno == EINTR) { BOX_TRACE("safe_sleep interrupted with " << @@ -415,4 +470,3 @@ void safe_sleep(int seconds) #endif } - diff --git a/lib/common/Test.h b/lib/common/Test.h index f4766ddc..362b43af 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -10,7 +10,7 @@ #ifndef TEST__H #define TEST__H -#include <string> +#include <cstring> #ifdef WIN32 #define BBACKUPCTL "..\\..\\bin\\bbackupctl\\bbackupctl.exe" @@ -158,7 +158,7 @@ void sync_and_wait(); void terminate_bbackupd(int pid); // Wait a given number of seconds for something to complete -void wait_for_operation(int seconds); +void wait_for_operation(int seconds, char* message); void safe_sleep(int seconds); #endif // TEST__H diff --git a/lib/common/WaitForEvent.h b/lib/common/WaitForEvent.h index 045d6d67..a80761ef 100644 --- a/lib/common/WaitForEvent.h +++ b/lib/common/WaitForEvent.h @@ -22,6 +22,8 @@ #endif #endif +#include <cstdlib> + #include "CommonException.h" #include "MemLeakFindOn.h" diff --git a/lib/raidfile/RaidFileController.h b/lib/raidfile/RaidFileController.h index 783cb055..216bdf3a 100644 --- a/lib/raidfile/RaidFileController.h +++ b/lib/raidfile/RaidFileController.h @@ -82,7 +82,7 @@ public: public: void Initialise(const std::string& rConfigFilename = - "/etc/box/raidfile.conf"); + "/etc/boxbackup/raidfile.conf"); int GetNumDiscSets() {return mSetList.size();} // -------------------------------------------------------------------------- diff --git a/lib/raidfile/RaidFileRead.h b/lib/raidfile/RaidFileRead.h index 93bf7388..8a04409d 100644 --- a/lib/raidfile/RaidFileRead.h +++ b/lib/raidfile/RaidFileRead.h @@ -10,7 +10,8 @@ #ifndef RAIDFILEREAD__H #define RAIDFILEREAD__H -#include <string> +#include <cstring> +#include <cstdlib> #include <memory> #include <vector> diff --git a/lib/raidfile/raidfile-config.in b/lib/raidfile/raidfile-config.in index 76b65ace..b8ea73a5 100755 --- a/lib/raidfile/raidfile-config.in +++ b/lib/raidfile/raidfile-config.in @@ -19,7 +19,7 @@ Usage: raidfile-config config-dir block-size dir0 [dir1 dir2] Parameters: - config-dir is usually @sysconfdir_expanded@/box + config-dir is usually @sysconfdir_expanded@/boxbackup block-size must be a power of two, and usually the block or fragment size of your file system dir0, dir1, dir2 are the directories used as the root of the raid diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index d868774f..c4026395 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -32,6 +32,7 @@ #include "UnixUser.h" #include "FileModificationTime.h" #include "Logging.h" +#include "Utils.h" #include "MemLeakFindOn.h" @@ -336,6 +337,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) if (argc > optind && !mHaveConfigFile) { mConfigFileName = argv[optind]; optind++; + mHaveConfigFile = true; } if (argc > optind && ::strcmp(argv[optind], "SINGLEPROCESS") == 0) @@ -375,6 +377,20 @@ bool Daemon::Configure(const std::string& rConfigFileName) try { + if (!FileExists(rConfigFileName.c_str())) + { + BOX_FATAL("The main configuration file for " << + DaemonName() << " was not found: " << + rConfigFileName); + if (!mHaveConfigFile) + { + BOX_WARNING("The default configuration " + "directory has changed from /etc/box " + "to /etc/boxbackup"); + } + return false; + } + apConfig = Configuration::LoadAndVerify(rConfigFileName, GetConfigVerify(), errors); } diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp index 4fbf296a..23b01b15 100644 --- a/test/backupstorepatch/testbackupstorepatch.cpp +++ b/test/backupstorepatch/testbackupstorepatch.cpp @@ -578,7 +578,7 @@ int test(int argc, const char *argv[]) #ifdef WIN32 // Cannot signal bbstored to do housekeeping now, // so just wait until we're sure it's done - wait_for_operation(12); + wait_for_operation(12, "housekeeping to run"); #else // Send the server a restart signal, so it does // housekeeping immediately, and wait for it to happen diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 9d82a11b..91c883cc 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -87,9 +87,9 @@ // two cycles and a bit #define TIME_TO_WAIT_FOR_BACKUP_OPERATION 12 -void wait_for_backup_operation(int seconds = TIME_TO_WAIT_FOR_BACKUP_OPERATION) +void wait_for_backup_operation(char* message) { - wait_for_operation(seconds); + wait_for_operation(TIME_TO_WAIT_FOR_BACKUP_OPERATION, message); } int bbstored_pid = 0; @@ -889,7 +889,7 @@ int test_bbackupd() TEST_THAT(close(fd) == 0); int pid = start_internal_daemon(); - wait_for_backup_operation(); + wait_for_backup_operation("internal daemon to run a sync"); TEST_THAT(stop_internal_daemon(pid)); // two-second delay on the first read() of f1 @@ -910,7 +910,8 @@ int test_bbackupd() "Buffer write"); TEST_THAT(close(fd) == 0); - wait_for_backup_operation(); + wait_for_backup_operation("internal daemon to sync " + "spacetest/f1"); // can't test whether intercept was triggered, because // it's in a different process. // TEST_THAT(intercept_triggered()); @@ -985,7 +986,8 @@ int test_bbackupd() "Buffer write"); TEST_THAT(close(fd) == 0); - wait_for_backup_operation(); + wait_for_backup_operation("internal daemon to sync " + "spacetest/f1 again"); // can't test whether intercept was triggered, because // it's in a different process. // TEST_THAT(intercept_triggered()); @@ -1050,7 +1052,8 @@ int test_bbackupd() "Buffer write"); TEST_THAT(close(fd) == 0); - wait_for_backup_operation(); + wait_for_backup_operation("internal daemon to sync " + "spacetest/f1 again"); // can't test whether intercept was triggered, because // it's in a different process. // TEST_THAT(intercept_triggered()); @@ -1139,7 +1142,8 @@ int test_bbackupd() "Buffer write"); TEST_THAT(close(fd) == 0); - wait_for_backup_operation(); + wait_for_backup_operation("internal daemon to scan " + "spacetest/d1"); // can't test whether intercept was triggered, because // it's in a different process. // TEST_THAT(intercept_triggered()); @@ -1284,10 +1288,10 @@ int test_bbackupd() // housekeeping deleted them, the backup cannot complete // if the limit is 20 blocks. - BOX_TRACE("Waiting for bbackupd to notice that the " + BOX_TRACE("Waiting for sync for bbackupd to notice that the " "store is full"); wait_for_sync_end(); - BOX_TRACE("done."); + BOX_TRACE("Sync finished."); BOX_TRACE("Compare to check that there are differences"); int compareReturnValue = ::system(BBACKUPQUERY " " @@ -1297,7 +1301,7 @@ int test_bbackupd() TEST_RETURN(compareReturnValue, BackupQueries::ReturnCode::Compare_Different); TestRemoteProcessMemLeaks("bbackupquery.memleaks"); - BOX_TRACE("done."); + BOX_TRACE("Compare finished."); // Check that the notify script was run TEST_THAT(TestFileExists("testfiles/notifyran.store-full.1")); @@ -1307,9 +1311,8 @@ int test_bbackupd() // Kill the daemon terminate_bbackupd(bbackupd_pid); - BOX_TRACE("Wait for housekeeping to remove the deleted files"); - wait_for_backup_operation(5); - BOX_TRACE("done."); + wait_for_operation(5, "housekeeping to remove the " + "deleted files"); // This removes f1 and d7, which were previously marked // as deleted, so total usage drops by 4 blocks to 24. @@ -1470,9 +1473,8 @@ int test_bbackupd() return 1; } - BOX_TRACE("Wait for housekeeping to remove the deleted files"); - wait_for_backup_operation(5); - BOX_TRACE("done."); + wait_for_operation(5, "housekeeping to remove the " + "deleted files"); BOX_TRACE("Check that the files were removed"); { @@ -1606,9 +1608,7 @@ int test_bbackupd() "| ( cd testfiles && tar xf - )") == 0); #endif - BOX_TRACE("Wait for bbackupd to upload more files"); - wait_for_backup_operation(); - BOX_TRACE("done."); + wait_for_backup_operation("bbackupd to upload more files"); // Check that the contents of the store are the same // as the contents of the disc @@ -1755,7 +1755,7 @@ int test_bbackupd() return 1; } - test_run_bbstored(); + TEST_THAT(test_run_bbstored() == 0); cmd = BBACKUPD " " + bbackupd_args + " testfiles/bbackupd.conf"; @@ -1803,8 +1803,8 @@ int test_bbackupd() // also test symlink-to-self loop does not break restore TEST_THAT(symlink("self", SYM_DIR "/self") == 0); - ::wait_for_operation(4); - ::sync_and_wait(); + wait_for_operation(4, "symlinks to be old enough"); + sync_and_wait(); // Check that the backup was successful, i.e. no differences int compareReturnValue = ::system(BBACKUPQUERY " " @@ -2207,7 +2207,8 @@ int test_bbackupd() fs.Close(); } - wait_for_backup_operation(); + wait_for_backup_operation("upload of file with unicode name"); + // Compare to check that the file was uploaded compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " "-c testfiles/bbackupd.conf \"compare -acQ\" quit"); @@ -2540,8 +2541,13 @@ int test_bbackupd() > 1024); } - // wait for backup daemon to do it's stuff, and compare again - wait_for_backup_operation(); + // wait long enough for new files to be old enough to backup + wait_for_operation(5, "new files to be old enough"); + + // wait for backup daemon to do it's stuff + sync_and_wait(); + + // compare to make sure that it worked compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " "-c testfiles/bbackupd.conf " "-l testfiles/query2.log " @@ -2586,7 +2592,8 @@ int test_bbackupd() TEST_THAT(close(fd1) == 0); } - wait_for_backup_operation(4); + wait_for_operation(4, "bbackupd to try to access the store"); + // Check that an error was reported just once TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.1")); TEST_THAT(!TestFileExists("testfiles/notifyran.backup-error.2")); @@ -2644,9 +2651,11 @@ int test_bbackupd() TEST_THAT(close(fd1) == 0); } - // bbackupd should pause for about 90 seconds from store_fixed_time, - // so check that it hasn't run after 85 seconds from store_fixed_time - wait_for_backup_operation(85 - time(NULL) + store_fixed_time); + // bbackupd should pause for about 90 seconds from + // store_fixed_time, so check that it hasn't run after + // 85 seconds after store_fixed_time + wait_for_operation(85 - time(NULL) + store_fixed_time, + "just before bbackupd recovers"); TEST_THAT(!TestFileExists("testfiles/" "notifyran.backup-start.wait-snapshot.1")); @@ -2660,7 +2669,7 @@ int test_bbackupd() TestRemoteProcessMemLeaks("bbackupquery.memleaks"); // wait another 10 seconds, bbackup should have run - wait_for_backup_operation(10); + wait_for_operation(10, "bbackupd to recover"); TEST_THAT(TestFileExists("testfiles/" "notifyran.backup-start.wait-snapshot.1")); @@ -2742,9 +2751,11 @@ int test_bbackupd() TEST_THAT(close(fd1) == 0); } - // bbackupd should pause for about 90 seconds from store_fixed_time, - // so check that it hasn't run after 85 seconds from store_fixed_time - wait_for_backup_operation(85 - time(NULL) + store_fixed_time); + // bbackupd should pause for about 90 seconds from + // store_fixed_time, so check that it hasn't run after + // 85 seconds from store_fixed_time + wait_for_operation(85 - time(NULL) + store_fixed_time, + "just before bbackupd recovers"); TEST_THAT(!TestFileExists("testfiles/" "notifyran.backup-start.wait-automatic.1")); @@ -2758,7 +2769,7 @@ int test_bbackupd() TestRemoteProcessMemLeaks("bbackupquery.memleaks"); // wait another 10 seconds, bbackup should have run - wait_for_backup_operation(10); + wait_for_operation(10, "bbackupd to recover"); TEST_THAT(TestFileExists("testfiles/" "notifyran.backup-start.wait-automatic.1")); @@ -2801,7 +2812,7 @@ int test_bbackupd() == 0); #endif - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync the changes"); compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3c.log " @@ -2830,7 +2841,8 @@ int test_bbackupd() "testfiles/TestDir1/x1/dir-to-file") == 0); #endif - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync the changes"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3d.log " @@ -2862,7 +2874,8 @@ int test_bbackupd() == 0); #endif - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync the changes"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3e.log " @@ -2894,7 +2907,8 @@ int test_bbackupd() "testfiles/TestDir1/x1/dir-to-file") == 0); #endif - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync the changes"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3f.log " @@ -2924,9 +2938,12 @@ int test_bbackupd() TEST_THAT(close(fd2) == 0); TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-1")); TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-2")); - wait_for_operation(5); + // back up both files - wait_for_backup_operation(); + wait_for_operation(5, "untracked files to be old enough"); + wait_for_backup_operation("bbackupd to sync the " + "untracked files"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3g.log " @@ -2944,7 +2961,10 @@ int test_bbackupd() "testfiles/TestDir1/untracked-2") == 0); TEST_THAT(!TestFileExists("testfiles/TestDir1/untracked-1")); TEST_THAT( TestFileExists("testfiles/TestDir1/untracked-2")); - wait_for_backup_operation(); + + wait_for_backup_operation("bbackupd to sync the untracked " + "files again"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3g.log " @@ -2977,9 +2997,14 @@ int test_bbackupd() TEST_THAT(close(fd2) == 0); TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-1")); TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-2")); - wait_for_operation(5); + + // wait for them to be old enough to back up + wait_for_operation(5, "tracked files to be old enough"); + // back up both files - wait_for_backup_operation(); + sync_and_wait(); + + // compare to make sure that it worked compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3h.log " @@ -2997,7 +3022,10 @@ int test_bbackupd() "testfiles/TestDir1/tracked-2") == 0); TEST_THAT(!TestFileExists("testfiles/TestDir1/tracked-1")); TEST_THAT( TestFileExists("testfiles/TestDir1/tracked-2")); - wait_for_backup_operation(); + + wait_for_backup_operation("bbackupd to sync the tracked " + "files again"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3i.log " @@ -3018,7 +3046,8 @@ int test_bbackupd() TEST_THAT(::rename("testfiles/TestDir1/df9834.dsf", "testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3j.log " @@ -3056,7 +3085,8 @@ int test_bbackupd() #endif // Wait and test - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync old files"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3k.log " @@ -3239,7 +3269,8 @@ int test_bbackupd() } // Wait and test... - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to try to sync " + "unreadable file"); compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3o.log " @@ -3343,7 +3374,9 @@ int test_bbackupd() ::chmod("testfiles/TestDir1/df9834.dsf", 0423); // Wait and test - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync deletion " + "of directory"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query4.log " @@ -3544,7 +3577,8 @@ int test_bbackupd() #endif // Wait and test - wait_for_backup_operation(); + wait_for_backup_operation("bbackupd to sync new files"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query5.log " @@ -3562,7 +3596,9 @@ int test_bbackupd() printf("\n==== Rename directory\n"); TEST_THAT(rename("testfiles/TestDir1/sub23/dhsfdss", "testfiles/TestDir1/renamed-dir") == 0); - wait_for_backup_operation(); + + wait_for_backup_operation("bbackupd to sync renamed directory"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query6.log " @@ -3588,7 +3624,9 @@ int test_bbackupd() "testfiles/TestDir1/df324-ren") == 0); TEST_THAT(rename("testfiles/TestDir1/sub23/find2perl", "testfiles/TestDir1/find2perl-ren") == 0); - wait_for_backup_operation(); + + wait_for_backup_operation("bbackupd to sync renamed files"); + compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query6.log " @@ -3631,7 +3669,7 @@ int test_bbackupd() } // Wait and test - wait_for_backup_operation(); + wait_for_backup_operation("bbackup to sync future file"); compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query3e.log " @@ -3698,9 +3736,11 @@ int test_bbackupd() ::fclose(f); } - // Wait and test that there *are* differences - wait_for_backup_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION * - 3) / 2); // little bit longer than usual + // Wait a little bit longer than usual + wait_for_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION * + 3) / 2, "bbackupd to detect changed store marker"); + + // Test that there *are* differences compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query6.log " @@ -3714,9 +3754,8 @@ int test_bbackupd() if (!ServerIsAlive(bbackupd_pid)) return 1; if (!ServerIsAlive(bbstored_pid)) return 1; - printf("\n==== Waiting for bbackupd to recover\n"); // 100 seconds - (12*3/2) - wait_for_operation(82); + wait_for_operation(82, "bbackupd to recover"); TEST_THAT(ServerIsAlive(bbackupd_pid)); TEST_THAT(ServerIsAlive(bbstored_pid)); @@ -3947,8 +3986,9 @@ int test_bbackupd() if(bbackupd_pid != -1 && bbackupd_pid != 0) { // Wait and compare (a little bit longer than usual) - wait_for_backup_operation( - (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2); + wait_for_operation( + (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2, + "bbackupd to sync everything"); compareReturnValue = ::system(BBACKUPQUERY " " "-c testfiles/bbackupd.conf " "-l testfiles/query4a.log " @@ -4006,6 +4046,7 @@ int test(int argc, const char *argv[]) if(r != 0) return r; r = test_run_bbstored(); + TEST_THAT(r == 0); if(r != 0) return r; r = test_bbackupd(); diff --git a/test/httpserver/testhttpserver.cpp b/test/httpserver/testhttpserver.cpp index c38ef8fe..6c0de9a9 100644 --- a/test/httpserver/testhttpserver.cpp +++ b/test/httpserver/testhttpserver.cpp @@ -9,6 +9,7 @@ #include "Box.h" +#include <algorithm> #include <cstdio> #include <cstring> #include <ctime> @@ -358,7 +359,9 @@ int test(int argc, const char *argv[]) // Run the request script TEST_THAT(::system("perl testfiles/testrequests.pl") == 0); + #ifndef WIN32 signal(SIGPIPE, SIG_IGN); + #endif SocketStream sock; sock.Open(Socket::TypeINET, "localhost", 1080); |