diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-11-21 21:50:59 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-11-21 21:50:59 +0000 |
commit | 00e03b53403bbaec08d3b4ab9e424855752c2d65 (patch) | |
tree | dde302f3ff82c7f4d4cb03e5c779b2f8e58e486f /netfs/fuse | |
parent | Shuffle some code back to where it came from (diff) | |
download | netfs-00e03b53403bbaec08d3b4ab9e424855752c2d65.tar.bz2 netfs-00e03b53403bbaec08d3b4ab9e424855752c2d65.tar.xz netfs-00e03b53403bbaec08d3b4ab9e424855752c2d65.zip |
First cut migration to fuse3
Diffstat (limited to 'netfs/fuse')
-rw-r--r-- | netfs/fuse/Jamfile.jam | 2 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 2 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 18 | ||||
-rw-r--r-- | netfs/fuse/fuseAppBase.cpp | 34 | ||||
-rw-r--r-- | netfs/fuse/fuseAppBase.h | 47 | ||||
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 8 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 46 | ||||
-rw-r--r-- | netfs/fuse/fuseMisc.cpp | 26 |
8 files changed, 78 insertions, 105 deletions
diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam index 2f0f1af..b697a62 100644 --- a/netfs/fuse/Jamfile.jam +++ b/netfs/fuse/Jamfile.jam @@ -28,6 +28,7 @@ lib netfs-client : netfs-client-configuration [ glob *.cpp : fuseConfigImpl.cpp netfs.cpp ] : + <define>FUSE_USE_VERSION=31 <implicit-dependency>../ice//netfs-api <library>netfs-client-configuration <implicit-dependency>netfs-client-configuration @@ -41,6 +42,7 @@ lib netfs-client : <library>..//slicer-xml <use>../..//fuse : : + <define>FUSE_USE_VERSION=31 <include>. <library>../ice//netfs-api <library>Glacier2 diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index 1609280..1f628fa 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -66,7 +66,7 @@ NetFS::FuseApp::~FuseApp() } void * -NetFS::FuseApp::init(struct fuse_conn_info *) +NetFS::FuseApp::init(struct fuse_conn_info *, struct fuse_config *) { BOOST_ASSERT(!ic); ic = Ice::initialize(iceArgs); diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 59fde20..d2b645e 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -53,7 +53,7 @@ namespace NetFS { ~FuseApp(); // lifecycle - void * init (struct fuse_conn_info * info) override; + void * init (struct fuse_conn_info * info, struct fuse_config * cfg) override; static int opt_parse(void * data, const char * arg, int, struct fuse_args *); protected: @@ -66,21 +66,20 @@ namespace NetFS { public: // misc int access(const char * p, int a) override; - int getattr(const char * p, struct stat * s) override; - int fgetattr(const char *, struct stat *, struct fuse_file_info *) override; - int chmod(const char *, mode_t) override; - int chown(const char *, uid_t, gid_t) override; + int getattr(const char *, struct stat *, struct fuse_file_info *) override; + int chmod(const char *, mode_t, struct fuse_file_info *) override; + int chown(const char *, uid_t, gid_t, struct fuse_file_info *) override; int link(const char *, const char *) override; int readlink(const char *, char *, size_t) override; - int rename(const char *, const char *) override; + int rename(const char *, const char *, unsigned int) override; int symlink(const char *, const char *) override; int unlink(const char *) override; - int utimens(const char *, const struct timespec tv[2]) override; + int utimens(const char *, const struct timespec tv[2], struct fuse_file_info *) override; int mknod(const char *, mode_t, dev_t) override; // dirs int opendir(const char * p, struct fuse_file_info * fi) override; int releasedir(const char *, struct fuse_file_info * fi) override; - int readdir(const char *, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi) override; + int readdir(const char *, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi, enum fuse_readdir_flags) override; int mkdir(const char *, mode_t) override; int rmdir(const char *) override; // files @@ -90,8 +89,7 @@ namespace NetFS { int release(const char *, struct fuse_file_info * fi) override; int read(const char *, char * buf, size_t s, off_t o, struct fuse_file_info * fi) override; int write(const char *, const char * buf, size_t s, off_t o, struct fuse_file_info * fi) override; - int truncate(const char *, off_t) override; - int ftruncate(const char *, off_t, struct fuse_file_info *) override; + int truncate(const char *, off_t, struct fuse_file_info *) override; // fs int statfs(const char *, struct statvfs *) override; // stuff diff --git a/netfs/fuse/fuseAppBase.cpp b/netfs/fuse/fuseAppBase.cpp index 68bc170..4d06b44 100644 --- a/netfs/fuse/fuseAppBase.cpp +++ b/netfs/fuse/fuseAppBase.cpp @@ -27,7 +27,7 @@ FuseAppBase::~FuseAppBase() // to call them in a realistic manner. They exist only as the default // implementation of the function which is never passed to libfuse // unless it is overridden. -void * FuseAppBase::init(fuse_conn_info*) +void * FuseAppBase::init(fuse_conn_info*, fuse_config *) { return nullptr; } @@ -35,11 +35,11 @@ int FuseAppBase::access(const char *, int) { return -ENOSYS; } -int FuseAppBase::chmod(const char *, mode_t) +int FuseAppBase::chmod(const char *, mode_t, struct fuse_file_info *) { return -ENOSYS; } -int FuseAppBase::chown(const char *, uid_t, gid_t) +int FuseAppBase::chown(const char *, uid_t, gid_t, struct fuse_file_info *) { return -ENOSYS; } @@ -47,7 +47,7 @@ int FuseAppBase::create(const char *, mode_t, struct fuse_file_info *) { return -ENOSYS; } -int FuseAppBase::fgetattr(const char *, struct stat *, struct fuse_file_info *) +int FuseAppBase::getattr(const char *, struct stat *, struct fuse_file_info *) { return -ENOSYS; } @@ -63,11 +63,7 @@ int FuseAppBase::fsyncdir(const char *, int, struct fuse_file_info *) { return -ENOSYS; } -int FuseAppBase::ftruncate(const char *, off_t, struct fuse_file_info *) -{ - return -ENOSYS; -} -int FuseAppBase::getattr(const char *, struct stat *) +int FuseAppBase::truncate(const char *, off_t, struct fuse_file_info *) { return -ENOSYS; } @@ -103,7 +99,7 @@ int FuseAppBase::read(const char *, char *, size_t, off_t, struct fuse_file_info { return -ENOSYS; } -int FuseAppBase::readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *) +int FuseAppBase::readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags) { return -ENOSYS; } @@ -123,7 +119,7 @@ int FuseAppBase::removexattr(const char *, const char *) { return -ENOSYS; } -int FuseAppBase::rename(const char *, const char *) +int FuseAppBase::rename(const char *, const char *, unsigned int) { return -ENOSYS; } @@ -143,10 +139,6 @@ int FuseAppBase::symlink(const char *, const char *) { return -ENOSYS; } -int FuseAppBase::truncate(const char *, off_t) -{ - return -ENOSYS; -} int FuseAppBase::unlink(const char *) { return -ENOSYS; @@ -160,7 +152,7 @@ int FuseAppBase::lock(const char *, struct fuse_file_info *, int, struct flock * return -ENOSYS; } // NOLINTNEXTLINE(modernize-avoid-c-arrays, hicpp-avoid-c-arrays) -int FuseAppBase::utimens(const char *, const struct timespec[2]) +int FuseAppBase::utimens(const char *, const struct timespec[2], struct fuse_file_info *) { return -ENOSYS; } @@ -168,7 +160,7 @@ int FuseAppBase::bmap(const char *, size_t, uint64_t *) { return -ENOSYS; } -int FuseAppBase::ioctl(const char *, int, void *, struct fuse_file_info *, unsigned int, void *) +int FuseAppBase::ioctl(const char *, unsigned int, void *, struct fuse_file_info *, unsigned int, void *) { return -ENOSYS; } @@ -192,6 +184,14 @@ int FuseAppBase::fallocate(const char *, int, off_t, off_t, struct fuse_file_inf { return -ENOSYS; } +ssize_t FuseAppBase::copy_file_range(const char *, struct fuse_file_info *, off_t, const char *, struct fuse_file_info *, off_t, size_t, int) +{ + return -ENOSYS; +} +off_t FuseAppBase::lseek(const char *, off_t, int, struct fuse_file_info *) +{ + return -ENOSYS; +} // LCOV_EXCL_STOP void FuseAppBase::log(int level, const char * message) const noexcept { diff --git a/netfs/fuse/fuseAppBase.h b/netfs/fuse/fuseAppBase.h index 44943b7..c73a476 100644 --- a/netfs/fuse/fuseAppBase.h +++ b/netfs/fuse/fuseAppBase.h @@ -1,7 +1,6 @@ #ifndef FUSEAPP_H #define FUSEAPP_H -#define FUSE_USE_VERSION 26 #include <fuse.h> #include <typeinfo> #include <exception> @@ -18,17 +17,16 @@ class DLL_PUBLIC FuseAppBase { FuseAppBase(); virtual ~FuseAppBase(); - virtual void * init (struct fuse_conn_info * info); + virtual void * init (struct fuse_conn_info * info, struct fuse_config * cfg); virtual int access(const char *, int); - virtual int chmod(const char *, mode_t); - virtual int chown(const char *, uid_t, gid_t); + virtual int chmod(const char *, mode_t, struct fuse_file_info *); + virtual int chown(const char *, uid_t, gid_t, struct fuse_file_info *); virtual int create(const char *, mode_t, struct fuse_file_info *); - virtual int fgetattr(const char *, struct stat *, struct fuse_file_info *); + virtual int getattr(const char *, struct stat *, struct fuse_file_info *); virtual int flush(const char *, struct fuse_file_info *); virtual int fsync(const char *, int, struct fuse_file_info *); virtual int fsyncdir(const char *, int, struct fuse_file_info *); - virtual int ftruncate(const char *, off_t, struct fuse_file_info *); - virtual int getattr(const char *, struct stat *); + virtual int truncate(const char *, off_t, struct fuse_file_info *); virtual int getxattr(const char *, const char *, char *, size_t); virtual int link(const char *, const char *); virtual int listxattr(const char *, char *, size_t); @@ -37,28 +35,29 @@ class DLL_PUBLIC FuseAppBase { virtual int open(const char *, struct fuse_file_info *); virtual int opendir(const char *, struct fuse_file_info *); virtual int read(const char *, char *, size_t, off_t, struct fuse_file_info *); - virtual int readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *); + virtual int readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags); virtual int readlink(const char *, char *, size_t); virtual int release(const char *, struct fuse_file_info *); virtual int releasedir(const char *, struct fuse_file_info *); virtual int removexattr(const char *, const char *); - virtual int rename(const char *, const char *); + virtual int rename(const char *, const char *, unsigned int); virtual int rmdir(const char *); virtual int setxattr(const char *, const char *, const char *, size_t, int); virtual int statfs(const char *, struct statvfs *); virtual int symlink(const char *, const char *); - virtual int truncate(const char *, off_t); virtual int unlink(const char *); virtual int write(const char *, const char *, size_t, off_t, struct fuse_file_info *); virtual int lock(const char *, struct fuse_file_info *, int cmd, struct flock *); - virtual int utimens(const char *, const struct timespec tv[2]); + virtual int utimens(const char *, const struct timespec tv[2], struct fuse_file_info *); virtual int bmap(const char *, size_t blocksize, uint64_t *idx); - virtual int ioctl(const char *, int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void * data); + virtual int ioctl(const char *, unsigned int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void * data); virtual int poll(const char *, struct fuse_file_info *, struct fuse_pollhandle *, unsigned *); virtual int write_buf(const char *, struct fuse_bufvec *buf, off_t off, struct fuse_file_info *); virtual int read_buf(const char *, struct fuse_bufvec **bufp, size_t size, off_t off, struct fuse_file_info *); virtual int flock(const char *, struct fuse_file_info *, int op); virtual int fallocate(const char *, int, off_t, off_t, struct fuse_file_info *); + virtual ssize_t copy_file_range(const char *, struct fuse_file_info *, off_t, const char *, struct fuse_file_info *, off_t, size_t, int); + virtual off_t lseek(const char *, off_t off, int whence, struct fuse_file_info *); virtual int onError(const std::exception & err) throw(); virtual void beforeOperation(); void log(int level, const char * message) const throw(); @@ -78,7 +77,6 @@ class FuseAppBaseT : public FuseAppBase { FuseAppBaseT() : operations({ GetHelper(getattr), GetHelper(readlink), - nullptr, // getdir deprecated GetHelper(mknod), GetHelper(mkdir), GetHelper(unlink), @@ -89,7 +87,6 @@ class FuseAppBaseT : public FuseAppBase { GetHelper(chmod), GetHelper(chown), GetHelper(truncate), - nullptr, // utime deprecated GetHelper(open), GetHelper(read), GetHelper(write), @@ -109,29 +106,17 @@ class FuseAppBaseT : public FuseAppBase { nullptr, //fuseDestroy GetHelper(access), GetHelper(create), - GetHelper(ftruncate), - GetHelper(fgetattr), -#if (FUSE_MINOR_VERSION >= 6) GetHelper(lock), GetHelper(utimens), GetHelper(bmap), -#if (FUSE_MINOR_VERSION >= 8) - 0, // flag_nullpath_ok -#if (FUSE_MINOR_VERSION >= 9) - 0, // flag_nopath - 0, // flag_utime_omit_ok -#endif - 0, // flag_reserved GetHelper(ioctl), GetHelper(poll), -#if (FUSE_MINOR_VERSION >= 9) GetHelper(write_buf), GetHelper(read_buf), GetHelper(flock), GetHelper(fallocate), -#endif -#endif -#endif + GetHelper(copy_file_range), + GetHelper(lseek), }) { } @@ -151,11 +136,11 @@ class FuseAppBaseT : public FuseAppBase { } return nullptr; } - template <typename BFunc, typename IFunc, BFunc bfunc, typename ... Args> - constexpr static auto getHelper(int(FuseAppBase::*)(Args...)) -> int(*)(Args...) + template <typename BFunc, typename IFunc, BFunc bfunc, typename Rtn, typename ... Args> + constexpr static auto getHelper(Rtn(FuseAppBase::*)(Args...)) -> Rtn(*)(Args...) { if constexpr (!std::is_same<BFunc, IFunc>::value) { - return [](Args ... a) { + return [](Args ... a) -> Rtn { for (int t = 0; ; ++t) { try { fuseApp->beforeOperation(); diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index 5091d39..490a4bb 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -46,15 +46,15 @@ FuseApp::releasedir(const char *, struct fuse_file_info * fi) } int -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, enum fuse_readdir_flags flags) { try { auto od = getProxy<OpenDirPtr>(fi->fh); std::string path(p); auto expiry = time(nullptr) + 2; - if (fcr->ListDir && od->remoteV2) { + if (flags == FUSE_READDIR_PLUS && fcr->ListDir && od->remoteV2) { for (const auto & e : od->remoteV2->listdir()) { - filler(buf, e.first.c_str(), nullptr, 0); + filler(buf, e.first.c_str(), nullptr, 0, FUSE_FILL_DIR_PLUS); std::string k(path + e.first); statCache.remove(k); statCache.add(k, converter.convert(e.second), expiry); @@ -62,7 +62,7 @@ FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, stru } else { for (const auto & e : od->remote->readdir()) { - filler(buf, e.c_str(), nullptr, 0); + filler(buf, e.c_str(), nullptr, 0, (fuse_fill_dir_flags)0); } } return 0; diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 4ea7f47..c166e46 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -205,10 +205,18 @@ FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_fi } int -FuseApp::truncate(const char * p, off_t o) +FuseApp::truncate(const char * p, off_t o, fuse_file_info * fi) { try { - volume->truncate(reqEnv(), p, o); + if (fi) { + auto of = getProxy<OpenFilePtr>(fi->fh); + of->wait(); + auto remote = of->remote; + remote->ftruncate(reqEnv(), o); + } + else { + volume->truncate(reqEnv(), p, o); + } return 0; } catch (SystemError & e) { @@ -217,28 +225,24 @@ FuseApp::truncate(const char * p, off_t o) } int -FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi) +FuseApp::getattr(const char * p, struct stat * s, fuse_file_info * fi) { try { - auto of = getProxy<OpenFilePtr>(fi->fh); - of->wait(); - auto remote = of->remote; - remote->ftruncate(reqEnv(), o); - return 0; - } - catch (SystemError & e) { - return -e.syserrno; - } -} + if (fi) { + auto of = getProxy<OpenFilePtr>(fi->fh); + of->wait(); + auto remote = of->remote; + *s = converter.convert(remote->fgetattr(reqEnv())); + } + else { + if (auto cacehedStat = statCache.get(p)) { + *s = *cacehedStat; + } + else { + *s = converter.convert(volume->getattr(reqEnv(), p)); + } -int -FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi) -{ - try { - auto of = getProxy<OpenFilePtr>(fi->fh); - of->wait(); - auto remote = of->remote; - *s = converter.convert(remote->fgetattr(reqEnv())); + } return 0; } catch (SystemError & e) { diff --git a/netfs/fuse/fuseMisc.cpp b/netfs/fuse/fuseMisc.cpp index f46b2fe..6703fa7 100644 --- a/netfs/fuse/fuseMisc.cpp +++ b/netfs/fuse/fuseMisc.cpp @@ -9,24 +9,7 @@ NetFS::FuseApp::access(const char * p, int a) } int -NetFS::FuseApp::getattr(const char * p, struct stat * s) -{ - try { - if (auto cacehedStat = statCache.get(p)) { - *s = *cacehedStat; - } - else { - *s = converter.convert(volume->getattr(reqEnv(), p)); - } - return 0; - } - catch (NetFS::SystemError & e) { - return -e.syserrno; - } -} - -int -NetFS::FuseApp::chmod(const char * p, mode_t m) +NetFS::FuseApp::chmod(const char * p, mode_t m, fuse_file_info *) { try { volume->chmod(reqEnv(), p, m); @@ -38,7 +21,7 @@ NetFS::FuseApp::chmod(const char * p, mode_t m) } int -NetFS::FuseApp::chown(const char * p, uid_t u, gid_t g) +NetFS::FuseApp::chown(const char * p, uid_t u, gid_t g, fuse_file_info *) { try { volume->chown(reqEnv(), p, u, g); @@ -100,9 +83,10 @@ NetFS::FuseApp::readlink(const char * p, char * p2, size_t s) } int -NetFS::FuseApp::rename(const char * p1, const char * p2) +NetFS::FuseApp::rename(const char * p1, const char * p2, unsigned int) { try { + // TODO flags volume->rename(reqEnv(), p1, p2); return 0; } @@ -113,7 +97,7 @@ NetFS::FuseApp::rename(const char * p1, const char * p2) int // NOLINTNEXTLINE(modernize-avoid-c-arrays,hicpp-avoid-c-arrays) -NetFS::FuseApp::utimens(const char * path, const struct timespec times[2]) +NetFS::FuseApp::utimens(const char * path, const struct timespec times[2], fuse_file_info *) { try { volume->utimens(reqEnv(), path, |