diff options
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 24 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 58 |
2 files changed, 43 insertions, 39 deletions
diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index becaa44..f872b79 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -2,7 +2,8 @@ #include <lockHelpers.h> #include <entCache.h> -NetFS::FuseApp::OpenDir::OpenDir(DirectoryPrx r, const std::string & p) : +namespace NetFS { +FuseApp::OpenDir::OpenDir(DirectoryPrx r, const std::string & p) : remote(r), remoteV2(r->ice_getFacet() >= "v02" ? DirectoryV2Prx::uncheckedCast(r) : nullptr), path(p) @@ -36,20 +37,20 @@ NetFS::FuseApp::clearDirProxy(uint64_t localID) } int -NetFS::FuseApp::opendir(const char * p, struct fuse_file_info * fi) +FuseApp::opendir(const char * p, struct fuse_file_info * fi) { try { auto remote = volume->opendir(reqEnv(), p); setProxy(new OpenDir(remote, p), fi->fh); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::releasedir(const char *, struct fuse_file_info * fi) +FuseApp::releasedir(const char *, struct fuse_file_info * fi) { try { auto remote = getDirProxy(fi->fh)->remote; @@ -57,13 +58,13 @@ NetFS::FuseApp::releasedir(const char *, struct fuse_file_info * fi) clearDirProxy(fi->fh); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi) +FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi) { try { auto od = getDirProxy(fi->fh); @@ -89,32 +90,33 @@ NetFS::FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_ } return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::mkdir(const char * p, mode_t m) +FuseApp::mkdir(const char * p, mode_t m) { try { volume->mkdir(reqEnv(), p, m); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::rmdir(const char * p) +FuseApp::rmdir(const char * p) { try { volume->rmdir(reqEnv(), p); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } +} diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index e81dd45..2fc6b26 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -3,7 +3,8 @@ #include "lockHelpers.h" #include <entCache.h> -NetFS::FuseApp::OpenFile::OpenFile(FilePrx r, const std::string & p, int f) : +namespace NetFS { +FuseApp::OpenFile::OpenFile(FilePrx r, const std::string & p, int f) : remote(r), path(p), flags(f) @@ -30,14 +31,14 @@ NetFS::FuseApp::getFileProxy(uint64_t localID) const } void -NetFS::FuseApp::clearFileProxy(uint64_t localID) +FuseApp::clearFileProxy(uint64_t localID) { Lock(_lock); openFiles.erase(localID); } void -NetFS::FuseApp::OpenFile::wait() const +FuseApp::OpenFile::wait() const { SharedLock(_lock); for (const auto & w : bg) { @@ -46,7 +47,7 @@ NetFS::FuseApp::OpenFile::wait() const } void -NetFS::FuseApp::OpenFile::flush() +FuseApp::OpenFile::flush() { Lock(_lock); while (!bg.empty()) { @@ -58,7 +59,7 @@ NetFS::FuseApp::OpenFile::flush() } void -NetFS::FuseApp::OpenFile::nonBlockingFlush() +FuseApp::OpenFile::nonBlockingFlush() { boost::unique_lock<boost::shared_mutex> lock(_lock, boost::try_to_lock); if (lock.owns_lock()) { @@ -76,33 +77,33 @@ NetFS::FuseApp::OpenFile::nonBlockingFlush() } int -NetFS::FuseApp::open(const char * p, struct fuse_file_info * fi) +FuseApp::open(const char * p, struct fuse_file_info * fi) { try { auto remote = volume->open(reqEnv(), p, fi->flags); setProxy(new OpenFile(remote, p, fi->flags), fi->fh); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::create(const char * p, mode_t m, struct fuse_file_info * fi) +FuseApp::create(const char * p, mode_t m, struct fuse_file_info * fi) { try { auto remote = volume->create(reqEnv(), p, fi->flags, m); setProxy(new OpenFile(remote, p, fi->flags), fi->fh); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::release(const char *, struct fuse_file_info * fi) +FuseApp::release(const char *, struct fuse_file_info * fi) { try { auto of = getFileProxy(fi->fh); @@ -110,53 +111,53 @@ NetFS::FuseApp::release(const char *, struct fuse_file_info * fi) try { of->flush(); } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { } remote->close(); clearFileProxy(fi->fh); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { clearFileProxy(fi->fh); return -e.syserrno; } } int -NetFS::FuseApp::flush(const char *, struct fuse_file_info * fi) +FuseApp::flush(const char *, struct fuse_file_info * fi) { try { getFileProxy(fi->fh)->flush(); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::read(const char *, char * buf, size_t s, off_t o, struct fuse_file_info * fi) +FuseApp::read(const char *, char * buf, size_t s, off_t o, struct fuse_file_info * fi) { try { auto of = getFileProxy(fi->fh); of->wait(); auto remote = of->remote; - NetFS::Buffer data = remote->read(o, s); + Buffer data = remote->read(o, s); memcpy(buf, &data.front(), data.size()); return data.size(); } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_file_info * fi) +FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_file_info * fi) { try { auto of = getFileProxy(fi->fh); auto remote = of->remote; - auto r = remote->begin_write(o, s, NetFS::Buffer(buf, buf + s)); + auto r = remote->begin_write(o, s, Buffer(buf, buf + s)); if (fcr->Async) { ScopeLock(of->_lock) { of->bg.push_back(r); @@ -168,25 +169,25 @@ NetFS::FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct } return s; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::truncate(const char * p, off_t o) +FuseApp::truncate(const char * p, off_t o) { try { volume->truncate(reqEnv(), p, o); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi) +FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi) { try { auto of = getFileProxy(fi->fh); @@ -195,13 +196,13 @@ NetFS::FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi) remote->ftruncate(reqEnv(), o); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi) +FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi) { try { auto of = getFileProxy(fi->fh); @@ -210,20 +211,21 @@ NetFS::FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi) *s = converter.convert(remote->fgetattr(reqEnv())); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } int -NetFS::FuseApp::unlink(const char * p) +FuseApp::unlink(const char * p) { try { volume->unlink(reqEnv(), p); return 0; } - catch (NetFS::SystemError & e) { + catch (SystemError & e) { return -e.syserrno; } } +} |