summaryrefslogtreecommitdiff
path: root/lib/backupclient
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-04-04 22:11:45 +0000
committerChris Wilson <chris+github@qwirx.com>2008-04-04 22:11:45 +0000
commitf2e6283815f4b598f3aa13441f82228370b8d077 (patch)
tree82886fbcbce618878dff2fb2ab6229d91e2f69d1 /lib/backupclient
parentd5f9f9c253584cc12cd88c83afd6c6bfcc6ebd68 (diff)
Undo mangling by tailor
Diffstat (limited to 'lib/backupclient')
-rw-r--r--lib/backupclient/BackupClientRestore.cpp36
-rw-r--r--lib/backupclient/BackupDaemonConfigVerify.cpp89
-rw-r--r--lib/backupclient/BackupStoreFileDiff.cpp36
-rw-r--r--lib/backupclient/BackupStoreFilenameClear.cpp6
-rw-r--r--lib/backupclient/BackupStoreObjectDump.cpp10
5 files changed, 107 insertions, 70 deletions
diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp
index b5a54964..aab514ad 100644
--- a/lib/backupclient/BackupClientRestore.cpp
+++ b/lib/backupclient/BackupClientRestore.cpp
@@ -267,14 +267,14 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
"restore this object.");
if(::unlink(rLocalDirectoryName.c_str()) != 0)
{
- BOX_ERROR("Failed to delete file " <<
- rLocalDirectoryName << ": " <<
- strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to delete "
+ "file '" <<
+ rLocalDirectoryName << "'");
return Restore_UnknownError;
}
BOX_TRACE("In restore, directory name "
- "collision with file " <<
- rLocalDirectoryName);
+ "collision with file '" <<
+ rLocalDirectoryName << "'");
}
break;
case ObjectExists_NoObject:
@@ -378,9 +378,8 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
exists == ObjectExists_File) &&
::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0)
{
- BOX_ERROR("Failed to create directory '" <<
- rLocalDirectoryName << "': " <<
- strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to create directory '" <<
+ rLocalDirectoryName << "'");
return Restore_UnknownError;
}
@@ -451,7 +450,9 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
{
// Local name
BackupStoreFilenameClear nm(en->GetName());
- std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename());
+ std::string localFilename(rLocalDirectoryName +
+ DIRECTORY_SEPARATOR_ASCHAR +
+ nm.GetClearFilename());
// Unlink anything which already exists:
// For resuming restores, we can't overwrite
@@ -459,20 +460,23 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
if(ObjectExists(localFilename) != ObjectExists_NoObject &&
::unlink(localFilename.c_str()) != 0)
{
- BOX_ERROR("Failed to delete file '" <<
- localFilename << "': " <<
- strerror(errno));
+ BOX_LOG_SYS_ERROR("Failed to delete "
+ "file '" << localFilename <<
+ "'");
return Restore_UnknownError;
}
// Request it from the store
- rConnection.QueryGetFile(DirectoryID, en->GetObjectID());
+ rConnection.QueryGetFile(DirectoryID,
+ en->GetObjectID());
// Stream containing encoded file
- std::auto_ptr<IOStream> objectStream(rConnection.ReceiveStream());
+ std::auto_ptr<IOStream> objectStream(
+ rConnection.ReceiveStream());
- // Decode the file -- need to do different things depending on whether
- // the directory entry has additional attributes
+ // Decode the file -- need to do different
+ // things depending on whether the directory
+ // entry has additional attributes
try
{
if(en->HasAttributes())
diff --git a/lib/backupclient/BackupDaemonConfigVerify.cpp b/lib/backupclient/BackupDaemonConfigVerify.cpp
index 61033b5b..db1de4fa 100644
--- a/lib/backupclient/BackupDaemonConfigVerify.cpp
+++ b/lib/backupclient/BackupDaemonConfigVerify.cpp
@@ -17,15 +17,15 @@
static const ConfigurationVerifyKey backuplocationkeys[] =
{
- {"ExcludeFile", 0, ConfigTest_MultiValueAllowed, 0},
- {"ExcludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
- {"ExcludeDir", 0, ConfigTest_MultiValueAllowed, 0},
- {"ExcludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
- {"AlwaysIncludeFile", 0, ConfigTest_MultiValueAllowed, 0},
- {"AlwaysIncludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
- {"AlwaysIncludeDir", 0, ConfigTest_MultiValueAllowed, 0},
- {"AlwaysIncludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
- {"Path", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+ ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("ExcludeDir", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("ExcludeDirsRegex", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("AlwaysIncludeFile", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("AlwaysIncludeFilesRegex", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("AlwaysIncludeDir", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("AlwaysIncludeDirsRegex", ConfigTest_MultiValueAllowed),
+ ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry)
};
static const ConfigurationVerify backuplocations[] =
@@ -64,39 +64,54 @@ static const ConfigurationVerify verifyserver[] =
static const ConfigurationVerifyKey verifyrootkeys[] =
{
- {"AccountNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-
- {"UpdateStoreInterval", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
- {"MinimumFileAge", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
- {"MaxUploadWait", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
- {"MaxFileTimeInFuture", "172800", ConfigTest_IsInt, 0}, // file is uploaded if the file is this much in the future (2 days default)
-
- {"AutomaticBackup", "yes", ConfigTest_IsBool, 0},
+ ConfigurationVerifyKey("AccountNumber",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("UpdateStoreInterval",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("MinimumFileAge",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("MaxUploadWait",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("MaxFileTimeInFuture", ConfigTest_IsInt, 172800),
+ // file is uploaded if the file is this much in the future
+ // (2 days default)
+ ConfigurationVerifyKey("AutomaticBackup", ConfigTest_IsBool, true),
- {"SyncAllowScript", 0, 0, 0}, // optional script to run to see if the sync should be started now
- // return "now" if it's allowed, or a number of seconds if it's not
-
- {"MaximumDiffingTime", 0, ConfigTest_IsInt, 0},
- {"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0},
+ ConfigurationVerifyKey("SyncAllowScript", 0),
+ // script that returns "now" if backup is allowed now, or a number
+ // of seconds to wait before trying again if not
- {"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
- {"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
- {"StoreHostname", 0, ConfigTest_Exists, 0},
- {"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // extended log to syslog
- {"ExtendedLogFile", NULL, 0, 0}, // extended log to a file
- {"LogAllFileAccess", "no", ConfigTest_IsBool, 0},
+ ConfigurationVerifyKey("MaximumDiffingTime", ConfigTest_IsInt),
+ ConfigurationVerifyKey("DeleteRedundantLocationsAfter",
+ ConfigTest_IsInt, 172800),
- {"CommandSocket", 0, 0, 0}, // not compulsory to have this
- {"KeepAliveTime", 0, ConfigTest_IsInt, 0}, // optional
- {"StoreObjectInfoFile", 0, 0, 0}, // optional
+ ConfigurationVerifyKey("FileTrackingSizeThreshold",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("DiffingUploadSizeThreshold",
+ ConfigTest_Exists | ConfigTest_IsInt),
+ ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists),
+ ConfigurationVerifyKey("StorePort", ConfigTest_IsInt,
+ BOX_PORT_BBSTORED),
+ ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
+ // extended log to syslog
+ ConfigurationVerifyKey("ExtendedLogFile", 0),
+ // extended log to a file
+ ConfigurationVerifyKey("LogAllFileAccess", ConfigTest_IsBool, false),
+ ConfigurationVerifyKey("CommandSocket", 0),
+ // not compulsory to have this
+ ConfigurationVerifyKey("KeepAliveTime", ConfigTest_IsInt),
+ ConfigurationVerifyKey("StoreObjectInfoFile", 0),
+ // optional
- {"NotifyScript", 0, 0, 0}, // optional script to run when backup needs attention, eg store full
+ ConfigurationVerifyKey("NotifyScript", 0),
+ // optional script to run when backup needs attention, eg store full
- {"CertificateFile", 0, ConfigTest_Exists, 0},
- {"PrivateKeyFile", 0, ConfigTest_Exists, 0},
- {"TrustedCAsFile", 0, ConfigTest_Exists, 0},
- {"KeysFile", 0, ConfigTest_Exists, 0},
- {"DataDirectory", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+ ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
+ ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
+ ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists),
+ ConfigurationVerifyKey("KeysFile", ConfigTest_Exists),
+ ConfigurationVerifyKey("DataDirectory",
+ ConfigTest_Exists | ConfigTest_LastEntry),
};
const ConfigurationVerify BackupDaemonConfigVerify =
diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp
index f7842a0b..d550e2ba 100644
--- a/lib/backupclient/BackupStoreFileDiff.cpp
+++ b/lib/backupclient/BackupStoreFileDiff.cpp
@@ -149,7 +149,7 @@ std::auto_ptr<IOStream> BackupStoreFile::EncodeFileDiff
int64_t blocksInIndex = 0;
bool canDiffFromThis = false;
LoadIndex(rDiffFromBlockIndex, DiffFromObjectID, &pindex, blocksInIndex, Timeout, canDiffFromThis);
- //TRACE1("Diff: Blocks in index: %lld\n", blocksInIndex);
+ // BOX_TRACE("Diff: Blocks in index: " << blocksInIndex);
if(!canDiffFromThis)
{
@@ -439,7 +439,9 @@ static void FindMostUsedSizes(BlocksAvailableEntry *pIndex, int64_t NumBlocks, i
{
for(int t = 0; t < BACKUP_FILE_DIFF_MAX_BLOCK_SIZES; ++t)
{
- TRACE3("Diff block size %d: %d (count = %lld)\n", t, Sizes[t], sizeCounts[t]);
+ BOX_TRACE("Diff block size " << t << ": " <<
+ Sizes[t] << " (count = " <<
+ sizeCounts[t] << ")");
}
}
#endif
@@ -774,7 +776,7 @@ static void SetupHashTable(BlocksAvailableEntry *pIndex, int64_t NumBlocks, int3
// Already present in table?
if(pHashTable[hash] != 0)
{
- //TRACE1("Another hash entry for %d found\n", hash);
+ //BOX_TRACE("Another hash entry for " << hash << " found");
// Yes -- need to set the pointer in this entry to the current entry to build the linked list
pIndex[b].mpNextInHashList = pHashTable[hash];
}
@@ -840,17 +842,19 @@ static bool SecondStageMatch(BlocksAvailableEntry *pFirstInHashList, RollingChec
// Then go through the entries in the hash list, comparing with the strong digest calculated
scan = pFirstInHashList;
- //TRACE0("second stage match\n");
+ //BOX_TRACE("second stage match");
while(scan != 0)
{
- //TRACE3("scan size %d, block size %d, hash %d\n", scan->mSize, BlockSize, Hash);
+ //BOX_TRACE("scan size " << scan->mSize <<
+ // ", block size " << BlockSize <<
+ // ", hash " << Hash);
ASSERT(scan->mSize == BlockSize);
ASSERT(RollingChecksum::ExtractHashingComponent(scan->mWeakChecksum) == DEBUG_Hash);
// Compare?
if(strong.DigestMatches(scan->mStrongChecksum))
{
- //TRACE0("Match!\n");
+ //BOX_TRACE("Match!\n");
// Found! Add to list of found blocks...
int64_t fileOffset = (FileBlockNumber * BlockSize) + Offset;
int64_t blockIndex = (scan - pIndex); // pointer arthmitic is frowned upon. But most efficient way of doing it here -- alternative is to use more memory
@@ -912,7 +916,8 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
#ifndef NDEBUG
if(BackupStoreFile::TraceDetailsOfDiffProcess)
{
- TRACE1("Diff: Default recipe generated, %lld bytes of file\n", SizeOfInputFile);
+ BOX_TRACE("Diff: Default recipe generated, " <<
+ SizeOfInputFile << " bytes of file");
}
#endif
@@ -1005,10 +1010,14 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
// dump out the recipe
#ifndef NDEBUG
- TRACE2("Diff: %lld new bytes found, %lld old blocks used\n", debug_NewBytesFound, debug_OldBlocksUsed);
+ BOX_TRACE("Diff: " <<
+ debug_NewBytesFound << " new bytes found, " <<
+ debug_OldBlocksUsed << " old blocks used");
if(BackupStoreFile::TraceDetailsOfDiffProcess)
{
- TRACE1("Diff: Recipe generated (size %d)\n======== ========= ========\nSpace b4 FirstBlk NumBlks\n", rRecipe.size());
+ BOX_TRACE("Diff: Recipe generated (size " << rRecipe.size());
+ BOX_TRACE("======== ========= ========");
+ BOX_TRACE("Space b4 FirstBlk NumBlks");
{
for(unsigned int e = 0; e < rRecipe.size(); ++e)
{
@@ -1018,10 +1027,15 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
#else
sprintf(b, "%8lld", (int64_t)(rRecipe[e].mpStartBlock - pIndex));
#endif
- TRACE3("%8lld %s %8lld\n", rRecipe[e].mSpaceBefore, (rRecipe[e].mpStartBlock == 0)?" -":b, (int64_t)rRecipe[e].mBlocks);
+ BOX_TRACE(std::setw(8) <<
+ rRecipe[e].mSpaceBefore <<
+ " " <<
+ ((rRecipe[e].mpStartBlock == 0)?" -":b) <<
+ " " << std::setw(8) <<
+ rRecipe[e].mBlocks);
}
}
- TRACE0("======== ========= ========\n");
+ BOX_TRACE("======== ========= ========");
}
#endif
}
diff --git a/lib/backupclient/BackupStoreFilenameClear.cpp b/lib/backupclient/BackupStoreFilenameClear.cpp
index 9114fdd1..cf168bfc 100644
--- a/lib/backupclient/BackupStoreFilenameClear.cpp
+++ b/lib/backupclient/BackupStoreFilenameClear.cpp
@@ -167,7 +167,8 @@ void BackupStoreFilenameClear::MakeClearAvailable() const
switch(encoding)
{
case Encoding_Clear:
- TRACE0("**** BackupStoreFilename encoded with Clear encoding ****\n");
+ BOX_TRACE("**** BackupStoreFilename encoded with "
+ "Clear encoding ****");
mClearFilename.assign(c_str() + 2, size - 2);
break;
@@ -193,7 +194,8 @@ static void EnsureEncDecBufferSize(int BufSize)
if(spEncDecBuffer == 0)
{
#ifndef WIN32
- TRACE1("Allocating filename encoding/decoding buffer with size %d\n", BufSize);
+ BOX_TRACE("Allocating filename encoding/decoding buffer "
+ "with size " << BufSize);
#endif
spEncDecBuffer = new MemoryBlockGuard<uint8_t *>(BufSize);
MEMLEAKFINDER_NOT_A_LEAK(spEncDecBuffer);
diff --git a/lib/backupclient/BackupStoreObjectDump.cpp b/lib/backupclient/BackupStoreObjectDump.cpp
index d3d9cc17..0ad044bb 100644
--- a/lib/backupclient/BackupStoreObjectDump.cpp
+++ b/lib/backupclient/BackupStoreObjectDump.cpp
@@ -47,7 +47,7 @@ static void OutputLine(FILE *file, bool ToTrace, const char *format, ...)
}
if(ToTrace)
{
- TRACE1("%s", text);
+ BOX_TRACE(text);
}
}
@@ -211,14 +211,16 @@ void BackupStoreFile::DumpFile(void *clibFileHandle, bool ToTrace, IOStream &rFi
if(s > 0)
{
nnew++;
- TRACE2("%8lld this s=%8lld\n", b, s);
+ BOX_TRACE(std::setw(8) << b << " this s=" <<
+ std::setw(8) << s);
}
else
{
nold++;
- TRACE2("%8lld other i=%8lld\n", b, 0 - s);
+ BOX_TRACE(std::setw(8) << b << " other i=" <<
+ std::setw(8) << 0 - s);
}
}
- TRACE0("======== ===== ==========\n");
+ BOX_TRACE("======== ===== ==========");
}