summaryrefslogtreecommitdiff
path: root/lib/backupclient
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-04-04 21:59:29 +0000
committerChris Wilson <chris+github@qwirx.com>2008-04-04 21:59:29 +0000
commit3661f3624acc46590d5504fda4f8714255fb2c8e (patch)
treee2cd17e19718d3f46944979a23e4c93dcf92584b /lib/backupclient
parent2f8d0c29536cdb306b525b78638727da4ead0022 (diff)
Tailorization
Import of the upstream sources from Repository: http://localhost:8000/ Kind: hg Revision: 7807b7768163f1c2537756abe5416063989cebb1 Original author: tailor@rocio.int.aidworld.org Date: 2008-03-16 19:44:36+00:00
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, 70 insertions, 107 deletions
diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp
index aab514ad..b5a54964 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_LOG_SYS_ERROR("Failed to delete "
- "file '" <<
- rLocalDirectoryName << "'");
+ BOX_ERROR("Failed to delete file " <<
+ rLocalDirectoryName << ": " <<
+ strerror(errno));
return Restore_UnknownError;
}
BOX_TRACE("In restore, directory name "
- "collision with file '" <<
- rLocalDirectoryName << "'");
+ "collision with file " <<
+ rLocalDirectoryName);
}
break;
case ObjectExists_NoObject:
@@ -378,8 +378,9 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
exists == ObjectExists_File) &&
::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to create directory '" <<
- rLocalDirectoryName << "'");
+ BOX_ERROR("Failed to create directory '" <<
+ rLocalDirectoryName << "': " <<
+ strerror(errno));
return Restore_UnknownError;
}
@@ -450,9 +451,7 @@ 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
@@ -460,23 +459,20 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
if(ObjectExists(localFilename) != ObjectExists_NoObject &&
::unlink(localFilename.c_str()) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to delete "
- "file '" << localFilename <<
- "'");
+ BOX_ERROR("Failed to delete file '" <<
+ localFilename << "': " <<
+ strerror(errno));
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 db1de4fa..61033b5b 100644
--- a/lib/backupclient/BackupDaemonConfigVerify.cpp
+++ b/lib/backupclient/BackupDaemonConfigVerify.cpp
@@ -17,15 +17,15 @@
static const ConfigurationVerifyKey backuplocationkeys[] =
{
- 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)
+ {"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}
};
static const ConfigurationVerify backuplocations[] =
@@ -64,54 +64,39 @@ static const ConfigurationVerify verifyserver[] =
static const ConfigurationVerifyKey verifyrootkeys[] =
{
- 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),
+ {"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("SyncAllowScript", 0),
- // script that returns "now" if backup is allowed now, or a number
- // of seconds to wait before trying again if not
+ {"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("MaximumDiffingTime", ConfigTest_IsInt),
- ConfigurationVerifyKey("DeleteRedundantLocationsAfter",
- ConfigTest_IsInt, 172800),
+ {"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("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
+ {"CommandSocket", 0, 0, 0}, // not compulsory to have this
+ {"KeepAliveTime", 0, ConfigTest_IsInt, 0}, // optional
+ {"StoreObjectInfoFile", 0, 0, 0}, // optional
- ConfigurationVerifyKey("NotifyScript", 0),
- // optional script to run when backup needs attention, eg store full
+ {"NotifyScript", 0, 0, 0}, // optional script to run when backup needs attention, eg store full
- ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
- ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
- ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists),
- ConfigurationVerifyKey("KeysFile", ConfigTest_Exists),
- ConfigurationVerifyKey("DataDirectory",
- ConfigTest_Exists | ConfigTest_LastEntry),
+ {"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}
};
const ConfigurationVerify BackupDaemonConfigVerify =
diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp
index d550e2ba..f7842a0b 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);
- // BOX_TRACE("Diff: Blocks in index: " << blocksInIndex);
+ //TRACE1("Diff: Blocks in index: %lld\n", blocksInIndex);
if(!canDiffFromThis)
{
@@ -439,9 +439,7 @@ static void FindMostUsedSizes(BlocksAvailableEntry *pIndex, int64_t NumBlocks, i
{
for(int t = 0; t < BACKUP_FILE_DIFF_MAX_BLOCK_SIZES; ++t)
{
- BOX_TRACE("Diff block size " << t << ": " <<
- Sizes[t] << " (count = " <<
- sizeCounts[t] << ")");
+ TRACE3("Diff block size %d: %d (count = %lld)\n", t, Sizes[t], sizeCounts[t]);
}
}
#endif
@@ -776,7 +774,7 @@ static void SetupHashTable(BlocksAvailableEntry *pIndex, int64_t NumBlocks, int3
// Already present in table?
if(pHashTable[hash] != 0)
{
- //BOX_TRACE("Another hash entry for " << hash << " found");
+ //TRACE1("Another hash entry for %d found\n", hash);
// Yes -- need to set the pointer in this entry to the current entry to build the linked list
pIndex[b].mpNextInHashList = pHashTable[hash];
}
@@ -842,19 +840,17 @@ static bool SecondStageMatch(BlocksAvailableEntry *pFirstInHashList, RollingChec
// Then go through the entries in the hash list, comparing with the strong digest calculated
scan = pFirstInHashList;
- //BOX_TRACE("second stage match");
+ //TRACE0("second stage match\n");
while(scan != 0)
{
- //BOX_TRACE("scan size " << scan->mSize <<
- // ", block size " << BlockSize <<
- // ", hash " << Hash);
+ //TRACE3("scan size %d, block size %d, hash %d\n", scan->mSize, BlockSize, Hash);
ASSERT(scan->mSize == BlockSize);
ASSERT(RollingChecksum::ExtractHashingComponent(scan->mWeakChecksum) == DEBUG_Hash);
// Compare?
if(strong.DigestMatches(scan->mStrongChecksum))
{
- //BOX_TRACE("Match!\n");
+ //TRACE0("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
@@ -916,8 +912,7 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
#ifndef NDEBUG
if(BackupStoreFile::TraceDetailsOfDiffProcess)
{
- BOX_TRACE("Diff: Default recipe generated, " <<
- SizeOfInputFile << " bytes of file");
+ TRACE1("Diff: Default recipe generated, %lld bytes of file\n", SizeOfInputFile);
}
#endif
@@ -1010,14 +1005,10 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
// dump out the recipe
#ifndef NDEBUG
- BOX_TRACE("Diff: " <<
- debug_NewBytesFound << " new bytes found, " <<
- debug_OldBlocksUsed << " old blocks used");
+ TRACE2("Diff: %lld new bytes found, %lld old blocks used\n", debug_NewBytesFound, debug_OldBlocksUsed);
if(BackupStoreFile::TraceDetailsOfDiffProcess)
{
- BOX_TRACE("Diff: Recipe generated (size " << rRecipe.size());
- BOX_TRACE("======== ========= ========");
- BOX_TRACE("Space b4 FirstBlk NumBlks");
+ TRACE1("Diff: Recipe generated (size %d)\n======== ========= ========\nSpace b4 FirstBlk NumBlks\n", rRecipe.size());
{
for(unsigned int e = 0; e < rRecipe.size(); ++e)
{
@@ -1027,15 +1018,10 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA
#else
sprintf(b, "%8lld", (int64_t)(rRecipe[e].mpStartBlock - pIndex));
#endif
- BOX_TRACE(std::setw(8) <<
- rRecipe[e].mSpaceBefore <<
- " " <<
- ((rRecipe[e].mpStartBlock == 0)?" -":b) <<
- " " << std::setw(8) <<
- rRecipe[e].mBlocks);
+ TRACE3("%8lld %s %8lld\n", rRecipe[e].mSpaceBefore, (rRecipe[e].mpStartBlock == 0)?" -":b, (int64_t)rRecipe[e].mBlocks);
}
}
- BOX_TRACE("======== ========= ========");
+ TRACE0("======== ========= ========\n");
}
#endif
}
diff --git a/lib/backupclient/BackupStoreFilenameClear.cpp b/lib/backupclient/BackupStoreFilenameClear.cpp
index cf168bfc..9114fdd1 100644
--- a/lib/backupclient/BackupStoreFilenameClear.cpp
+++ b/lib/backupclient/BackupStoreFilenameClear.cpp
@@ -167,8 +167,7 @@ void BackupStoreFilenameClear::MakeClearAvailable() const
switch(encoding)
{
case Encoding_Clear:
- BOX_TRACE("**** BackupStoreFilename encoded with "
- "Clear encoding ****");
+ TRACE0("**** BackupStoreFilename encoded with Clear encoding ****\n");
mClearFilename.assign(c_str() + 2, size - 2);
break;
@@ -194,8 +193,7 @@ static void EnsureEncDecBufferSize(int BufSize)
if(spEncDecBuffer == 0)
{
#ifndef WIN32
- BOX_TRACE("Allocating filename encoding/decoding buffer "
- "with size " << BufSize);
+ TRACE1("Allocating filename encoding/decoding buffer with size %d\n", 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 0ad044bb..d3d9cc17 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)
{
- BOX_TRACE(text);
+ TRACE1("%s", text);
}
}
@@ -211,16 +211,14 @@ void BackupStoreFile::DumpFile(void *clibFileHandle, bool ToTrace, IOStream &rFi
if(s > 0)
{
nnew++;
- BOX_TRACE(std::setw(8) << b << " this s=" <<
- std::setw(8) << s);
+ TRACE2("%8lld this s=%8lld\n", b, s);
}
else
{
nold++;
- BOX_TRACE(std::setw(8) << b << " other i=" <<
- std::setw(8) << 0 - s);
+ TRACE2("%8lld other i=%8lld\n", b, 0 - s);
}
}
- BOX_TRACE("======== ===== ==========");
+ TRACE0("======== ===== ==========\n");
}