[Box Backup-commit] COMMIT r2359 - box/trunk/lib/backupclient
boxbackup-dev at boxbackup.org
boxbackup-dev at boxbackup.org
Tue Oct 21 21:25:33 BST 2008
Author: chris
Date: 2008-10-21 21:25:33 +0100 (Tue, 21 Oct 2008)
New Revision: 2359
Modified:
box/trunk/lib/backupclient/BackupClientFileAttributes.cpp
Log:
Report the filename that failed when various file attribute syscalls
fail, for example setting, listing or reading extended attributes,
or creating or changing the owner of a symlink. Thanks to Torsten for
noticing that the filename was not reported in these cases.
Modified: box/trunk/lib/backupclient/BackupClientFileAttributes.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupClientFileAttributes.cpp 2008-10-18 13:58:55 UTC (rev 2358)
+++ box/trunk/lib/backupclient/BackupClientFileAttributes.cpp 2008-10-21 20:25:33 UTC (rev 2359)
@@ -304,6 +304,8 @@
struct stat st;
if(::lstat(Filename, &st) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to stat file: '" <<
+ Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
@@ -441,6 +443,7 @@
int linkedToSize = ::readlink(Filename, linkedTo, PATH_MAX);
if(linkedToSize == -1)
{
+ BOX_LOG_SYS_ERROR("Failed to readlink '" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError);
}
@@ -531,6 +534,9 @@
int valueSize = ::lgetxattr(Filename, attrKey.c_str(), 0, 0);
if(valueSize<0)
{
+ BOX_LOG_SYS_ERROR("Failed to get "
+ "extended attributes size "
+ "for '" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError);
}
@@ -546,6 +552,9 @@
valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
if(valueSize<0)
{
+ BOX_LOG_SYS_ERROR("Failed to get "
+ "extended attributes for "
+ "'" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError);
}
xattrSize += valueSize;
@@ -569,15 +578,15 @@
}
else if(errno == ERANGE)
{
- BOX_ERROR("Failed to read extended "
- "attributes of " << Filename <<
- ": buffer too small, not backed up");
+ BOX_ERROR("Failed to list extended "
+ "attributes of '" << Filename << "': "
+ "buffer too small, not backed up");
}
else
{
- BOX_LOG_SYS_ERROR("Failed to read extended "
- "attributes of " << Filename <<
- ", not backed up");
+ BOX_LOG_SYS_ERROR("Failed to list extended "
+ "attributes of '" << Filename << "', "
+ "not backed up");
THROW_EXCEPTION(CommonException, OSFileError);
}
}
@@ -656,6 +665,8 @@
::unlink(Filename);
if(::symlink((char*)(pattr + 1), Filename) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to symlink '" << Filename <<
+ "' to '" << (char*)(pattr + 1) << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
#endif
@@ -673,12 +684,18 @@
// Not a link, use normal chown
if(::chown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to change "
+ "owner of file "
+ "'" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
}
#else
- if(::lchown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0) // use the version which sets things on symlinks
+ // use the version which sets things on symlinks
+ if(::lchown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to change owner of "
+ "symbolic link '" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
#endif
@@ -723,6 +740,8 @@
// Try to apply
if(::utimes(Filename, times) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to change times of "
+ "file '" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
}
@@ -733,8 +752,12 @@
}
// Apply everything else... (allowable mode flags only)
- if(::chmod(Filename, mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)) != 0) // mode must be done last (think setuid)
+ // Mode must be done last (think setuid)
+ if(::chmod(Filename, mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID
+ | S_ISGID | S_ISVTX)) != 0)
{
+ BOX_LOG_SYS_ERROR("Failed to change permissions of file "
+ "'" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError)
}
}
@@ -849,6 +872,8 @@
// FIXME: Warn on EOPNOTSUPP
if(::lsetxattr(Filename, key, buffer+xattrOffset, valueSize, 0)!=0 && errno!=EOPNOTSUPP)
{
+ BOX_LOG_SYS_ERROR("Failed to set extended attributes "
+ "on file '" << Filename << "'");
THROW_EXCEPTION(CommonException, OSFileError);
}
More information about the Boxbackup-commit
mailing list