summaryrefslogtreecommitdiff
path: root/lib/raidfile/RaidFileRead.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/raidfile/RaidFileRead.cpp')
-rw-r--r--lib/raidfile/RaidFileRead.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/lib/raidfile/RaidFileRead.cpp b/lib/raidfile/RaidFileRead.cpp
index 0a79be57..3a7a5893 100644
--- a/lib/raidfile/RaidFileRead.cpp
+++ b/lib/raidfile/RaidFileRead.cpp
@@ -12,7 +12,14 @@
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
+<<<<<<< HEAD
#include <unistd.h>
+=======
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+>>>>>>> 0.12
#include <sys/stat.h>
#include <sys/types.h>
@@ -1022,8 +1029,13 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
RaidFileUtil::ExistType existance = RaidFileUtil::RaidFileExists(rdiscSet, Filename, &startDisc, &existingFiles, pRevisionID);
if(existance == RaidFileUtil::NoFile)
{
+<<<<<<< HEAD
BOX_ERROR("Expected raidfile " << Filename << " does not exist");
THROW_EXCEPTION(RaidFileException, RaidFileDoesntExist)
+=======
+ THROW_FILE_ERROR("Expected raidfile does not exist",
+ Filename, RaidFileException, RaidFileDoesntExist);
+>>>>>>> 0.12
}
else if(existance == RaidFileUtil::NonRaid)
{
@@ -1086,9 +1098,25 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
{
stripe2errno = errno;
}
+<<<<<<< HEAD
if(stripe1errno != 0 || stripe2errno != 0)
{
THROW_EXCEPTION(RaidFileException, ErrorOpeningFileForRead)
+=======
+
+ if(stripe1errno != 0)
+ {
+ THROW_SYS_FILE_ERRNO("Failed to open RaidFile",
+ stripe1Filename, stripe1errno,
+ RaidFileException, ErrorOpeningFileForRead);
+ }
+
+ if(stripe2errno != 0)
+ {
+ THROW_SYS_FILE_ERRNO("Failed to open RaidFile",
+ stripe2Filename, stripe2errno,
+ RaidFileException, ErrorOpeningFileForRead);
+>>>>>>> 0.12
}
// stat stripe 1 to find ('half' of) length...
@@ -1107,11 +1135,28 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
length += st.st_size;
// Handle errors
+<<<<<<< HEAD
if(stripe1errno != 0 || stripe2errno != 0)
{
THROW_EXCEPTION(RaidFileException, OSError)
}
+=======
+ if(stripe1errno != 0)
+ {
+ THROW_SYS_FILE_ERRNO("Failed to stat RaidFile",
+ stripe1Filename, stripe1errno,
+ RaidFileException, OSError);
+ }
+
+ if(stripe2errno != 0)
+ {
+ THROW_SYS_FILE_ERRNO("Failed to stat RaidFile",
+ stripe2Filename, stripe2errno,
+ RaidFileException, OSError);
+ }
+
+>>>>>>> 0.12
// Make a nice object to represent this file
return std::auto_ptr<RaidFileRead>(new RaidFileRead_Raid(SetNumber, Filename, stripe1, stripe2, -1, length, rdiscSet.GetBlockSize(), false /* actually we don't know */));
}
@@ -1238,17 +1283,40 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
ASSERT(sizeof(FileSizeType) == 8); // compiler bug (I think) prevents from using 0 - sizeof(FileSizeType)...
if(::lseek(parity, -8 /*(0 - sizeof(FileSizeType))*/, SEEK_END) == -1)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to seek "
+ "in parity RaidFile",
+ parityFilename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
// Read it in
if(::read(parity, &parityLastData, sizeof(parityLastData)) != sizeof(parityLastData))
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
}
// Set back to beginning of file
if(::lseek(parity, 0, SEEK_SET) == -1)
{
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to read "
+ "parity RaidFile",
+ parityFilename,
+ RaidFileException, OSError);
+ }
+
+ // Set back to beginning of file
+ if(::lseek(parity, 0, SEEK_SET) == -1)
+ {
+ THROW_SYS_FILE_ERROR("Failed to seek "
+ "in parity RaidFile",
+ parityFilename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
}
@@ -1271,7 +1339,14 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
// to get the size from the FileSizeType value at end of the file.
if(::fstat(stripe1, &st) != 0)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to "
+ "stat RaidFile stripe 1",
+ stripe1Filename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
pos_type stripe1Size = st.st_size;
// Is size integral?
@@ -1305,17 +1380,38 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
ASSERT(btr <= (int)sizeof(FileSizeType));
if(::lseek(stripe1, 0 - btr, SEEK_END) == -1)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to "
+ "seek in RaidFile stripe 1",
+ stripe1Filename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
// Read it in
if(::read(stripe1, &stripe1LastData, btr) != btr)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to "
+ "read RaidFile stripe 1",
+ stripe1Filename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
// Set back to beginning of file
if(::lseek(stripe1, 0, SEEK_SET) == -1)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to "
+ "seek in RaidFile stripe 1",
+ stripe1Filename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
}
// Lovely!
@@ -1337,7 +1433,14 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
// Get size of stripe2 file
if(::fstat(stripe2, &st) != 0)
{
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, OSError)
+=======
+ THROW_SYS_FILE_ERROR("Failed to "
+ "stat RaidFile stripe 2",
+ stripe2Filename,
+ RaidFileException, OSError);
+>>>>>>> 0.12
}
pos_type stripe2Size = st.st_size;
@@ -1406,7 +1509,12 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
}
}
+<<<<<<< HEAD
THROW_EXCEPTION(RaidFileException, FileIsDamagedNotRecoverable)
+=======
+ THROW_FILE_ERROR("Failed to recover RaidFile", Filename,
+ RaidFileException, FileIsDamagedNotRecoverable);
+>>>>>>> 0.12
// Avoid compiler warning -- it'll never get here...
return std::auto_ptr<RaidFileRead>();
@@ -1540,7 +1648,11 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
{
// build name
std::string dn(rdiscSet[l] + DIRECTORY_SEPARATOR + rDirName);
+<<<<<<< HEAD
+=======
+
+>>>>>>> 0.12
// read the contents...
DIR *dirHandle = 0;
try