summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2011-06-16 15:45:26 +0000
committerChris Wilson <chris+github@qwirx.com>2011-06-16 15:45:26 +0000
commit8ad29b4e5ded759dd93932d35229d2858d14839c (patch)
treea6757875d31e10fe860b837771b471de5d887cf7 /lib
parent613c2e58676ff19d8ecf86df753b987a9eefdb26 (diff)
Improve error logging for store info and refcount database errors.
Diffstat (limited to 'lib')
-rw-r--r--lib/backupstore/BackupStoreInfo.cpp15
-rw-r--r--lib/backupstore/BackupStoreRefCountDatabase.cpp28
2 files changed, 27 insertions, 16 deletions
diff --git a/lib/backupstore/BackupStoreInfo.cpp b/lib/backupstore/BackupStoreInfo.cpp
index cc4d2b35..6c7a3758 100644
--- a/lib/backupstore/BackupStoreInfo.cpp
+++ b/lib/backupstore/BackupStoreInfo.cpp
@@ -141,7 +141,9 @@ void BackupStoreInfo::CreateNew(int32_t AccountID, const std::string &rRootDir,
// Created: 2003/08/28
//
// --------------------------------------------------------------------------
-std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const std::string &rRootDir, int DiscSet, bool ReadOnly, int64_t *pRevisionID)
+std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID,
+ const std::string &rRootDir, int DiscSet, bool ReadOnly,
+ int64_t *pRevisionID)
{
// Generate the filename
std::string fn(rRootDir + INFO_FILENAME);
@@ -153,7 +155,9 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const st
int32_t magic;
if(!rf->ReadFullBuffer(&magic, sizeof(magic), 0))
{
- THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo);
+ THROW_FILE_ERROR("Failed to read store info file: "
+ "short read of magic number", fn,
+ BackupStoreException, CouldNotLoadStoreInfo);
}
bool v1 = false, v2 = false;
@@ -168,7 +172,9 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const st
}
else
{
- THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad)
+ THROW_FILE_ERROR("Failed to read store info file: "
+ "unknown magic " << BOX_FORMAT_HEX32(ntohl(magic)),
+ fn, BackupStoreException, BadStoreInfoOnLoad);
}
// Make new object
@@ -223,7 +229,8 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const st
archive.Read(FileAccountID);
if (FileAccountID != AccountID)
{
- THROW_FILE_ERROR("Found wrong account ID in store info",
+ THROW_FILE_ERROR("Found wrong account ID in store "
+ "info: " << BOX_FORMAT_HEX32(FileAccountID),
fn, BackupStoreException, BadStoreInfoOnLoad);
}
diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp
index 9c934335..4bf6f557 100644
--- a/lib/backupstore/BackupStoreRefCountDatabase.cpp
+++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp
@@ -91,9 +91,9 @@ void BackupStoreRefCountDatabase::Create(const
// Open the file for writing
if (FileExists(Filename) && !AllowOverwrite)
{
- BOX_ERROR("Attempted to overwrite refcount database file: " <<
- Filename);
- THROW_EXCEPTION(RaidFileException, CannotOverwriteExistingFile);
+ THROW_FILE_ERROR("Failed to overwrite refcount database: "
+ "not allowed here", Filename, RaidFileException,
+ CannotOverwriteExistingFile);
}
int flags = O_CREAT | O_BINARY | O_RDWR;
@@ -134,14 +134,18 @@ std::auto_ptr<BackupStoreRefCountDatabase> BackupStoreRefCountDatabase::Load(
refcount_StreamFormat hdr;
if(!dbfile->ReadFullBuffer(&hdr, sizeof(hdr), 0 /* not interested in bytes read if this fails */))
{
- THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo)
+ THROW_FILE_ERROR("Failed to read refcount database: "
+ "short read", filename, BackupStoreException,
+ CouldNotLoadStoreInfo);
}
// Check it
if(ntohl(hdr.mMagicValue) != REFCOUNT_MAGIC_VALUE ||
(int32_t)ntohl(hdr.mAccountID) != rAccount.GetID())
{
- THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad)
+ THROW_FILE_ERROR("Failed to read refcount database: "
+ "bad magic number", filename, BackupStoreException,
+ BadStoreInfoOnLoad);
}
// Make new object
@@ -255,10 +259,10 @@ BackupStoreRefCountDatabase::GetRefCount(int64_t ObjectID) const
if (GetSize() < offset + GetEntrySize())
{
- BOX_ERROR("attempted read of unknown refcount for object " <<
- BOX_FORMAT_OBJECTID(ObjectID));
- THROW_EXCEPTION(BackupStoreException,
- UnknownObjectRefCountRequested);
+ THROW_FILE_ERROR("Failed to read refcount database: "
+ "attempted read of unknown refcount for object " <<
+ BOX_FORMAT_OBJECTID(ObjectID), mFilename,
+ BackupStoreException, UnknownObjectRefCountRequested);
}
mapDatabaseFile->Seek(offset, SEEK_SET);
@@ -267,9 +271,9 @@ BackupStoreRefCountDatabase::GetRefCount(int64_t ObjectID) const
if (mapDatabaseFile->Read(&refcount, sizeof(refcount)) !=
sizeof(refcount))
{
- BOX_LOG_SYS_ERROR("short read on refcount database: " <<
- mFilename);
- THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo);
+ THROW_FILE_ERROR("Failed to read refcount database: "
+ "short read at offset " << offset, mFilename,
+ BackupStoreException, CouldNotLoadStoreInfo);
}
return ntohl(refcount);