[Box Backup-commit] COMMIT r1022 - box/chris/merge/bin/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Oct 14 15:07:37 BST 2006


Author: chris
Date: 2006-10-14 15:07:37 +0100 (Sat, 14 Oct 2006)
New Revision: 1022

Modified:
   box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp
Log:
 * Use readdir's d_type field to determine type of directory entry without
   statting the entry, which allows users to exclude unreadable entries to
   suppress warnings about them on Win32 (refs #3)


Modified: box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp	2006-10-14 14:05:31 UTC (rev 1021)
+++ box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp	2006-10-14 14:07:37 UTC (rev 1022)
@@ -236,6 +236,18 @@
 				// Stat file to get info
 				filename = MakeFullPath(rLocalPath, en->d_name);
 
+				#ifdef WIN32
+				// Don't stat the file just yet, to ensure
+				// that users can exclude unreadable files
+				// to suppress warnings that they are
+				// not accessible.
+				//
+				// Our emulated readdir() abuses en->d_type, 
+				// which would normally contain DT_REG, 
+				// DT_DIR, etc, but we only use it here and 
+				// prefer S_IFREG, S_IFDIR...
+				int type = en->d_type;
+				#else
 				if(::lstat(filename.c_str(), &st) != 0)
 				{
 					// Report the error (logs and 
@@ -248,6 +260,8 @@
 				}
 
 				int type = st.st_mode & S_IFMT;
+				#endif
+
 				if(type == S_IFREG || type == S_IFLNK)
 				{
 					// File or symbolic link
@@ -278,11 +292,34 @@
 				}
 				else
 				{
+					#ifdef WIN32
+					::syslog(LOG_ERR, "Unknown file type: "
+						"%d (%s)", type, 
+						filename.c_str());
+					#endif
+					SetErrorWhenReadingFilesystemObject(
+						rParams, filename.c_str());
 					continue;
 				}
 				
 				// Here if the object is something to back up (file, symlink or dir, not excluded)
 				// So make the information for adding to the checksum
+				
+				#ifdef WIN32
+				// We didn't stat the file before,
+				// but now we need the information.
+				if(::lstat(filename.c_str(), &st) != 0)
+				{
+					// Report the error (logs and 
+					// eventual email to administrator)
+					SetErrorWhenReadingFilesystemObject(
+						rParams, filename.c_str());
+
+					// Ignore this entry for now.
+					continue;
+				}
+				#endif
+
 				checksum_info.mModificationTime = FileModificationTime(st);
 				checksum_info.mAttributeModificationTime = FileAttrModificationTime(st);
 				checksum_info.mSize = st.st_size;




More information about the Boxbackup-commit mailing list