summaryrefslogtreecommitdiff
path: root/bin
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 /bin
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 'bin')
-rw-r--r--bin/bbackupd/BackupClientContext.cpp9
-rw-r--r--bin/bbackupd/BackupClientContext.h2
-rw-r--r--bin/bbackupd/BackupClientDirectoryRecord.cpp7
-rw-r--r--bin/bbackupd/BackupDaemon.cpp22
-rw-r--r--bin/bbackupd/Win32ServiceFunctions.cpp6
-rwxr-xr-xbin/bbackupd/bbackupd-config.in2
-rw-r--r--bin/bbackupquery/BackupQueries.cpp41
-rw-r--r--bin/bbackupquery/bbackupquery.cpp8
-rw-r--r--bin/bbstoreaccounts/bbstoreaccounts.cpp56
-rw-r--r--bin/bbstored/BBStoreDHousekeeping.cpp3
-rw-r--r--bin/bbstored/BackupContext.cpp3
-rwxr-xr-xbin/bbstored/bbstored-config.in2
12 files changed, 79 insertions, 82 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp
index 146f7cb8..4b4efd90 100644
--- a/bin/bbackupd/BackupClientContext.cpp
+++ b/bin/bbackupd/BackupClientContext.cpp
@@ -44,7 +44,6 @@ BackupClientContext::BackupClientContext
BackupDaemon &rDaemon,
TLSContext &rTLSContext,
const std::string &rHostname,
- int Port,
int32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
@@ -53,7 +52,6 @@ BackupClientContext::BackupClientContext
: mrDaemon(rDaemon),
mrTLSContext(rTLSContext),
mHostname(rHostname),
- mPort(Port),
mAccountNumber(AccountNumber),
mpSocket(0),
mpConnection(0),
@@ -131,8 +129,7 @@ BackupProtocolClient &BackupClientContext::GetConnection()
mHostname << "'...");
// Connect!
- mpSocket->Open(mrTLSContext, Socket::TypeINET,
- mHostname.c_str(), mPort);
+ mpSocket->Open(mrTLSContext, Socket::TypeINET, mHostname.c_str(), BOX_PORT_BBSTORED);
// And create a procotol object
mpConnection = new BackupProtocolClient(*mpSocket);
@@ -149,8 +146,8 @@ BackupProtocolClient &BackupClientContext::GetConnection()
if (!mpExtendedLogFileHandle)
{
- BOX_LOG_SYS_ERROR("Failed to open extended "
- "log file: " << mExtendedLogFile);
+ BOX_ERROR("Failed to open extended log "
+ "file: " << strerror(errno));
}
else
{
diff --git a/bin/bbackupd/BackupClientContext.h b/bin/bbackupd/BackupClientContext.h
index 1504cc72..152d8556 100644
--- a/bin/bbackupd/BackupClientContext.h
+++ b/bin/bbackupd/BackupClientContext.h
@@ -41,7 +41,6 @@ public:
BackupDaemon &rDaemon,
TLSContext &rTLSContext,
const std::string &rHostname,
- int32_t Port,
int32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
@@ -202,7 +201,6 @@ private:
BackupDaemon &mrDaemon;
TLSContext &mrTLSContext;
std::string mHostname;
- int mPort;
int32_t mAccountNumber;
SocketStreamTLS *mpSocket;
BackupProtocolClient *mpConnection;
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp
index 47094af3..0a0703c2 100644
--- a/bin/bbackupd/BackupClientDirectoryRecord.cpp
+++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp
@@ -1014,8 +1014,7 @@ bool BackupClientDirectoryRecord::UpdateItems(BackupClientDirectoryRecord::SyncP
// Delete the pending entries, if the map is entry
if(mpPendingEntries != 0 && mpPendingEntries->size() == 0)
{
- BOX_TRACE("Deleting mpPendingEntries from dir ID " <<
- BOX_FORMAT_OBJECTID(mObjectID));
+ TRACE1("Deleting mpPendingEntries from dir ID %lld\n", mObjectID);
delete mpPendingEntries;
mpPendingEntries = 0;
}
@@ -1250,8 +1249,8 @@ bool BackupClientDirectoryRecord::UpdateItems(BackupClientDirectoryRecord::SyncP
rLocalPath,
dirname.GetClearFilename());
- BOX_TRACE("Deleted directory record "
- "for " << name);
+ TRACE1("Deleted directory record for "
+ "%s\n", name.c_str());
}
}
}
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index b1dc4832..059cda38 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -958,7 +958,6 @@ void BackupDaemon::Run2()
*this,
tlsContext,
conf.GetKeyValue("StoreHostname"),
- conf.GetKeyValueInt("StorePort"),
conf.GetKeyValueInt("AccountNumber"),
conf.GetKeyValueBool("ExtendedLogging"),
conf.KeyExists("ExtendedLogFile"),
@@ -1813,9 +1812,10 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
if(::statfs(apLoc->mPath.c_str(), &s) != 0)
#endif // HAVE_STRUCT_STATVFS_F_MNTONNAME
{
- BOX_LOG_SYS_WARNING("Failed to stat location "
+ BOX_WARNING("Failed to stat location "
"path '" << apLoc->mPath <<
- "', skipping location '" <<
+ "' (" << strerror(errno) <<
+ "), skipping location '" <<
apLoc->mName << "'");
continue;
}
@@ -2189,8 +2189,9 @@ void BackupDaemon::CommitIDMapsAfterSync()
#endif
if(::rename(newmap.c_str(), target.c_str()) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to rename ID map: " <<
- newmap << " to " << target);
+ BOX_ERROR("failed to rename ID map: " << newmap
+ << " to " << target << ": "
+ << strerror(errno));
THROW_EXCEPTION(CommonException, OSFileError)
}
}
@@ -3054,10 +3055,9 @@ bool BackupDaemon::DeleteStoreObjectInfo() const
// Check to see if the file exists
if(!FileExists(storeObjectInfoFile.c_str()))
{
- // File doesn't exist -- so can't be deleted. But something
- // isn't quite right, so log a message
- BOX_WARNING("StoreObjectInfoFile did not exist when it "
- "was supposed to: " << storeObjectInfoFile);
+ // File doesn't exist -- so can't be deleted. But something isn't quite right, so log a message
+ BOX_WARNING("Store object info file did not exist when it "
+ "was supposed to. (" << storeObjectInfoFile << ")");
// Return true to stop things going around in a loop
return true;
@@ -3066,8 +3066,8 @@ bool BackupDaemon::DeleteStoreObjectInfo() const
// Actually delete it
if(::unlink(storeObjectInfoFile.c_str()) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to delete the old "
- "StoreObjectInfoFile: " << storeObjectInfoFile);
+ BOX_ERROR("Failed to delete the old store object info file: "
+ << storeObjectInfoFile << ": "<< strerror(errno));
return false;
}
diff --git a/bin/bbackupd/Win32ServiceFunctions.cpp b/bin/bbackupd/Win32ServiceFunctions.cpp
index 53be3bc7..a7bf6bd9 100644
--- a/bin/bbackupd/Win32ServiceFunctions.cpp
+++ b/bin/bbackupd/Win32ServiceFunctions.cpp
@@ -207,8 +207,8 @@ int InstallService(const char* pConfigFileName, const std::string& rServiceName)
if (emu_stat(pConfigFileName, &st) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to open configuration file "
- "'" << pConfigFileName << "'");
+ BOX_ERROR("Failed to open configuration file '" <<
+ pConfigFileName << "': " << strerror(errno));
return 1;
}
@@ -221,7 +221,7 @@ int InstallService(const char* pConfigFileName, const std::string& rServiceName)
}
}
- SC_HANDLE scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
+ SC_HANDLE scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
if (!scm)
{
diff --git a/bin/bbackupd/bbackupd-config.in b/bin/bbackupd/bbackupd-config.in
index 925dcc3e..ee6a745d 100755
--- a/bin/bbackupd/bbackupd-config.in
+++ b/bin/bbackupd/bbackupd-config.in
@@ -26,7 +26,7 @@ Parameters:
explicitly, using bbackupctl sync
account-num (hexdecimal) and server-hostname
are supplied by the server administrator
- working-dir is usually @localstatedir_expanded@/bbackupd
+ working-dir is usually @localstatedir_expanded@
backup directories is list of directories to back up
__E
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index 0faa4770..b6984641 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -27,8 +27,6 @@
#include <set>
#include <limits>
-#include <iostream>
-#include <ostream>
#include "BackupQueries.h"
#include "Utils.h"
@@ -812,8 +810,8 @@ void BackupQueries::CommandChangeLocalDir(const std::vector<std::string> &args)
}
else
{
- BOX_LOG_SYS_ERROR("Failed to change to directory "
- "'" << args[0] << "'");
+ BOX_ERROR("Error changing to directory '" <<
+ args[0] << ": " << strerror(errno));
}
SetReturnCode(COMMAND_RETURN_ERROR);
@@ -824,7 +822,8 @@ void BackupQueries::CommandChangeLocalDir(const std::vector<std::string> &args)
char wd[PATH_MAX];
if(::getcwd(wd, PATH_MAX) == 0)
{
- BOX_LOG_SYS_ERROR("Error getting current directory");
+ BOX_ERROR("Error getting current directory: " <<
+ strerror(errno));
SetReturnCode(COMMAND_RETURN_ERROR);
return;
}
@@ -1400,8 +1399,9 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
}
else
{
- BOX_LOG_SYS_WARNING("Failed to access local directory "
- "'" << localDirDisplay << "'");
+ BOX_WARNING("Failed to access local directory '" <<
+ localDirDisplay << ": " << strerror(errno) <<
+ "'.");
rParams.mUncheckedFiles ++;
}
return;
@@ -1449,8 +1449,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
DIR *dirhandle = ::opendir(rLocalDir.c_str());
if(dirhandle == 0)
{
- BOX_LOG_SYS_WARNING("Failed to open local directory '" <<
- localDirDisplay << "'");
+ BOX_WARNING("Failed to open local directory '" <<
+ localDirDisplay << "': " << strerror(errno));
rParams.mUncheckedFiles ++;
return;
}
@@ -1518,8 +1518,8 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
// Close directory
if(::closedir(dirhandle) != 0)
{
- BOX_LOG_SYS_ERROR("Failed to close local directory "
- "'" << localDirDisplay << "'");
+ BOX_ERROR("Failed to close local directory '" <<
+ localDirDisplay << "': " << strerror(errno));
}
dirhandle = 0;
@@ -2158,9 +2158,22 @@ void BackupQueries::CommandUsage()
// --------------------------------------------------------------------------
void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize)
{
- std::cout << FormatUsageLineStart(Name) <<
- FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize) <<
- std::endl;
+ // Calculate size in Mb
+ double mb = (((double)Size) * ((double)BlockSize)) / ((double)(1024*1024));
+ int64_t percent = (Size * 100) / HardLimit;
+
+ // Bar graph
+ char bar[41];
+ unsigned int b = (int)((Size * (sizeof(bar)-1)) / HardLimit);
+ if(b > sizeof(bar)-1) {b = sizeof(bar)-1;}
+ for(unsigned int l = 0; l < b; l++)
+ {
+ bar[l] = '*';
+ }
+ bar[b] = '\0';
+
+ // Print the entryj
+ ::printf("%14s %10.1fMb %3d%% %s\n", Name, mb, (int32_t)percent, bar);
}
diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp
index b38821c1..4b97409f 100644
--- a/bin/bbackupquery/bbackupquery.cpp
+++ b/bin/bbackupquery/bbackupquery.cpp
@@ -174,8 +174,8 @@ int main(int argc, const char *argv[])
logFile = ::fopen(optarg, "w");
if(logFile == 0)
{
- BOX_LOG_SYS_ERROR("Failed to open log file "
- "'" << optarg << "'");
+ BOX_ERROR("Failed to open log file '" <<
+ optarg << "': " << strerror(errno));
}
break;
@@ -260,9 +260,7 @@ int main(int argc, const char *argv[])
// 2. Connect to server
if(!quiet) BOX_INFO("Connecting to store...");
SocketStreamTLS socket;
- socket.Open(tlsContext, Socket::TypeINET,
- conf.GetKeyValue("StoreHostname").c_str(),
- conf.GetKeyValueInt("StorePort"));
+ socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED);
// 3. Make a protocol, and handshake
if(!quiet) BOX_INFO("Handshake with store...");
diff --git a/bin/bbstoreaccounts/bbstoreaccounts.cpp b/bin/bbstoreaccounts/bbstoreaccounts.cpp
index d1740d81..6f079d30 100644
--- a/bin/bbstoreaccounts/bbstoreaccounts.cpp
+++ b/bin/bbstoreaccounts/bbstoreaccounts.cpp
@@ -13,11 +13,8 @@
#include <stdio.h>
#include <sys/types.h>
#include <limits.h>
-
-#include <algorithm>
-#include <iostream>
-#include <ostream>
#include <vector>
+#include <algorithm>
#include "BoxPortsAndFiles.h"
#include "BackupStoreConfigVerify.h"
@@ -65,10 +62,22 @@ int BlockSizeOfDiscSet(int DiscSet)
return controller.GetDiscSet(DiscSet).GetBlockSize();
}
-std::string BlockSizeToString(int64_t Blocks, int64_t MaxBlocks, int DiscSet)
+const char *BlockSizeToString(int64_t Blocks, int DiscSet)
{
- return FormatUsageBar(Blocks, Blocks * BlockSizeOfDiscSet(DiscSet),
- MaxBlocks * BlockSizeOfDiscSet(DiscSet));
+ // Not reentrant, nor can be used in the same function call twice, etc.
+ static char string[256];
+
+ // Work out size in Mb.
+ double mb = (Blocks * BlockSizeOfDiscSet(DiscSet)) / (1024.0*1024.0);
+
+ // Format string
+#ifdef WIN32
+ sprintf(string, "%I64d (%.2fMb)", Blocks, mb);
+#else
+ sprintf(string, "%lld (%.2fMb)", Blocks, mb);
+#endif
+
+ return string;
}
int64_t SizeStringToBlocks(const char *string, int DiscSet)
@@ -220,30 +229,15 @@ int AccountInfo(Configuration &rConfig, int32_t ID)
std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, rootDir, discSet, true /* ReadOnly */));
// Then print out lots of info
- std::cout << FormatUsageLineStart("Account ID") <<
- BOX_FORMAT_ACCOUNT(ID) << std::endl;
- std::cout << FormatUsageLineStart("Last object ID") <<
- BOX_FORMAT_OBJECTID(info->GetLastObjectIDUsed()) << std::endl;
- std::cout << FormatUsageLineStart("Used") <<
- BlockSizeToString(info->GetBlocksUsed(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Old files") <<
- BlockSizeToString(info->GetBlocksInOldFiles(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Deleted files") <<
- BlockSizeToString(info->GetBlocksInDeletedFiles(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Directories") <<
- BlockSizeToString(info->GetBlocksInDirectories(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Soft limit") <<
- BlockSizeToString(info->GetBlocksSoftLimit(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Hard limit") <<
- BlockSizeToString(info->GetBlocksHardLimit(),
- info->GetBlocksHardLimit(), discSet) << std::endl;
- std::cout << FormatUsageLineStart("Client store marker") <<
- info->GetLastObjectIDUsed() << std::endl;
+ printf(" Account ID: %08x\n", ID);
+ printf(" Last object ID: %lld\n", info->GetLastObjectIDUsed());
+ printf(" Blocks used: %s\n", BlockSizeToString(info->GetBlocksUsed(), discSet));
+ printf(" Blocks used by old files: %s\n", BlockSizeToString(info->GetBlocksInOldFiles(), discSet));
+ printf("Blocks used by deleted files: %s\n", BlockSizeToString(info->GetBlocksInDeletedFiles(), discSet));
+ printf(" Blocks used by directories: %s\n", BlockSizeToString(info->GetBlocksInDirectories(), discSet));
+ printf(" Block soft limit: %s\n", BlockSizeToString(info->GetBlocksSoftLimit(), discSet));
+ printf(" Block hard limit: %s\n", BlockSizeToString(info->GetBlocksHardLimit(), discSet));
+ printf(" Client store marker: %lld\n", info->GetClientStoreMarker());
return 0;
}
diff --git a/bin/bbstored/BBStoreDHousekeeping.cpp b/bin/bbstored/BBStoreDHousekeeping.cpp
index 4694c0bb..16a1432a 100644
--- a/bin/bbstored/BBStoreDHousekeeping.cpp
+++ b/bin/bbstored/BBStoreDHousekeeping.cpp
@@ -193,8 +193,7 @@ bool BackupStoreDaemon::CheckForInterProcessMsg(int AccountNum, int MaximumWaitT
std::string line;
if(mInterProcessComms.GetLine(line, false /* no pre-processing */, MaximumWaitTime))
{
- BOX_TRACE("Housekeeping received command '" << line <<
- "' over interprocess comms");
+ TRACE1("Housekeeping received command '%s' over interprocess comms\n", line.c_str());
int account = 0;
diff --git a/bin/bbstored/BackupContext.cpp b/bin/bbstored/BackupContext.cpp
index af1c9475..f956b1a8 100644
--- a/bin/bbstored/BackupContext.cpp
+++ b/bin/bbstored/BackupContext.cpp
@@ -382,8 +382,7 @@ int64_t BackupContext::AllocateObjectID()
// Mark that the store info should be saved as soon as possible
mSaveStoreInfoDelay = 0;
- BOX_WARNING("When allocating object ID, found that " <<
- BOX_FORMAT_OBJECTID(id) << " is already in use");
+ TRACE1("When allocating object ID, found that %lld is already in use\n", id);
}
THROW_EXCEPTION(BackupStoreException, CouldNotFindUnusedIDDuringAllocation)
diff --git a/bin/bbstored/bbstored-config.in b/bin/bbstored/bbstored-config.in
index 5ad96d50..57fa50c6 100755
--- a/bin/bbstored/bbstored-config.in
+++ b/bin/bbstored/bbstored-config.in
@@ -196,7 +196,7 @@ TimeBetweenHousekeeping = 900
Server
{
- PidFile = @localstatedir_expanded@/run/bbstored.pid
+ PidFile = @localstatedir_expanded@/bbstored.pid
User = $username
ListenAddresses = inet:$server
CertificateFile = $certificate