[Box Backup-commit] COMMIT r987 - box/trunk/lib/raidfile

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Oct 12 21:55:06 BST 2006


Author: chris
Date: 2006-10-12 21:55:06 +0100 (Thu, 12 Oct 2006)
New Revision: 987

Modified:
   box/trunk/lib/raidfile/RaidFileRead.cpp
Log:
 * Don't include headers that we don't have
 * Open RAID files in binary mode


Modified: box/trunk/lib/raidfile/RaidFileRead.cpp
===================================================================
--- box/trunk/lib/raidfile/RaidFileRead.cpp	2006-10-12 20:54:28 UTC (rev 986)
+++ box/trunk/lib/raidfile/RaidFileRead.cpp	2006-10-12 20:55:06 UTC (rev 987)
@@ -14,11 +14,20 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <sys/uio.h>
-#include <syslog.h>
 #include <stdarg.h>
-#include <dirent.h>
 
+#ifdef HAVE_SYS_UIO_H
+	#include <sys/uio.h>
+#endif
+
+#ifdef HAVE_SYSLOG_H
+	#include <syslog.h>
+#endif
+
+#ifdef HAVE_DIRENT_H
+	#include <dirent.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <memory>
@@ -583,7 +592,8 @@
 
 	// Open the parity file
 	std::string parityFilename(RaidFileUtil::MakeRaidComponentName(rdiscSet, mFilename, (2 + startDisc) % READ_NUMBER_DISCS_REQUIRED));
-	mParityHandle = ::open(parityFilename.c_str(), O_RDONLY, 0555);
+	mParityHandle = ::open(parityFilename.c_str(), 
+		O_RDONLY | O_BINARY, 0555);
 	if(mParityHandle == -1)
 	{
 		THROW_EXCEPTION(RaidFileException, OSError)
@@ -1017,7 +1027,8 @@
 		std::string writeFilename(RaidFileUtil::MakeWriteFileName(rdiscSet, Filename));
 
 		// Attempt to open
-		int osFileHandle = ::open(writeFilename.c_str(), O_RDONLY, 0);
+		int osFileHandle = ::open(writeFilename.c_str(), 
+			O_RDONLY | O_BINARY, 0);
 		if(osFileHandle == -1)
 		{
 			THROW_EXCEPTION(RaidFileException, ErrorOpeningFileForRead)
@@ -1055,13 +1066,15 @@
 		try
 		{
 			// Open stripe1
-			stripe1 = ::open(stripe1Filename.c_str(), O_RDONLY, 0555);
+			stripe1 = ::open(stripe1Filename.c_str(), 
+				O_RDONLY | O_BINARY, 0555);
 			if(stripe1 == -1)
 			{
 				stripe1errno = errno;
 			}
 			// Open stripe2
-			stripe2 = ::open(stripe2Filename.c_str(), O_RDONLY, 0555);
+			stripe2 = ::open(stripe2Filename.c_str(), 
+				O_RDONLY | O_BINARY, 0555);
 			if(stripe2 == -1)
 			{
 				stripe2errno = errno;
@@ -1169,7 +1182,8 @@
 			// Open stripe1?
 			if(existingFiles & RaidFileUtil::Stripe1Exists)
 			{
-				stripe1 = ::open(stripe1Filename.c_str(), O_RDONLY, 0555);
+				stripe1 = ::open(stripe1Filename.c_str(), 
+					O_RDONLY | O_BINARY, 0555);
 				if(stripe1 == -1)
 				{
 					THROW_EXCEPTION(RaidFileException, OSError)
@@ -1178,14 +1192,16 @@
 			// Open stripe2?
 			if(existingFiles & RaidFileUtil::Stripe2Exists)
 			{
-				stripe2 = ::open(stripe2Filename.c_str(), O_RDONLY, 0555);
+				stripe2 = ::open(stripe2Filename.c_str(), 
+					O_RDONLY | O_BINARY, 0555);
 				if(stripe2 == -1)
 				{
 					THROW_EXCEPTION(RaidFileException, OSError)
 				}
 			}
 			// Open parity
-			parity = ::open(parityFilename.c_str(), O_RDONLY, 0555);
+			parity = ::open(parityFilename.c_str(), 
+				O_RDONLY | O_BINARY, 0555);
 			if(parity == -1)
 			{
 				THROW_EXCEPTION(RaidFileException, OSError)




More information about the Boxbackup-commit mailing list