Refactor: Move Filesystem.h and FuseErrnoException.h to fuse package

This commit is contained in:
Sebastian Messmer 2014-11-28 14:46:45 +01:00
parent f4e3ad7e5b
commit 5118d5decc
32 changed files with 73 additions and 65 deletions

View File

@ -8,6 +8,7 @@
#include <sys/statvfs.h>
namespace fspp {
namespace fuse {
class Filesystem {
public:
virtual ~Filesystem() {}
@ -35,6 +36,7 @@ public:
virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0;
};
}
}
#endif

View File

@ -2,8 +2,8 @@
#include <memory>
#include <cassert>
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/impl/Filesystem.h"
#include "fspp/fuse/FuseErrnoException.h"
#include "Filesystem.h"
using std::unique_ptr;
using std::make_unique;
@ -223,7 +223,7 @@ int Fuse::getattr(const bf::path &path, struct stat *stbuf) {
try {
_fs->lstat(path, stbuf);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}
@ -243,7 +243,7 @@ int Fuse::fgetattr(const bf::path &path, struct stat *stbuf, fuse_file_info *fil
try {
_fs->fstat(fileinfo->fh, stbuf);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}
@ -270,7 +270,7 @@ int Fuse::mkdir(const bf::path &path, mode_t mode) {
try {
_fs->mkdir(path, mode);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}
@ -280,7 +280,7 @@ int Fuse::unlink(const bf::path &path) {
try {
_fs->unlink(path);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}
@ -289,7 +289,7 @@ int Fuse::rmdir(const bf::path &path) {
try {
_fs->rmdir(path);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}
@ -309,7 +309,7 @@ int Fuse::rename(const bf::path &from, const bf::path &to) {
try {
_fs->rename(from, to);
return 0;
} catch(fspp::FuseErrnoException &e) {
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();
}
}

View File

@ -11,9 +11,9 @@
namespace fspp {
class Device;
class Filesystem;
namespace fuse {
class Filesystem;
class Fuse {
public:

View File

@ -6,6 +6,7 @@
#include <errno.h>
namespace fspp {
namespace fuse{
class FuseErrnoException: public std::runtime_error {
public:
@ -35,6 +36,7 @@ inline int FuseErrnoException::getErrno() const {
return _errno;
}
} /* namespace fspp */
}
}
#endif /* FSPP_FUSE_FUSEERRNOEXCEPTION_H_ */

View File

@ -5,7 +5,7 @@
#include <fspp/fs_interface/Device.h>
#include <fspp/fs_interface/Dir.h>
#include "FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
#include "fspp/fs_interface/File.h"
@ -31,7 +31,7 @@ unique_ptr<File> FilesystemImpl::LoadFile(const bf::path &path) {
auto node = _device->Load(path);
auto file = dynamic_pointer_move<File>(node);
if (!file) {
throw FuseErrnoException(EISDIR);
throw fuse::FuseErrnoException(EISDIR);
}
return file;
}
@ -40,7 +40,7 @@ unique_ptr<Dir> FilesystemImpl::LoadDir(const bf::path &path) {
auto node = _device->Load(path);
auto dir = dynamic_pointer_move<Dir>(node);
if (!dir) {
throw FuseErrnoException(ENOTDIR);
throw fuse::FuseErrnoException(ENOTDIR);
}
return dir;
}

View File

@ -3,7 +3,7 @@
#define FSPP_IMPL_FILESYSTEMIMPL_H_
#include "FuseOpenFileList.h"
#include "Filesystem.h"
#include "fspp/fuse/Filesystem.h"
#include "fspp/utils/macros.h"
@ -13,7 +13,7 @@ class File;
class OpenFile;
class Dir;
class FilesystemImpl: public Filesystem {
class FilesystemImpl: public fuse::Filesystem {
public:
FilesystemImpl(Device *device);
virtual ~FilesystemImpl();

View File

@ -3,7 +3,7 @@
#include "test/testutils/FuseTest.h"
using namespace fspp;
using namespace fspp::fuse;
using namespace fspp::fuse;
using ::testing::_;

View File

@ -0,0 +1,4 @@
/*
* Tests that the header can be included without needing additional header includes as dependencies.
*/
#include "fspp/fuse/Filesystem.h"

View File

@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using namespace fspp;
using namespace fspp::fuse;
class FuseAccessErrorTest: public FuseAccessTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseCreateAndOpenTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::WithParamInterface;
using ::testing::Values;
@ -9,7 +9,7 @@ using ::testing::Throw;
using ::testing::StrEq;
using ::testing::_;
using namespace fspp;
using namespace fspp::fuse;
class FuseCreateAndOpenErrorTest: public FuseCreateAndOpenTest, public WithParamInterface<int> {
};

View File

@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using namespace fspp;
using namespace fspp::fuse;
class FuseFdatasyncErrorTest: public FuseFdatasyncTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFdatasyncTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -9,7 +9,7 @@ using ::testing::Values;
using ::testing::Eq;
using ::testing::Return;
using namespace fspp;
using namespace fspp::fuse;
class FuseFdatasyncFileDescriptorTest: public FuseFdatasyncTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFlushTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::WithParamInterface;
using ::testing::StrEq;
@ -11,7 +11,7 @@ using ::testing::AtLeast;
using ::testing::Values;
using ::testing::_;
using fspp::FuseErrnoException;
using fspp::fuse::FuseErrnoException;
class FuseFlushErrorTest: public FuseFlushTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFstatTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
// Cite from FUSE documentation on the fgetattr function:
// "Currently this is only called after the create() method if that is implemented (see above).

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFstatTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
// Cite from FUSE documentation on the fgetattr function:
// "Currently this is only called after the create() method if that is implemented (see above).

View File

@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using namespace fspp;
using namespace fspp::fuse;
class FuseFsyncErrorTest: public FuseFsyncTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFsyncTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -9,7 +9,7 @@ using ::testing::Values;
using ::testing::Eq;
using ::testing::Return;
using namespace fspp;
using namespace fspp::fuse;
class FuseFsyncFileDescriptorTest: public FuseFsyncTest, public WithParamInterface<int> {
};

View File

@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using namespace fspp;
using namespace fspp::fuse;
class FuseFTruncateErrorTest: public FuseFTruncateTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseFTruncateTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
class FuseFTruncateFileDescriptorTest: public FuseFTruncateTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseLstatTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::_;
@ -8,7 +8,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using fspp::FuseErrnoException;
using fspp::fuse::FuseErrnoException;
class FuseLstatErrorTest: public FuseLstatTest, public WithParamInterface<int> {
public:

View File

@ -1,6 +1,6 @@
#include "testutils/FuseOpenTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::WithParamInterface;
using ::testing::Values;
@ -9,7 +9,7 @@ using ::testing::Throw;
using ::testing::StrEq;
using ::testing::_;
using namespace fspp;
using namespace fspp::fuse;
class FuseOpenErrorTest: public FuseOpenTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseReadTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -12,7 +12,7 @@ using ::testing::Return;
using ::testing::Invoke;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
class FuseReadErrorTest: public FuseReadTest, public WithParamInterface<int> {
public:

View File

@ -1,6 +1,6 @@
#include "testutils/FuseReadTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -11,7 +11,7 @@ using ::testing::Return;
using ::testing::Invoke;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
class FuseReadFileDescriptorTest: public FuseReadTest, public WithParamInterface<int> {
};

View File

@ -1,6 +1,6 @@
#include "testutils/FuseReadTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -11,7 +11,7 @@ using ::testing::Action;
using std::min;
using namespace fspp;
using namespace fspp::fuse;
class FuseReadOverflowTest: public FuseReadTest {
public:

View File

@ -2,7 +2,7 @@
#include "test/testutils/VirtualTestFile.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
#include <tuple>
#include <cstdlib>
@ -23,7 +23,7 @@ using std::min;
using std::unique_ptr;
using std::make_unique;
using namespace fspp;
using namespace fspp::fuse;
// We can't test the count or size parameter directly, because fuse doesn't pass them 1:1.
// It usually asks to read bigger blocks (probably does some caching).

View File

@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -10,7 +10,7 @@ using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
using namespace fspp;
using namespace fspp::fuse;
class FuseTruncateErrorTest: public FuseTruncateTest, public WithParamInterface<int> {
};

View File

@ -2,7 +2,7 @@
#include "test/testutils/VirtualTestFile.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
#include <tuple>
#include <cstdlib>
@ -23,7 +23,7 @@ using std::min;
using std::unique_ptr;
using std::make_unique;
using namespace fspp;
using namespace fspp::fuse;
// We can't test the count or size parameter directly, because fuse doesn't pass them 1:1.
// But we can test that the data passed to the ::write syscall is correctly written.

View File

@ -1,6 +1,6 @@
#include "testutils/FuseWriteTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -12,7 +12,7 @@ using ::testing::Return;
using ::testing::Invoke;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
class FuseWriteErrorTest: public FuseWriteTest, public WithParamInterface<int> {
public:

View File

@ -1,6 +1,6 @@
#include "testutils/FuseWriteTest.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -11,7 +11,7 @@ using ::testing::Return;
using ::testing::Invoke;
using ::testing::Throw;
using namespace fspp;
using namespace fspp::fuse;
class FuseWriteFileDescriptorTest: public FuseWriteTest, public WithParamInterface<int> {
};

View File

@ -2,7 +2,7 @@
#include "test/testutils/VirtualTestFile.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
@ -13,7 +13,7 @@ using ::testing::Action;
using std::min;
using namespace fspp;
using namespace fspp::fuse;
class FuseWriteOverflowTest: public FuseWriteTest {
public:

View File

@ -12,7 +12,7 @@ using std::make_unique;
namespace bf = boost::filesystem;
using namespace fspp;
using namespace fspp::fuse;
MockFilesystem::MockFilesystem() {}
MockFilesystem::~MockFilesystem() {}
@ -83,7 +83,7 @@ Action<void(const char*, struct ::stat*)> FuseTest::ReturnIsDir =
result->st_nlink = 1;
});
Action<void(const char*, struct ::stat*)> FuseTest::ReturnDoesntExist = Throw(fspp::FuseErrnoException(ENOENT));
Action<void(const char*, struct ::stat*)> FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT));
void FuseTest::OnOpenReturnFileDescriptor(const char *filename, int descriptor) {
EXPECT_CALL(fsimpl, openFile(StrEq(filename), _)).Times(1).WillOnce(Return(descriptor));

View File

@ -5,8 +5,8 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fspp/impl/Filesystem.h"
#include "fspp/impl/FuseErrnoException.h"
#include "fspp/fuse/Filesystem.h"
#include "fspp/fuse/FuseErrnoException.h"
#include "fspp/fuse/Fuse.h"
#include <boost/filesystem.hpp>
@ -32,7 +32,7 @@
} \
MOCK_METHOD4(NAME, RETURNTYPE(const char*, PARAM1, PARAM2, PARAM3)); \
class MockFilesystem: public fspp::Filesystem {
class MockFilesystem: public fspp::fuse::Filesystem {
public:
MockFilesystem();
virtual ~MockFilesystem();