From f130d07fd86336d3fa330ab3a998c18f8b522dba Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Tue, 21 Jul 2015 14:19:17 -0400 Subject: [PATCH] config get and struct naming cleanup --- src/access.cpp | 4 +- src/chmod.cpp | 4 +- src/chown.cpp | 5 +- src/config.cpp | 171 ++++++++++++++++++------------------------ src/config.hpp | 104 +++++++++++++------------ src/create.cpp | 10 +-- src/create.hpp | 6 +- src/fallocate.cpp | 10 +-- src/fallocate.hpp | 10 +-- src/fgetattr.cpp | 6 +- src/fgetattr.hpp | 6 +- src/flush.cpp | 4 +- src/flush.hpp | 4 +- src/fsync.cpp | 6 +- src/fsync.hpp | 6 +- src/ftruncate.cpp | 6 +- src/ftruncate.hpp | 6 +- src/getattr.cpp | 4 +- src/getxattr.cpp | 9 +-- src/init.cpp | 4 +- src/init.hpp | 2 +- src/ioctl.cpp | 16 ++-- src/ioctl.hpp | 12 +-- src/link.cpp | 4 +- src/listxattr.cpp | 4 +- src/mergerfs.cpp | 6 +- src/mkdir.cpp | 4 +- src/mknod.cpp | 4 +- src/open.cpp | 8 +- src/open.hpp | 4 +- src/opendir.cpp | 4 +- src/opendir.hpp | 4 +- src/option_parser.cpp | 44 +++++------ src/option_parser.hpp | 4 +- src/policy_all.cpp | 24 +++++- src/policy_epmfs.cpp | 69 ++++++++--------- src/policy_ff.cpp | 26 +++++-- src/policy_ffwp.cpp | 14 ++-- src/policy_fwfs.cpp | 9 +-- src/policy_lfs.cpp | 23 +++--- src/policy_mfs.cpp | 23 +++--- src/policy_newest.cpp | 15 ++-- src/read.cpp | 10 +-- src/read.hpp | 10 +-- src/read_buf.cpp | 22 +++--- src/read_buf.hpp | 10 +-- src/readdir.cpp | 14 ++-- src/readdir.hpp | 10 +-- src/readlink.cpp | 4 +- src/release.cpp | 4 +- src/release.hpp | 4 +- src/releasedir.cpp | 4 +- src/releasedir.hpp | 4 +- src/removexattr.cpp | 8 +- src/rename.cpp | 4 +- src/rmdir.cpp | 4 +- src/setxattr.cpp | 60 +++++++-------- src/statfs.cpp | 4 +- src/symlink.cpp | 4 +- src/truncate.cpp | 4 +- src/unlink.cpp | 4 +- src/utimens.cpp | 18 ++--- src/utimens.hpp | 4 +- src/write.cpp | 10 +-- src/write.hpp | 10 +-- src/write_buf.cpp | 18 ++--- src/write_buf.hpp | 8 +- 67 files changed, 484 insertions(+), 480 deletions(-) diff --git a/src/access.cpp b/src/access.cpp index f8652228..2da0a538 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -74,8 +74,8 @@ namespace mergerfs access(const char *fusepath, int mask) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/chmod.cpp b/src/chmod.cpp index ee9b504d..dc5dab10 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -74,8 +74,8 @@ namespace mergerfs chmod(const char *fusepath, mode_t mode) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/chown.cpp b/src/chown.cpp index 41d8b1d8..27dc7400 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -37,6 +37,7 @@ using std::string; using std::vector; using mergerfs::Policy; +using mergerfs::Config; static int @@ -77,8 +78,8 @@ namespace mergerfs uid_t uid, gid_t gid) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/config.cpp b/src/config.cpp index 71500606..d8267da6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -40,102 +40,81 @@ using std::vector; namespace mergerfs { - namespace config + Config::Config() + : destmount(), + srcmounts(), + srcmountslock(), + minfreespace(UINT32_MAX), + POLICYINIT(access), + POLICYINIT(chmod), + POLICYINIT(chown), + POLICYINIT(create), + POLICYINIT(getattr), + POLICYINIT(getxattr), + POLICYINIT(link), + POLICYINIT(listxattr), + POLICYINIT(mkdir), + POLICYINIT(mknod), + POLICYINIT(open), + POLICYINIT(readlink), + POLICYINIT(removexattr), + POLICYINIT(rename), + POLICYINIT(rmdir), + POLICYINIT(setxattr), + POLICYINIT(symlink), + POLICYINIT(truncate), + POLICYINIT(unlink), + POLICYINIT(utimens), + controlfile("/.mergerfs") { - Config::Config() - : destmount(), - srcmounts(), - srcmountslock(), - minfreespace(UINT32_MAX), - POLICYINIT(access), - POLICYINIT(chmod), - POLICYINIT(chown), - POLICYINIT(create), - POLICYINIT(getattr), - POLICYINIT(getxattr), - POLICYINIT(link), - POLICYINIT(listxattr), - POLICYINIT(mkdir), - POLICYINIT(mknod), - POLICYINIT(open), - POLICYINIT(readlink), - POLICYINIT(removexattr), - POLICYINIT(rename), - POLICYINIT(rmdir), - POLICYINIT(setxattr), - POLICYINIT(symlink), - POLICYINIT(truncate), - POLICYINIT(unlink), - POLICYINIT(utimens), - controlfile("/.mergerfs") - { - pthread_rwlock_init(&srcmountslock,NULL); - - set_category_policy("action","all"); - set_category_policy("create","epmfs"); - set_category_policy("search","ff"); - } - - int - Config::set_func_policy(const string &fusefunc_, - const string &policy_) - { - const Policy *policy; - const FuseFunc *fusefunc; - - fusefunc = FuseFunc::find(fusefunc_); - if(fusefunc == FuseFunc::invalid) - return (errno=ENODATA,-1); - - policy = Policy::find(policy_); - if(policy == Policy::invalid) - return (errno=EINVAL,-1); - - policies[(FuseFunc::Enum::Type)*fusefunc] = policy; - - return 0; - } - - int - Config::set_category_policy(const string &category_, - const string &policy_) - { - const Policy *policy; - const Category *category; - - category = Category::find(category_); - if(category == Category::invalid) - return (errno=ENODATA,-1); - - policy = Policy::find(policy_); - if(policy == Policy::invalid) - return (errno=EINVAL,-1); - - for(int i = 0; i < FuseFunc::Enum::END; i++) - { - if(FuseFunc::fusefuncs[i] == (Category::Enum::Type)*category) - policies[(FuseFunc::Enum::Type)FuseFunc::fusefuncs[i]] = policy; - } - - return 0; - } - - const Config& - get(const struct fuse_context *fc) - { - return *((Config*)fc->private_data); - } - - const Config& - get(void) - { - return get(fuse_get_context()); - } - - Config& - get_writable(void) - { - return (*((Config*)fuse_get_context()->private_data)); - } + pthread_rwlock_init(&srcmountslock,NULL); + + set_category_policy("action","all"); + set_category_policy("create","epmfs"); + set_category_policy("search","ff"); + } + + int + Config::set_func_policy(const string &fusefunc_, + const string &policy_) + { + const Policy *policy; + const FuseFunc *fusefunc; + + fusefunc = FuseFunc::find(fusefunc_); + if(fusefunc == FuseFunc::invalid) + return (errno=ENODATA,-1); + + policy = Policy::find(policy_); + if(policy == Policy::invalid) + return (errno=EINVAL,-1); + + policies[(FuseFunc::Enum::Type)*fusefunc] = policy; + + return 0; + } + + int + Config::set_category_policy(const string &category_, + const string &policy_) + { + const Policy *policy; + const Category *category; + + category = Category::find(category_); + if(category == Category::invalid) + return (errno=ENODATA,-1); + + policy = Policy::find(policy_); + if(policy == Policy::invalid) + return (errno=EINVAL,-1); + + for(int i = 0; i < FuseFunc::Enum::END; i++) + { + if(FuseFunc::fusefuncs[i] == (Category::Enum::Type)*category) + policies[(FuseFunc::Enum::Type)FuseFunc::fusefuncs[i]] = policy; + } + + return 0; } } diff --git a/src/config.hpp b/src/config.hpp index 9a7b2602..550fd41b 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -38,56 +38,64 @@ namespace mergerfs { - namespace config + class Config { - class Config + public: + Config(); + + public: + int set_func_policy(const std::string &fusefunc_, + const std::string &policy_); + int set_category_policy(const std::string &category, + const std::string &policy); + + public: + std::string destmount; + std::vector srcmounts; + mutable pthread_rwlock_t srcmountslock; + size_t minfreespace; + + public: + const Policy *policies[FuseFunc::Enum::END]; + const Policy *&access; + const Policy *&chmod; + const Policy *&chown; + const Policy *&create; + const Policy *&getattr; + const Policy *&getxattr; + const Policy *&link; + const Policy *&listxattr; + const Policy *&mkdir; + const Policy *&mknod; + const Policy *&open; + const Policy *&readlink; + const Policy *&removexattr; + const Policy *&rename; + const Policy *&rmdir; + const Policy *&setxattr; + const Policy *&symlink; + const Policy *&truncate; + const Policy *&unlink; + const Policy *&utimens; + + public: + const std::string controlfile; + + public: + static + const Config & + get(const fuse_context *fc) { - public: - Config(); - - public: - int set_func_policy(const std::string &fusefunc_, - const std::string &policy_); - int set_category_policy(const std::string &category, - const std::string &policy); - - public: - std::string destmount; - std::vector srcmounts; - mutable pthread_rwlock_t srcmountslock; - size_t minfreespace; - - public: - const Policy *policies[FuseFunc::Enum::END]; - const Policy *&access; - const Policy *&chmod; - const Policy *&chown; - const Policy *&create; - const Policy *&getattr; - const Policy *&getxattr; - const Policy *&link; - const Policy *&listxattr; - const Policy *&mkdir; - const Policy *&mknod; - const Policy *&open; - const Policy *&readlink; - const Policy *&removexattr; - const Policy *&rename; - const Policy *&rmdir; - const Policy *&setxattr; - const Policy *&symlink; - const Policy *&truncate; - const Policy *&unlink; - const Policy *&utimens; - - public: - const std::string controlfile; - }; - - const Config &get(const struct fuse_context *fc); - const Config &get(void); - Config &get_writable(void); - } + return *((Config*)fc->private_data); + } + + static + Config & + get_writable(void) + { + return (*((Config*)fuse_get_context()->private_data)); + } + }; } #endif diff --git a/src/create.cpp b/src/create.cpp index 9b568d4b..ae2ed60e 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -89,12 +89,12 @@ namespace mergerfs namespace fuse { int - create(const char *fusepath, - mode_t mode, - struct fuse_file_info *fileinfo) + create(const char *fusepath, + mode_t mode, + fuse_file_info *fileinfo) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/create.hpp b/src/create.hpp index c3cdd6d0..19bd3a24 100644 --- a/src/create.hpp +++ b/src/create.hpp @@ -30,8 +30,8 @@ namespace mergerfs namespace fuse { int - create(const char *fusepath, - mode_t mode, - struct fuse_file_info *fileinfo); + create(const char *fusepath, + mode_t mode, + fuse_file_info *fileinfo); } } diff --git a/src/fallocate.cpp b/src/fallocate.cpp index 99a10234..2e65692f 100644 --- a/src/fallocate.cpp +++ b/src/fallocate.cpp @@ -67,11 +67,11 @@ namespace mergerfs namespace fuse { int - fallocate(const char *fusepath, - int mode, - off_t offset, - off_t len, - struct fuse_file_info *ffi) + fallocate(const char *fusepath, + int mode, + off_t offset, + off_t len, + fuse_file_info *ffi) { return _fallocate(ffi->fh, mode, diff --git a/src/fallocate.hpp b/src/fallocate.hpp index f59560b5..503bda68 100644 --- a/src/fallocate.hpp +++ b/src/fallocate.hpp @@ -27,10 +27,10 @@ namespace mergerfs namespace fuse { int - fallocate(const char *fusepath, - int mode, - off_t offset, - off_t len, - struct fuse_file_info *fi); + fallocate(const char *fusepath, + int mode, + off_t offset, + off_t len, + fuse_file_info *fi); } } diff --git a/src/fgetattr.cpp b/src/fgetattr.cpp index 6bebe8b6..1c135937 100644 --- a/src/fgetattr.cpp +++ b/src/fgetattr.cpp @@ -46,9 +46,9 @@ namespace mergerfs namespace fuse { int - fgetattr(const char *fusepath, - struct stat *st, - struct fuse_file_info *ffi) + fgetattr(const char *fusepath, + struct stat *st, + fuse_file_info *ffi) { return _fgetattr(ffi->fh, *st); diff --git a/src/fgetattr.hpp b/src/fgetattr.hpp index ccf91afe..c2425c8a 100644 --- a/src/fgetattr.hpp +++ b/src/fgetattr.hpp @@ -31,8 +31,8 @@ namespace mergerfs namespace fuse { int - fgetattr(const char *fusepath, - struct stat *st, - struct fuse_file_info *fileinfo); + fgetattr(const char *fusepath, + struct stat *st, + fuse_file_info *fileinfo); } } diff --git a/src/flush.cpp b/src/flush.cpp index 97916358..7700674e 100644 --- a/src/flush.cpp +++ b/src/flush.cpp @@ -47,8 +47,8 @@ namespace mergerfs namespace fuse { int - flush(const char *fusepath, - struct fuse_file_info *ffi) + flush(const char *fusepath, + fuse_file_info *ffi) { return _flush(ffi->fh); } diff --git a/src/flush.hpp b/src/flush.hpp index 347fac5e..bd3a0230 100644 --- a/src/flush.hpp +++ b/src/flush.hpp @@ -27,7 +27,7 @@ namespace mergerfs namespace fuse { int - flush(const char *path, - struct fuse_file_info *fi); + flush(const char *path, + fuse_file_info *fi); } } diff --git a/src/fsync.cpp b/src/fsync.cpp index fb30c6fa..70d256c7 100644 --- a/src/fsync.cpp +++ b/src/fsync.cpp @@ -53,9 +53,9 @@ namespace mergerfs namespace fuse { int - fsync(const char *fusepath, - int isdatasync, - struct fuse_file_info *ffi) + fsync(const char *fusepath, + int isdatasync, + fuse_file_info *ffi) { return _fsync(ffi->fh, isdatasync); diff --git a/src/fsync.hpp b/src/fsync.hpp index 20b56d6b..f62f90b9 100644 --- a/src/fsync.hpp +++ b/src/fsync.hpp @@ -29,8 +29,8 @@ namespace mergerfs namespace fuse { int - fsync(const char *fusepath, - int isdatasync, - struct fuse_file_info *fi); + fsync(const char *fusepath, + int isdatasync, + fuse_file_info *fi); } } diff --git a/src/ftruncate.cpp b/src/ftruncate.cpp index 538756fe..5b52fc5a 100644 --- a/src/ftruncate.cpp +++ b/src/ftruncate.cpp @@ -45,9 +45,9 @@ namespace mergerfs namespace fuse { int - ftruncate(const char *fusepath, - off_t size, - struct fuse_file_info *ffi) + ftruncate(const char *fusepath, + off_t size, + fuse_file_info *ffi) { return _ftruncate(ffi->fh, size); diff --git a/src/ftruncate.hpp b/src/ftruncate.hpp index 5be0841b..29b8403d 100644 --- a/src/ftruncate.hpp +++ b/src/ftruncate.hpp @@ -32,8 +32,8 @@ namespace mergerfs namespace fuse { int - ftruncate(const char *fusepath, - off_t size, - struct fuse_file_info *fi); + ftruncate(const char *fusepath, + off_t size, + fuse_file_info *fi); } } diff --git a/src/getattr.cpp b/src/getattr.cpp index 9a8bcd03..bf4f487f 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -94,12 +94,12 @@ namespace mergerfs getattr(const char *fusepath, struct stat *st) { - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); if(fusepath == config.controlfile) return _getattr_controlfile(*st); - const struct fuse_context *fc = fuse_get_context(); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/getxattr.cpp b/src/getxattr.cpp index ba74eb7c..f217eb9e 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -45,7 +45,6 @@ using std::string; using std::vector; using std::set; using namespace mergerfs; -using namespace mergerfs::config; static void @@ -246,7 +245,8 @@ namespace mergerfs char *buf, size_t count) { - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); if(fusepath == config.controlfile) return _getxattr_controlfile(config, @@ -254,9 +254,8 @@ namespace mergerfs buf, count); - const struct fuse_context *fc = fuse_get_context(); - const ugid::SetResetGuard ugid(fc->uid,fc->gid); - const rwlock::ReadGuard readlock(&config.srcmountslock); + const ugid::SetResetGuard ugid(fc->uid,fc->gid); + const rwlock::ReadGuard readlock(&config.srcmountslock); return _getxattr(config.getxattr, config.srcmounts, diff --git a/src/init.cpp b/src/init.cpp index c4839235..e91ca6c9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -31,13 +31,13 @@ namespace mergerfs namespace fuse { void * - init(struct fuse_conn_info *conn) + init(fuse_conn_info *conn) { #ifdef FUSE_CAP_IOCTL_DIR conn->want |= FUSE_CAP_IOCTL_DIR; #endif - return &config::get_writable(); + return &Config::get_writable(); } } } diff --git a/src/init.hpp b/src/init.hpp index d7747736..692afb4b 100644 --- a/src/init.hpp +++ b/src/init.hpp @@ -27,6 +27,6 @@ namespace mergerfs namespace fuse { void * - init(struct fuse_conn_info *conn); + init(fuse_conn_info *conn); } } diff --git a/src/ioctl.cpp b/src/ioctl.cpp index 5e5887dd..9ef0d1e4 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -98,8 +98,8 @@ _ioctl_dir(const string &fusepath, const int cmd, void *data) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(fc); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); @@ -117,12 +117,12 @@ namespace mergerfs namespace fuse { int - ioctl(const char *fusepath, - int cmd, - void *arg, - struct fuse_file_info *ffi, - unsigned int flags, - void *data) + ioctl(const char *fusepath, + int cmd, + void *arg, + fuse_file_info *ffi, + unsigned int flags, + void *data) { #ifdef FUSE_IOCTL_DIR if(flags & FUSE_IOCTL_DIR) diff --git a/src/ioctl.hpp b/src/ioctl.hpp index 18da1324..b746d8b5 100644 --- a/src/ioctl.hpp +++ b/src/ioctl.hpp @@ -27,11 +27,11 @@ namespace mergerfs namespace fuse { int - ioctl(const char *fusepath, - int cmd, - void *arg, - struct fuse_file_info *fi, - unsigned int flags, - void *data); + ioctl(const char *fusepath, + int cmd, + void *arg, + fuse_file_info *fi, + unsigned int flags, + void *data); } } diff --git a/src/link.cpp b/src/link.cpp index 87b30907..d8e7733c 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -110,8 +110,8 @@ namespace mergerfs link(const char *from, const char *to) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/listxattr.cpp b/src/listxattr.cpp index 6e078952..7d71b6c2 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -109,12 +109,12 @@ namespace mergerfs char *list, size_t size) { - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); if(fusepath == config.controlfile) return _listxattr_controlfile(list,size); - const struct fuse_context *fc = fuse_get_context(); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index 145cb554..e27b5894 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -168,9 +168,9 @@ namespace mergerfs main(const int argc, char **argv) { - struct fuse_args args; - struct fuse_operations ops = {0}; - mergerfs::config::Config config; + fuse_args args; + fuse_operations ops = {0}; + Config config; args.argc = argc; args.argv = argv; diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 35fb91dd..1ddb3bbc 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -94,8 +94,8 @@ namespace mergerfs mkdir(const char *fusepath, mode_t mode) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/mknod.cpp b/src/mknod.cpp index c63bfa39..9a8f2504 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -97,8 +97,8 @@ namespace mergerfs mode_t mode, dev_t rdev) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/open.cpp b/src/open.cpp index 4bb2ea6c..08a8c3da 100644 --- a/src/open.cpp +++ b/src/open.cpp @@ -73,11 +73,11 @@ namespace mergerfs namespace fuse { int - open(const char *fusepath, - struct fuse_file_info *fileinfo) + open(const char *fusepath, + fuse_file_info *fileinfo) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/open.hpp b/src/open.hpp index 07d002d2..753f9093 100644 --- a/src/open.hpp +++ b/src/open.hpp @@ -29,7 +29,7 @@ namespace mergerfs namespace fuse { int - open(const char *fusepath, - struct fuse_file_info *fileinfo); + open(const char *fusepath, + fuse_file_info *fileinfo); } } diff --git a/src/opendir.cpp b/src/opendir.cpp index 9a20f5e6..c11ae5ca 100644 --- a/src/opendir.cpp +++ b/src/opendir.cpp @@ -29,8 +29,8 @@ namespace mergerfs namespace fuse { int - opendir(const char *fusepath, - struct fuse_file_info *ffi) + opendir(const char *fusepath, + fuse_file_info *ffi) { ffi->fh = 0; diff --git a/src/opendir.hpp b/src/opendir.hpp index e5bf6193..11cf1546 100644 --- a/src/opendir.hpp +++ b/src/opendir.hpp @@ -29,7 +29,7 @@ namespace mergerfs namespace fuse { int - opendir(const char *fusepath, - struct fuse_file_info *ffi); + opendir(const char *fusepath, + fuse_file_info *ffi); } } diff --git a/src/option_parser.cpp b/src/option_parser.cpp index ef355a7e..c960e402 100644 --- a/src/option_parser.cpp +++ b/src/option_parser.cpp @@ -45,7 +45,7 @@ using namespace mergerfs; static void -set_option(struct fuse_args &args, +set_option(fuse_args &args, const std::string &option_) { string option; @@ -57,7 +57,7 @@ set_option(struct fuse_args &args, static void -set_kv_option(struct fuse_args &args, +set_kv_option(fuse_args &args, const std::string &key, const std::string &value) { @@ -70,7 +70,7 @@ set_kv_option(struct fuse_args &args, static void -set_fsname(struct fuse_args &args, +set_fsname(fuse_args &args, const vector &srcmounts) { if(srcmounts.size() > 0) @@ -85,14 +85,14 @@ set_fsname(struct fuse_args &args, static void -set_subtype(struct fuse_args &args) +set_subtype(fuse_args &args) { set_kv_option(args,"subtype","mergerfs"); } static void -set_default_options(struct fuse_args &args) +set_default_options(fuse_args &args) { set_option(args,"big_writes"); set_option(args,"splice_read"); @@ -118,9 +118,9 @@ parse_and_process_minfreespace(const std::string &value, static int -parse_and_process_arg(config::Config &config, +parse_and_process_arg(Config &config, const std::string &arg, - struct fuse_args *outargs) + fuse_args *outargs) { if(arg == "defaults") { @@ -133,7 +133,7 @@ parse_and_process_arg(config::Config &config, static int -parse_and_process_kv_arg(config::Config &config, +parse_and_process_kv_arg(Config &config, const std::string &key, const std::string &value) { @@ -162,9 +162,9 @@ parse_and_process_kv_arg(config::Config &config, static int -process_opt(config::Config &config, +process_opt(Config &config, const std::string &arg, - struct fuse_args *outargs) + fuse_args *outargs) { int rv; std::vector argvalue; @@ -191,8 +191,8 @@ process_opt(config::Config &config, static int -process_srcmounts(const char *arg, - config::Config &config) +process_srcmounts(const char *arg, + Config &config) { vector paths; @@ -205,8 +205,8 @@ process_srcmounts(const char *arg, static int -process_destmounts(const char *arg, - config::Config &config) +process_destmounts(const char *arg, + Config &config) { config.destmount = arg; @@ -215,13 +215,13 @@ process_destmounts(const char *arg, static int -option_processor(void *data, - const char *arg, - int key, - struct fuse_args *outargs) +option_processor(void *data, + const char *arg, + int key, + fuse_args *outargs) { - int rv = 0; - config::Config &config = *(config::Config*)data; + int rv = 0; + Config &config = *(Config*)data; switch(key) { @@ -247,8 +247,8 @@ namespace mergerfs namespace options { void - parse(struct fuse_args &args, - config::Config &config) + parse(fuse_args &args, + Config &config) { fuse_opt_parse(&args, diff --git a/src/option_parser.hpp b/src/option_parser.hpp index 2dc1928b..b554be0c 100644 --- a/src/option_parser.hpp +++ b/src/option_parser.hpp @@ -31,7 +31,7 @@ namespace mergerfs namespace options { void - parse(struct fuse_args &args, - mergerfs::config::Config &config); + parse(fuse_args &args, + Config &config); } } diff --git a/src/policy_all.cpp b/src/policy_all.cpp index e939d24a..a92b9c27 100644 --- a/src/policy_all.cpp +++ b/src/policy_all.cpp @@ -48,9 +48,8 @@ _all(const vector &basepaths, for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - const char *basepath; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = ::lstat(fullpath.c_str(),&st); @@ -58,7 +57,23 @@ _all(const vector &basepaths, paths.push_back(basepath); } - return paths.empty() ? (errno=ENOENT,-1) : 0; + if(paths.empty()) + return (errno=ENOENT,-1); + + return 0; +} + +static +int +_all_create(const vector &basepaths, + vector &paths) +{ + if(basepaths.empty()) + return (errno=ENOENT,-1); + + paths = basepaths; + + return 0; } namespace mergerfs @@ -70,6 +85,9 @@ namespace mergerfs const size_t minfreespace, vector &paths) { + if(type == Category::Enum::create) + return _all_create(basepaths,paths); + return _all(basepaths,fusepath,paths); } } diff --git a/src/policy_epmfs.cpp b/src/policy_epmfs.cpp index 80caeb3c..3ccb92b8 100644 --- a/src/policy_epmfs.cpp +++ b/src/policy_epmfs.cpp @@ -40,12 +40,12 @@ using std::size_t; static inline void -_calc_epmfs(const struct statvfs &fsstats, - const char *basepath, - fsblkcnt_t &epmfs, - const char *&epmfsbasepath, - fsblkcnt_t &mfs, - const char *&mfsbasepath) +_calc_epmfs(const struct statvfs &fsstats, + const string &basepath, + fsblkcnt_t &epmfs, + string &epmfsbasepath, + fsblkcnt_t &mfs, + string &mfsbasepath) { fsblkcnt_t spaceavail; @@ -66,10 +66,10 @@ _calc_epmfs(const struct statvfs &fsstats, static inline void -_calc_mfs(const struct statvfs &fsstats, - const char *basepath, - fsblkcnt_t &mfs, - const char *&mfsbasepath) +_calc_mfs(const struct statvfs &fsstats, + const string &basepath, + fsblkcnt_t &mfs, + string &mfsbasepath) { fsblkcnt_t spaceavail; @@ -84,12 +84,12 @@ _calc_mfs(const struct statvfs &fsstats, static inline int -_try_statvfs(const char *basepath, - const string &fullpath, - fsblkcnt_t &epmfs, - const char *&epmfsbasepath, - fsblkcnt_t &mfs, - const char *&mfsbasepath) +_try_statvfs(const string &basepath, + const string &fullpath, + fsblkcnt_t &epmfs, + string &epmfsbasepath, + fsblkcnt_t &mfs, + string &mfsbasepath) { int rv; struct statvfs fsstats; @@ -104,14 +104,14 @@ _try_statvfs(const char *basepath, static inline int -_try_statvfs(const char *basepath, - fsblkcnt_t &mfs, - const char *&mfsbasepath) +_try_statvfs(const string &basepath, + fsblkcnt_t &mfs, + string &mfsbasepath) { int rv; struct statvfs fsstats; - rv = ::statvfs(basepath,&fsstats); + rv = ::statvfs(basepath.c_str(),&fsstats); if(rv == 0) _calc_mfs(fsstats,basepath,mfs,mfsbasepath); @@ -125,22 +125,19 @@ _epmfs_create(const vector &basepaths, vector &paths) { - fsblkcnt_t epmfs; - fsblkcnt_t mfs; - const char *basepath; - const char *mfsbasepath; - const char *epmfsbasepath; - string fullpath; + fsblkcnt_t epmfs; + fsblkcnt_t mfs; + string mfsbasepath; + string epmfsbasepath; + string fullpath; mfs = 0; epmfs = 0; - mfsbasepath = NULL; - epmfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath); @@ -148,7 +145,7 @@ _epmfs_create(const vector &basepaths, _try_statvfs(basepath,mfs,mfsbasepath); } - if(epmfsbasepath == NULL) + if(epmfsbasepath.empty()) epmfsbasepath = mfsbasepath; paths.push_back(epmfsbasepath); @@ -163,19 +160,17 @@ _epmfs(const vector &basepaths, vector &paths) { - fsblkcnt_t epmfs; - const char *basepath; - const char *epmfsbasepath; - string fullpath; + fsblkcnt_t epmfs; + string epmfsbasepath; + string fullpath; epmfs = 0; - epmfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = ::statvfs(fullpath.c_str(),&fsstats); @@ -183,7 +178,7 @@ _epmfs(const vector &basepaths, _calc_mfs(fsstats,basepath,epmfs,epmfsbasepath); } - if(epmfsbasepath == NULL) + if(epmfsbasepath.empty()) return (errno=ENOENT,-1); paths.push_back(epmfsbasepath); diff --git a/src/policy_ff.cpp b/src/policy_ff.cpp index 929d42be..04900b43 100644 --- a/src/policy_ff.cpp +++ b/src/policy_ff.cpp @@ -45,12 +45,11 @@ _ff(const vector &basepaths, { for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - int rv; - struct stat st; - const char *basepath; - string fullpath; + int rv; + struct stat st; + string fullpath; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = ::lstat(fullpath.c_str(),&st); @@ -65,6 +64,20 @@ _ff(const vector &basepaths, return (errno=ENOENT,-1); } +static +int +_ff_create(const vector &basepaths, + const string &fusepath, + vector &paths) +{ + if(basepaths.empty()) + return (errno=ENOENT,-1); + + paths.push_back(basepaths[0]); + + return 0; +} + namespace mergerfs { int @@ -74,6 +87,9 @@ namespace mergerfs const size_t minfreespace, vector &paths) { + if(type == Category::Enum::create) + return _ff_create(basepaths,fusepath,paths); + return _ff(basepaths,fusepath,paths); } } diff --git a/src/policy_ffwp.cpp b/src/policy_ffwp.cpp index 154876fc..2643969b 100644 --- a/src/policy_ffwp.cpp +++ b/src/policy_ffwp.cpp @@ -42,17 +42,15 @@ _ffwp(const vector &basepaths, const string &fusepath, vector &paths) { - const char *fallback; + string fallback; - fallback = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - int rv; - struct stat st; - const char *basepath; - string fullpath; + int rv; + struct stat st; + string fullpath; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = ::lstat(fullpath.c_str(),&st); @@ -67,7 +65,7 @@ _ffwp(const vector &basepaths, } } - if(fallback == NULL) + if(fallback.empty()) return (errno=ENOENT,-1); paths.push_back(fallback); diff --git a/src/policy_fwfs.cpp b/src/policy_fwfs.cpp index ccc77b16..68dd3377 100644 --- a/src/policy_fwfs.cpp +++ b/src/policy_fwfs.cpp @@ -47,11 +47,10 @@ _fwfs_create(const Category::Enum::Type type, for(size_t i = 0, size = basepaths.size(); i != size; i++) { int rv; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); - rv = ::statvfs(basepath,&fsstats); + rv = ::statvfs(basepath.c_str(),&fsstats); if(rv == 0) { fsblkcnt_t spaceavail; @@ -81,11 +80,11 @@ _fwfs(const Category::Enum::Type type, { int rv; string fullpath; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); + rv = ::statvfs(fullpath.c_str(),&fsstats); if(rv == 0) { diff --git a/src/policy_lfs.cpp b/src/policy_lfs.cpp index 8ec98772..ce94a20b 100644 --- a/src/policy_lfs.cpp +++ b/src/policy_lfs.cpp @@ -47,19 +47,17 @@ _lfs_create(const Category::Enum::Type type, const size_t minfreespace, vector &paths) { - fsblkcnt_t lfs; - const char *lfsstr; + fsblkcnt_t lfs; + string lfsstr; lfs = -1; - lfsstr = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); - rv = ::statvfs(basepath,&fsstats); + rv = ::statvfs(basepath.c_str(),&fsstats); if(rv == 0) { fsblkcnt_t spaceavail; @@ -74,7 +72,7 @@ _lfs_create(const Category::Enum::Type type, } } - if(lfsstr == NULL) + if(lfsstr.empty()) return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths); paths.push_back(lfsstr); @@ -90,20 +88,19 @@ _lfs(const Category::Enum::Type type, const size_t minfreespace, vector &paths) { - fsblkcnt_t lfs; - const char *lfsstr; + fsblkcnt_t lfs; + string lfsstr; lfs = -1; - lfsstr = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; string fullpath; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); + rv = ::statvfs(fullpath.c_str(),&fsstats); if(rv == 0) { @@ -119,7 +116,7 @@ _lfs(const Category::Enum::Type type, } } - if(lfsstr == NULL) + if(lfsstr.empty()) return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths); paths.push_back(lfsstr); diff --git a/src/policy_mfs.cpp b/src/policy_mfs.cpp index b13d7722..f33bd622 100644 --- a/src/policy_mfs.cpp +++ b/src/policy_mfs.cpp @@ -40,19 +40,17 @@ _mfs_create(const vector &basepaths, const string &fusepath, vector &paths) { - fsblkcnt_t mfs; - const char *mfsstr; + fsblkcnt_t mfs; + string mfsstr; mfs = 0; - mfsstr = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); - rv = ::statvfs(basepath,&fsstats); + rv = ::statvfs(basepath.c_str(),&fsstats); if(rv == 0) { fsblkcnt_t spaceavail; @@ -66,7 +64,7 @@ _mfs_create(const vector &basepaths, } } - if(mfsstr == NULL) + if(mfsstr.empty()) return (errno=ENOENT,-1); paths.push_back(mfsstr); @@ -80,20 +78,19 @@ _mfs(const vector &basepaths, const string &fusepath, vector &paths) { - fsblkcnt_t mfs; - const char *mfsstr; + fsblkcnt_t mfs; + string mfsstr; mfs = 0; - mfsstr = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { int rv; string fullpath; - const char *basepath; struct statvfs fsstats; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); + rv = ::statvfs(fullpath.c_str(),&fsstats); if(rv == 0) { @@ -108,7 +105,7 @@ _mfs(const vector &basepaths, } } - if(mfsstr == NULL) + if(mfsstr.empty()) return (errno=ENOENT,-1); paths.push_back(mfsstr); diff --git a/src/policy_newest.cpp b/src/policy_newest.cpp index 27f2deae..dedf808a 100644 --- a/src/policy_newest.cpp +++ b/src/policy_newest.cpp @@ -43,17 +43,16 @@ _newest(const vector &basepaths, const string &fusepath, vector &paths) { - time_t newest = std::numeric_limits::min(); - const char *neweststr = NULL; + time_t newest = std::numeric_limits::min(); + string neweststr; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - int rv; - struct stat st; - const char *basepath; - string fullpath; + int rv; + struct stat st; + string fullpath; + const string &basepath = basepaths[i]; - basepath = basepaths[i].c_str(); fullpath = fs::path::make(basepath,fusepath); rv = ::lstat(fullpath.c_str(),&st); @@ -64,7 +63,7 @@ _newest(const vector &basepaths, } } - if(neweststr == NULL) + if(neweststr.empty()) return (errno=ENOENT,-1); paths.push_back(neweststr); diff --git a/src/read.cpp b/src/read.cpp index bb9fbc10..57b3ac59 100644 --- a/src/read.cpp +++ b/src/read.cpp @@ -49,11 +49,11 @@ namespace mergerfs namespace fuse { int - read(const char *fusepath, - char *buf, - size_t count, - off_t offset, - struct fuse_file_info *ffi) + read(const char *fusepath, + char *buf, + size_t count, + off_t offset, + fuse_file_info *ffi) { return _read(ffi->fh, buf, diff --git a/src/read.hpp b/src/read.hpp index f146f9e5..f672f19d 100644 --- a/src/read.hpp +++ b/src/read.hpp @@ -27,10 +27,10 @@ namespace mergerfs namespace fuse { int - read(const char *fusepath, - char *buf, - size_t count, - off_t offset, - struct fuse_file_info *fi); + read(const char *fusepath, + char *buf, + size_t count, + off_t offset, + fuse_file_info *fi); } } diff --git a/src/read_buf.cpp b/src/read_buf.cpp index e7f7cca6..0b189942 100644 --- a/src/read_buf.cpp +++ b/src/read_buf.cpp @@ -32,14 +32,14 @@ static int -_read_buf(const int fd, - struct fuse_bufvec **bufp, - const size_t size, - const off_t offset) +_read_buf(const int fd, + fuse_bufvec **bufp, + const size_t size, + const off_t offset) { - struct fuse_bufvec *src; + fuse_bufvec *src; - src = (fuse_bufvec*)malloc(sizeof(struct fuse_bufvec)); + src = (fuse_bufvec*)malloc(sizeof(fuse_bufvec)); if(src == NULL) return -ENOMEM; @@ -59,11 +59,11 @@ namespace mergerfs namespace fuse { int - read_buf(const char *fusepath, - struct fuse_bufvec **bufp, - size_t size, - off_t offset, - struct fuse_file_info *ffi) + read_buf(const char *fusepath, + fuse_bufvec **bufp, + size_t size, + off_t offset, + fuse_file_info *ffi) { return _read_buf(ffi->fh, bufp, diff --git a/src/read_buf.hpp b/src/read_buf.hpp index 1ec4021a..76b89b7a 100644 --- a/src/read_buf.hpp +++ b/src/read_buf.hpp @@ -27,10 +27,10 @@ namespace mergerfs namespace fuse { int - read_buf(const char *fusepath, - struct fuse_bufvec **buf, - size_t size, - off_t offset, - struct fuse_file_info *fi); + read_buf(const char *fusepath, + fuse_bufvec **buf, + size_t size, + off_t offset, + fuse_file_info *fi); } } diff --git a/src/readdir.cpp b/src/readdir.cpp index 7892a20c..77826ef2 100644 --- a/src/readdir.cpp +++ b/src/readdir.cpp @@ -90,14 +90,14 @@ namespace mergerfs namespace fuse { int - readdir(const char *fusepath, - void *buf, - fuse_fill_dir_t filler, - off_t offset, - struct fuse_file_info *fi) + readdir(const char *fusepath, + void *buf, + fuse_fill_dir_t filler, + off_t offset, + fuse_file_info *fi) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/readdir.hpp b/src/readdir.hpp index 395337d4..69e222d7 100644 --- a/src/readdir.hpp +++ b/src/readdir.hpp @@ -39,11 +39,11 @@ namespace mergerfs namespace fuse { int - readdir(const char *fusepath, - void *buf, - fuse_fill_dir_t filler, - off_t offset, - struct fuse_file_info *fi); + readdir(const char *fusepath, + void *buf, + fuse_fill_dir_t filler, + off_t offset, + fuse_file_info *fi); } } diff --git a/src/readlink.cpp b/src/readlink.cpp index 99ce4bfa..08e8b7ce 100644 --- a/src/readlink.cpp +++ b/src/readlink.cpp @@ -75,8 +75,8 @@ namespace mergerfs char *buf, size_t size) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/release.cpp b/src/release.cpp index 2fb58f2f..59e0f3b7 100644 --- a/src/release.cpp +++ b/src/release.cpp @@ -45,8 +45,8 @@ namespace mergerfs namespace fuse { int - release(const char *fusepath, - struct fuse_file_info *ffi) + release(const char *fusepath, + fuse_file_info *ffi) { return _release(ffi->fh); } diff --git a/src/release.hpp b/src/release.hpp index fee3aecc..1bcfeced 100644 --- a/src/release.hpp +++ b/src/release.hpp @@ -27,7 +27,7 @@ namespace mergerfs namespace fuse { int - release(const char *fusepath, - struct fuse_file_info *fi); + release(const char *fusepath, + fuse_file_info *fi); } } diff --git a/src/releasedir.cpp b/src/releasedir.cpp index 179eb6cf..e130e514 100644 --- a/src/releasedir.cpp +++ b/src/releasedir.cpp @@ -29,8 +29,8 @@ namespace mergerfs namespace fuse { int - releasedir(const char *fusepath, - struct fuse_file_info *ffi) + releasedir(const char *fusepath, + fuse_file_info *ffi) { return 0; } diff --git a/src/releasedir.hpp b/src/releasedir.hpp index 61df8f64..4f76e32f 100644 --- a/src/releasedir.hpp +++ b/src/releasedir.hpp @@ -29,7 +29,7 @@ namespace mergerfs namespace fuse { int - releasedir(const char *fusepath, - struct fuse_file_info *ffi); + releasedir(const char *fusepath, + fuse_file_info *ffi); } } diff --git a/src/removexattr.cpp b/src/removexattr.cpp index ae8bc4ad..3b1cfca5 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -81,14 +81,14 @@ namespace mergerfs removexattr(const char *fusepath, const char *attrname) { - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); if(fusepath == config.controlfile) return -ENOTSUP; - const struct fuse_context *fc = fuse_get_context(); - const ugid::SetResetGuard ugid(fc->uid,fc->gid); - const rwlock::ReadGuard readlock(&config.srcmountslock); + const ugid::SetResetGuard ugid(fc->uid,fc->gid); + const rwlock::ReadGuard readlock(&config.srcmountslock); return _removexattr(config.removexattr, config.srcmounts, diff --git a/src/rename.cpp b/src/rename.cpp index 7864ec20..7eee0f67 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -113,8 +113,8 @@ namespace mergerfs rename(const char *oldpath, const char *newpath) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/rmdir.cpp b/src/rmdir.cpp index c6690888..30b94af1 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -73,8 +73,8 @@ namespace mergerfs int rmdir(const char *fusepath) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readguard(&config.srcmountslock); diff --git a/src/setxattr.cpp b/src/setxattr.cpp index 0075d0e3..68d26cff 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -168,9 +168,9 @@ _setxattr_srcmounts(vector &srcmounts, static int -_setxattr_minfreespace(config::Config &config, - const string &attrval, - const int flags) +_setxattr_minfreespace(Config &config, + const string &attrval, + const int flags) { int rv; @@ -186,10 +186,10 @@ _setxattr_minfreespace(config::Config &config, static int -_setxattr_controlfile_func_policy(config::Config &config, - const char *funcname, - const string &attrval, - const int flags) +_setxattr_controlfile_func_policy(Config &config, + const char *funcname, + const string &attrval, + const int flags) { int rv; @@ -205,10 +205,10 @@ _setxattr_controlfile_func_policy(config::Config &config, static int -_setxattr_controlfile_category_policy(config::Config &config, - const char *categoryname, - const string &attrval, - const int flags) +_setxattr_controlfile_category_policy(Config &config, + const char *categoryname, + const string &attrval, + const int flags) { int rv; @@ -224,10 +224,10 @@ _setxattr_controlfile_category_policy(config::Config &config, static int -_setxattr_controlfile(config::Config &config, - const char *attrname, - const string &attrval, - const int flags) +_setxattr_controlfile(Config &config, + const char *attrname, + const string &attrval, + const int flags) { const char *attrbasename = &attrname[sizeof("user.mergerfs.")-1]; @@ -307,33 +307,31 @@ namespace mergerfs size_t attrvalsize, int flags) { - const config::Config &config = config::get(); - const struct fuse_context *fc = fuse_get_context(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); if(fusepath == config.controlfile) { if((fc->uid != ::getuid()) && (fc->gid != ::getgid())) return -EPERM; - return _setxattr_controlfile(config::get_writable(), + return _setxattr_controlfile(Config::get_writable(), attrname, string(attrval,attrvalsize), flags); } - { - const ugid::SetResetGuard ugid(fc->uid,fc->gid); - const rwlock::ReadGuard readlock(&config.srcmountslock); - - return _setxattr(config.setxattr, - config.srcmounts, - config.minfreespace, - fusepath, - attrname, - attrval, - attrvalsize, - flags); - } + const ugid::SetResetGuard ugid(fc->uid,fc->gid); + const rwlock::ReadGuard readlock(&config.srcmountslock); + + return _setxattr(config.setxattr, + config.srcmounts, + config.minfreespace, + fusepath, + attrname, + attrval, + attrvalsize, + flags); } } } diff --git a/src/statfs.cpp b/src/statfs.cpp index 2d238fe4..7c9a3827 100644 --- a/src/statfs.cpp +++ b/src/statfs.cpp @@ -124,8 +124,8 @@ namespace mergerfs statfs(const char *fusepath, struct statvfs *stat) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/symlink.cpp b/src/symlink.cpp index b8f5f8b6..e20ff9c1 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -77,8 +77,8 @@ namespace mergerfs symlink(const char *oldpath, const char *newpath) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/truncate.cpp b/src/truncate.cpp index 86933998..ab99bd30 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -77,8 +77,8 @@ namespace mergerfs truncate(const char *fusepath, off_t size) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/unlink.cpp b/src/unlink.cpp index 1dbfa690..108dfc51 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -74,8 +74,8 @@ namespace mergerfs int unlink(const char *fusepath) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/utimens.cpp b/src/utimens.cpp index 2bdbfeed..f75c5ff5 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -42,11 +42,11 @@ using mergerfs::Policy; static int -_utimens(Policy::Func::Action actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const struct timespec ts[2]) +_utimens(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const timespec ts[2]) { int rv; int error; @@ -74,11 +74,11 @@ namespace mergerfs namespace fuse { int - utimens(const char *fusepath, - const struct timespec ts[2]) + utimens(const char *fusepath, + const timespec ts[2]) { - const struct fuse_context *fc = fuse_get_context(); - const config::Config &config = config::get(); + const fuse_context *fc = fuse_get_context(); + const Config &config = Config::get(fc); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); diff --git a/src/utimens.hpp b/src/utimens.hpp index 61af02fc..e141dc19 100644 --- a/src/utimens.hpp +++ b/src/utimens.hpp @@ -27,7 +27,7 @@ namespace mergerfs namespace fuse { int - utimens(const char *fusepath, - const struct timespec ts[2]); + utimens(const char *fusepath, + const timespec ts[2]); } } diff --git a/src/write.cpp b/src/write.cpp index 68faf2ef..08fdfc9e 100644 --- a/src/write.cpp +++ b/src/write.cpp @@ -46,11 +46,11 @@ namespace mergerfs namespace fuse { int - write(const char *fusepath, - const char *buf, - size_t count, - off_t offset, - struct fuse_file_info *ffi) + write(const char *fusepath, + const char *buf, + size_t count, + off_t offset, + fuse_file_info *ffi) { return _write(ffi->fh, buf, diff --git a/src/write.hpp b/src/write.hpp index b4706baf..ab035acd 100644 --- a/src/write.hpp +++ b/src/write.hpp @@ -27,10 +27,10 @@ namespace mergerfs namespace fuse { int - write(const char *fusepath, - const char *buf, - size_t count, - off_t offset, - struct fuse_file_info *fi); + write(const char *fusepath, + const char *buf, + size_t count, + off_t offset, + fuse_file_info *fi); } } diff --git a/src/write_buf.cpp b/src/write_buf.cpp index 07bc3e06..328c3c7e 100644 --- a/src/write_buf.cpp +++ b/src/write_buf.cpp @@ -32,12 +32,12 @@ static int -_write_buf(const int fd, - struct fuse_bufvec &src, - const off_t offset) +_write_buf(const int fd, + fuse_bufvec &src, + const off_t offset) { - size_t size = fuse_buf_size(&src); - struct fuse_bufvec dst = FUSE_BUFVEC_INIT(size); + size_t size = fuse_buf_size(&src); + fuse_bufvec dst = FUSE_BUFVEC_INIT(size); const fuse_buf_copy_flags cpflags = (fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK); @@ -53,10 +53,10 @@ namespace mergerfs namespace fuse { int - write_buf(const char *fusepath, - struct fuse_bufvec *src, - off_t offset, - struct fuse_file_info *ffi) + write_buf(const char *fusepath, + fuse_bufvec *src, + off_t offset, + fuse_file_info *ffi) { return _write_buf(ffi->fh, *src, diff --git a/src/write_buf.hpp b/src/write_buf.hpp index d539c2b8..8bbae088 100644 --- a/src/write_buf.hpp +++ b/src/write_buf.hpp @@ -27,9 +27,9 @@ namespace mergerfs namespace fuse { int - write_buf(const char *fusepath, - struct fuse_bufvec *buf, - off_t offset, - struct fuse_file_info *fi); + write_buf(const char *fusepath, + fuse_bufvec *buf, + off_t offset, + fuse_file_info *fi); } }