diff options
Diffstat (limited to 'netfs/fuse/fuseFiles.cpp')
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
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; } } +} |