From 51b6d3f6475ad7cf05c13bf7f281ebe7a172bc42 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 25 Jun 2015 17:55:16 -0400 Subject: [PATCH] add category to policies so as to distinguish between creates and searches --- src/access.cpp | 13 +++--- src/chmod.cpp | 12 ++--- src/chown.cpp | 14 +++--- src/create.cpp | 20 ++++---- src/getattr.cpp | 12 ++--- src/getxattr.cpp | 16 +++---- src/ioctl.cpp | 18 +++---- src/link.cpp | 28 +++++------ src/listxattr.cpp | 14 +++--- src/mkdir.cpp | 16 +++---- src/mknod.cpp | 18 +++---- src/open.cpp | 14 +++--- src/policy.hpp | 103 ++++++++++++++++++++++++++++++++--------- src/policy_all.cpp | 9 ++-- src/policy_epmfs.cpp | 9 ++-- src/policy_ff.cpp | 9 ++-- src/policy_ffwp.cpp | 9 ++-- src/policy_fwfs.cpp | 11 +++-- src/policy_invalid.cpp | 9 ++-- src/policy_lfs.cpp | 11 +++-- src/policy_mfs.cpp | 9 ++-- src/policy_newest.cpp | 9 ++-- src/policy_rand.cpp | 11 +++-- src/readlink.cpp | 14 +++--- src/removexattr.cpp | 12 ++--- src/rename.cpp | 26 +++++------ src/rmdir.cpp | 10 ++-- src/setxattr.cpp | 18 +++---- src/symlink.cpp | 12 ++--- src/truncate.cpp | 12 ++--- src/unlink.cpp | 10 ++-- src/utimens.cpp | 12 ++--- 32 files changed, 294 insertions(+), 226 deletions(-) diff --git a/src/access.cpp b/src/access.cpp index 86418d94..15b45be4 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -42,14 +42,15 @@ using std::string; using std::vector; using mergerfs::Policy; +using mergerfs::Category; static int -_access(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const int mask) +_access(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const int mask) { int rv; Paths paths; @@ -76,7 +77,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _access(*config.access, + return _access(config.access, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/chmod.cpp b/src/chmod.cpp index ecd57ae4..a37ffd3d 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -39,11 +39,11 @@ using mergerfs::Policy; static int -_chmod(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const mode_t mode) +_chmod(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const mode_t mode) { int rv; int error; @@ -78,7 +78,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _chmod(*config.chmod, + return _chmod(config.chmod, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/chown.cpp b/src/chown.cpp index 19469d6a..9aac1735 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -40,12 +40,12 @@ using mergerfs::Policy; static int -_chown(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const uid_t uid, - const gid_t gid) +_chown(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const uid_t uid, + const gid_t gid) { int rv; int error; @@ -81,7 +81,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _chown(*config.chown, + return _chown(config.chown, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/create.cpp b/src/create.cpp index 80a1a836..18c2e42f 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -43,14 +43,14 @@ using mergerfs::Policy; static int -_create(const Policy::Func::Ptr searchFunc, - const Policy::Func::Ptr createFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const mode_t mode, - const int flags, - uint64_t &fh) +_create(Policy::Func::Search searchFunc, + Policy::Func::Create createFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const mode_t mode, + const int flags, + uint64_t &fh) { int fd; int rv; @@ -99,8 +99,8 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _create(*config.getattr, - *config.create, + return _create(config.getattr, + config.create, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/getattr.cpp b/src/getattr.cpp index fd471c5b..cdea50b6 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -66,11 +66,11 @@ _getattr_controlfile(struct stat &buf) static int -_getattr(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - struct stat &buf) +_getattr(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + struct stat &buf) { int rv; Paths path; @@ -101,7 +101,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _getattr(*config.getattr, + return _getattr(config.getattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/getxattr.cpp b/src/getxattr.cpp index 9f277e90..9ae45c6b 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -190,13 +190,13 @@ _getxattr_user_mergerfs(const Path &path, static int -_getxattr(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const char *attrname, - char *buf, - const size_t count) +_getxattr(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const char *attrname, + char *buf, + const size_t count) { #ifndef WITHOUT_XATTR int rv; @@ -239,7 +239,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _getxattr(*config.getxattr, + return _getxattr(config.getxattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/ioctl.cpp b/src/ioctl.cpp index 41947431..258594ab 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -82,14 +82,14 @@ _ioctl(const int fd, #ifdef FUSE_IOCTL_DIR static int -_ioctl_dir_base(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const int cmd, - void *arg, - const unsigned int flags, - void *data) +_ioctl_dir_base(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const int cmd, + void *arg, + const unsigned int flags, + void *data) { int fd; int rv; @@ -123,7 +123,7 @@ _ioctl_dir(const string &fusepath, const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _ioctl_dir_base(*config.getattr, + return _ioctl_dir_base(config.getattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/link.cpp b/src/link.cpp index 8f53a18c..41cd7ac2 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -41,12 +41,12 @@ using mergerfs::Policy; static int -_single_link(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &base, - const string &oldpath, - const string &newpath) +_single_link(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &base, + const string &oldpath, + const string &newpath) { int rv; const string fulloldpath = fs::make_path(base,oldpath); @@ -76,12 +76,12 @@ _single_link(const Policy::Func::Ptr searchFunc, static int -_link(const Policy::Func::Ptr searchFunc, - const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &oldpath, - const string &newpath) +_link(Policy::Func::Search searchFunc, + Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &oldpath, + const string &newpath) { int rv; int error; @@ -116,8 +116,8 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _link(*config.getattr, - *config.link, + return _link(config.getattr, + config.link, config.srcmounts, config.minfreespace, from, diff --git a/src/listxattr.cpp b/src/listxattr.cpp index 59428cc8..41490dfb 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -69,12 +69,12 @@ _listxattr_controlfile(char *list, static int -_listxattr(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - char *list, - const size_t size) +_listxattr(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + char *list, + const size_t size) { #ifndef WITHOUT_XATTR int rv; @@ -110,7 +110,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _listxattr(*config.listxattr, + return _listxattr(config.listxattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/mkdir.cpp b/src/mkdir.cpp index fb8caf23..66193a79 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -42,12 +42,12 @@ using mergerfs::Policy; static int -_mkdir(const Policy::Func::Ptr searchFunc, - const Policy::Func::Ptr createFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const mode_t mode) +_mkdir(Policy::Func::Search searchFunc, + Policy::Func::Create createFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const mode_t mode) { int rv; int error; @@ -98,8 +98,8 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _mkdir(*config.getattr, - *config.mkdir, + return _mkdir(config.getattr, + config.mkdir, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/mknod.cpp b/src/mknod.cpp index 21ab3f7d..2340aba3 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -44,13 +44,13 @@ using mergerfs::Policy; static int -_mknod(const Policy::Func::Ptr searchFunc, - const Policy::Func::Ptr createFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const mode_t mode, - const dev_t dev) +_mknod(Policy::Func::Search searchFunc, + Policy::Func::Create createFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const mode_t mode, + const dev_t dev) { int rv; int error; @@ -102,8 +102,8 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _mknod(*config.getattr, - *config.mknod, + return _mknod(config.getattr, + config.mknod, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/open.cpp b/src/open.cpp index b06cec3d..c177b56e 100644 --- a/src/open.cpp +++ b/src/open.cpp @@ -42,12 +42,12 @@ using mergerfs::Policy; static int -_open(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const int flags, - uint64_t &fh) +_open(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const int flags, + uint64_t &fh) { int fd; int rv; @@ -79,7 +79,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _open(*config.open, + return _open(config.open, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/policy.hpp b/src/policy.hpp index a40b069c..6adf06d7 100644 --- a/src/policy.hpp +++ b/src/policy.hpp @@ -31,6 +31,7 @@ #include "path.hpp" #include "fs.hpp" +#include "category.hpp" namespace mergerfs { @@ -61,19 +62,74 @@ namespace mergerfs typedef std::string string; typedef std::size_t size_t; typedef std::vector strvec; - - typedef int (*Ptr)(const strvec&,const string&,const size_t,Paths&); - - static int invalid(const strvec&,const string&,const size_t,Paths&); - static int all(const strvec&,const string&,const size_t,Paths&); - static int epmfs(const strvec&,const string&,const size_t,Paths&); - static int ff(const strvec&,const string&,const size_t,Paths&); - static int ffwp(const strvec&,const string&,const size_t,Paths&); - static int fwfs(const strvec&,const string&,const size_t,Paths&); - static int lfs(const strvec&,const string&,const size_t,Paths&); - static int mfs(const strvec&,const string&,const size_t,Paths&); - static int newest(const strvec&,const string&,const size_t,Paths&); - static int rand(const strvec&,const string&,const size_t,Paths&); + typedef const string cstring; + typedef const size_t csize_t; + typedef const strvec cstrvec; + typedef const Category::Enum::Type CType; + + typedef int (*Ptr)(CType,cstrvec&,cstring&,csize_t,Paths&); + + class Action + { + public: + Action(const Policy *p) + : func(p->_func) + {} + + int + operator()(cstrvec& b,cstring& c,csize_t d,Paths& e) + { + return func(Category::Enum::action,b,c,d,e); + } + + private: + const Ptr func; + }; + + class Create + { + public: + Create(const Policy *p) + : func(p->_func) + {} + + int + operator()(cstrvec& b,cstring& c,csize_t d,Paths& e) + { + return func(Category::Enum::create,b,c,d,e); + } + + private: + const Ptr func; + }; + + class Search + { + public: + Search(const Policy *p) + : func(p->_func) + {} + + int + operator()(cstrvec& b,cstring& c,csize_t d,Paths& e) + { + return func(Category::Enum::search,b,c,d,e); + } + + private: + const Ptr func; + }; + + static int invalid(CType,cstrvec&,cstring&,csize_t,Paths&); + static int all(CType,cstrvec&,cstring&,csize_t,Paths&); + static int epmfs(CType,cstrvec&,cstring&,csize_t,Paths&); + static int ff(CType,cstrvec&,cstring&,csize_t,Paths&); + static int ffwp(CType,cstrvec&,cstring&,csize_t,Paths&); + static int fwfs(CType,cstrvec&,cstring&,csize_t,Paths&); + static int lfs(CType,cstrvec&,cstring&,csize_t,Paths&); + static int mfs(CType,cstrvec&,cstring&,csize_t,Paths&); + static int newest(CType,cstrvec&,cstring&,csize_t,Paths&); + static int rand(CType,cstrvec&,cstring&,csize_t,Paths&); }; private: @@ -124,16 +180,17 @@ namespace mergerfs public: static const std::vector _policies_; static const Policy * const policies; - static const Policy &invalid; - static const Policy &all; - static const Policy &epmfs; - static const Policy &ff; - static const Policy &ffwp; - static const Policy &fwfs; - static const Policy &lfs; - static const Policy &mfs; - static const Policy &newest; - static const Policy &rand; + + static const Policy &invalid; + static const Policy &all; + static const Policy &epmfs; + static const Policy &ff; + static const Policy &ffwp; + static const Policy &fwfs; + static const Policy &lfs; + static const Policy &mfs; + static const Policy &newest; + static const Policy &rand; }; } diff --git a/src/policy_all.cpp b/src/policy_all.cpp index 9260651c..2ad14708 100644 --- a/src/policy_all.cpp +++ b/src/policy_all.cpp @@ -39,10 +39,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::all(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::all(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { int rv; struct stat st; diff --git a/src/policy_epmfs.cpp b/src/policy_epmfs.cpp index b6456f5d..22bf8e56 100644 --- a/src/policy_epmfs.cpp +++ b/src/policy_epmfs.cpp @@ -40,10 +40,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::epmfs(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::epmfs(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { fsblkcnt_t existingmfs; fsblkcnt_t generalmfs; diff --git a/src/policy_ff.cpp b/src/policy_ff.cpp index a555ee1c..d81fa2d4 100644 --- a/src/policy_ff.cpp +++ b/src/policy_ff.cpp @@ -40,10 +40,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::ff(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::ff(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { errno = ENOENT; for(vector::const_iterator diff --git a/src/policy_ffwp.cpp b/src/policy_ffwp.cpp index fc908c45..ab0dc45e 100644 --- a/src/policy_ffwp.cpp +++ b/src/policy_ffwp.cpp @@ -39,10 +39,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::ffwp(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::ffwp(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { Path fallback; diff --git a/src/policy_fwfs.cpp b/src/policy_fwfs.cpp index 517060d1..219de38e 100644 --- a/src/policy_fwfs.cpp +++ b/src/policy_fwfs.cpp @@ -37,10 +37,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::fwfs(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::fwfs(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { for(size_t i = 0, size = basepaths.size(); i != size; i++) { @@ -64,6 +65,6 @@ namespace mergerfs } } - return mfs(basepaths,fusepath,minfreespace,paths); + return mfs(type,basepaths,fusepath,minfreespace,paths); } } diff --git a/src/policy_invalid.cpp b/src/policy_invalid.cpp index 829db3e5..d67432a2 100644 --- a/src/policy_invalid.cpp +++ b/src/policy_invalid.cpp @@ -36,10 +36,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::invalid(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &rv) + Policy::Func::invalid(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &rv) { return (errno = EINVAL,-1); } diff --git a/src/policy_lfs.cpp b/src/policy_lfs.cpp index 89cc22be..c972e4dd 100644 --- a/src/policy_lfs.cpp +++ b/src/policy_lfs.cpp @@ -40,10 +40,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::lfs(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::lfs(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { fsblkcnt_t lfs; const char *lfsstr; @@ -73,7 +74,7 @@ namespace mergerfs } if(lfsstr == NULL) - return Policy::Func::mfs(basepaths,fusepath,minfreespace,paths); + return mfs(type,basepaths,fusepath,minfreespace,paths); paths.push_back(Path(lfsstr, fs::make_path(lfsstr,fusepath))); diff --git a/src/policy_mfs.cpp b/src/policy_mfs.cpp index 62c0596e..6e7c72fb 100644 --- a/src/policy_mfs.cpp +++ b/src/policy_mfs.cpp @@ -37,10 +37,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::mfs(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::mfs(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { fsblkcnt_t mfs; size_t mfsidx; diff --git a/src/policy_newest.cpp b/src/policy_newest.cpp index d260aba7..bb01fb8d 100644 --- a/src/policy_newest.cpp +++ b/src/policy_newest.cpp @@ -39,10 +39,11 @@ using std::size_t; namespace mergerfs { int - Policy::Func::newest(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::newest(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { time_t newest; string npath; diff --git a/src/policy_rand.cpp b/src/policy_rand.cpp index b4fdc2d7..b7f8996d 100644 --- a/src/policy_rand.cpp +++ b/src/policy_rand.cpp @@ -37,14 +37,15 @@ using std::size_t; namespace mergerfs { int - Policy::Func::rand(const vector &basepaths, - const string &fusepath, - const size_t minfreespace, - Paths &paths) + Policy::Func::rand(const Category::Enum::Type type, + const vector &basepaths, + const string &fusepath, + const size_t minfreespace, + Paths &paths) { int rv; - rv = Policy::Func::all(basepaths,fusepath,minfreespace,paths); + rv = Policy::Func::all(type,basepaths,fusepath,minfreespace,paths); if(rv == -1) return -1; diff --git a/src/readlink.cpp b/src/readlink.cpp index 8ca42216..cfe121bb 100644 --- a/src/readlink.cpp +++ b/src/readlink.cpp @@ -41,12 +41,12 @@ using mergerfs::Policy; static int -_readlink(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - char *buf, - const size_t size) +_readlink(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + char *buf, + const size_t size) { int rv; Paths path; @@ -78,7 +78,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _readlink(*config.readlink, + return _readlink(config.readlink, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/removexattr.cpp b/src/removexattr.cpp index 235bb1bf..41a171e7 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -42,11 +42,11 @@ using mergerfs::Policy; static int -_removexattr(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const char *attrname) +_removexattr(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const char *attrname) { #ifndef WITHOUT_XATTR int rv; @@ -89,7 +89,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _removexattr(*config.removexattr, + return _removexattr(config.removexattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/rename.cpp b/src/rename.cpp index e0e05299..9594c77a 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -42,11 +42,11 @@ using mergerfs::Policy; static int -_single_rename(const Policy::Func::Ptr searchFunc, - const vector &srcmounts, - const size_t minfreespace, - const Path &oldpath, - const string &newpath) +_single_rename(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const Path &oldpath, + const string &newpath) { int rv; const string fullnewpath = fs::make_path(oldpath.base,newpath); @@ -75,12 +75,12 @@ _single_rename(const Policy::Func::Ptr searchFunc, static int -_rename(const Policy::Func::Ptr searchFunc, - const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &oldpath, - const string &newpath) +_rename(Policy::Func::Search searchFunc, + Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &oldpath, + const string &newpath) { int rv; int error; @@ -115,8 +115,8 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _rename(*config.getattr, - *config.rename, + return _rename(config.getattr, + config.rename, config.srcmounts, config.minfreespace, oldpath, diff --git a/src/rmdir.cpp b/src/rmdir.cpp index dd9e1abe..80023988 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -40,10 +40,10 @@ using mergerfs::Policy; static int -_rmdir(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath) +_rmdir(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath) { int rv; int error; @@ -77,7 +77,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readguard(&config.srcmountslock); - return _rmdir(*config.rmdir, + return _rmdir(config.rmdir, config.srcmounts, config.minfreespace, fusepath); diff --git a/src/setxattr.cpp b/src/setxattr.cpp index c2d5c870..c81aaaa4 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -240,14 +240,14 @@ _setxattr_controlfile(config::Config &config, static int -_setxattr(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const char *attrname, - const char *attrval, - const size_t attrvalsize, - const int flags) +_setxattr(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const char *attrname, + const char *attrval, + const size_t attrvalsize, + const int flags) { #ifndef WITHOUT_XATTR int rv; @@ -301,7 +301,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _setxattr(*config.setxattr, + return _setxattr(config.setxattr, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/symlink.cpp b/src/symlink.cpp index 418310d0..d35ecac5 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -40,11 +40,11 @@ using mergerfs::Policy; static int -_symlink(const Policy::Func::Ptr createFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &oldpath, - const string &newpath) +_symlink(Policy::Func::Create createFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &oldpath, + const string &newpath) { int rv; int error; @@ -83,7 +83,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _symlink(*config.symlink, + return _symlink(config.symlink, config.srcmounts, config.minfreespace, oldpath, diff --git a/src/truncate.cpp b/src/truncate.cpp index 70f0df6b..01975589 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -42,11 +42,11 @@ using mergerfs::Policy; static int -_truncate(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath, - const off_t size) +_truncate(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath, + const off_t size) { int rv; int error; @@ -81,7 +81,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _truncate(*config.truncate, + return _truncate(config.truncate, config.srcmounts, config.minfreespace, fusepath, diff --git a/src/unlink.cpp b/src/unlink.cpp index e6965635..b334f051 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -41,10 +41,10 @@ using mergerfs::Policy; static int -_unlink(const Policy::Func::Ptr actionFunc, - const vector &srcmounts, - const size_t minfreespace, - const string &fusepath) +_unlink(Policy::Func::Action actionFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &fusepath) { int rv; int error; @@ -78,7 +78,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _unlink(*config.unlink, + return _unlink(config.unlink, config.srcmounts, config.minfreespace, fusepath); diff --git a/src/utimens.cpp b/src/utimens.cpp index 42f4bc99..d7cdf898 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -42,11 +42,11 @@ using mergerfs::Policy; static int -_utimens(const Policy::Func::Ptr 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 struct timespec ts[2]) { int rv; int error; @@ -81,7 +81,7 @@ namespace mergerfs const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); - return _utimens(*config.utimens, + return _utimens(config.utimens, config.srcmounts, config.minfreespace, fusepath,