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 /lib | |
parent | a84d45498bd861c9225080232948a99c2e317bb8 (diff) |
Import upstream version 0.11~rc3~r2502
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backupclient/BackupClientFileAttributes.cpp | 2 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFile.h | 1 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFileDiff.cpp | 2 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFileEncodeStream.cpp | 2 | ||||
-rw-r--r-- | lib/common/BoxPortsAndFiles.h.in | 9 | ||||
-rw-r--r-- | lib/common/Configuration.cpp | 2 | ||||
-rw-r--r-- | lib/common/DebugMemLeakFinder.cpp | 15 | ||||
-rw-r--r-- | lib/common/Logging.cpp | 4 | ||||
-rw-r--r-- | lib/common/MemLeakFinder.h | 2 | ||||
-rw-r--r-- | lib/common/StreamableMemBlock.cpp | 2 | ||||
-rw-r--r-- | lib/common/Test.cpp | 86 | ||||
-rw-r--r-- | lib/common/Test.h | 4 | ||||
-rw-r--r-- | lib/common/WaitForEvent.h | 2 | ||||
-rw-r--r-- | lib/raidfile/RaidFileController.h | 2 | ||||
-rw-r--r-- | lib/raidfile/RaidFileRead.h | 3 | ||||
-rwxr-xr-x | lib/raidfile/raidfile-config.in | 2 | ||||
-rw-r--r-- | lib/server/Daemon.cpp | 16 |
17 files changed, 123 insertions, 33 deletions
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); } |