diff --git a/src/fuse_access.cpp b/src/fuse_access.cpp index 1c0d34e4..37ce0f71 100644 --- a/src/fuse_access.cpp +++ b/src/fuse_access.cpp @@ -28,10 +28,9 @@ namespace FUSE::ACCESS int mode_) { State s; - gfs::path fusepath(&fusepath_[1]); const fuse_context *fc = fuse_get_context(); const ugid::Set ugid(fc->uid,fc->gid); - return s->access(fusepath,mode_); + return s->access(&fusepath_[1],mode_); } } diff --git a/src/fuse_access_policy.hpp b/src/fuse_access_policy.hpp index b5b92e60..92f7c279 100644 --- a/src/fuse_access_policy.hpp +++ b/src/fuse_access_policy.hpp @@ -19,8 +19,7 @@ #pragma once #include "fuse_access_policy_base.hpp" - -#include "toml.hpp" +#include "fuse_access_policy_factory.hpp" namespace FUSE::ACCESS @@ -28,11 +27,18 @@ namespace FUSE::ACCESS class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _access = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - const int mask); + int + operator()(const gfs::path &fusepath_, + const int mask_) + { + return (*_access)(fusepath_,mask_); + } private: POLICY::Base::Ptr _access; diff --git a/src/fuse_chmod_policy.hpp b/src/fuse_chmod_policy.hpp index c5c69003..4ad94a19 100644 --- a/src/fuse_chmod_policy.hpp +++ b/src/fuse_chmod_policy.hpp @@ -19,8 +19,7 @@ #pragma once #include "fuse_chmod_policy_base.hpp" - -#include "toml.hpp" +#include "fuse_chmod_policy_factory.hpp" #include @@ -30,11 +29,18 @@ namespace FUSE::CHMOD class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _chmod = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - const mode_t mode); + int + operator()(const gfs::path &fusepath_, + const mode_t mode_) + { + return (*_chmod)(fusepath_,mode_); + } private: POLICY::Base::Ptr _chmod; diff --git a/src/fuse_chown_policy.hpp b/src/fuse_chown_policy.hpp index fd0fc59a..d85acff3 100644 --- a/src/fuse_chown_policy.hpp +++ b/src/fuse_chown_policy.hpp @@ -19,8 +19,7 @@ #pragma once #include "fuse_chown_policy_base.hpp" - -#include "toml.hpp" +#include "fuse_chown_policy_factory.hpp" #include @@ -30,12 +29,19 @@ namespace FUSE::CHOWN class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _chown = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - const uid_t uid, - const gid_t gid); + int + operator()(const gfs::path &fusepath_, + const uid_t uid_, + const gid_t gid_) + { + return (*_chown)(fusepath_,uid_,gid_); + } private: POLICY::Base::Ptr _chown; diff --git a/src/fuse_chown_policy_all.cpp b/src/fuse_chown_policy_all.cpp index 84ad6487..00190167 100644 --- a/src/fuse_chown_policy_all.cpp +++ b/src/fuse_chown_policy_all.cpp @@ -22,14 +22,14 @@ #include "fs_lchown.hpp" -FUSE::CHOWN::POLICY::all::all(const toml::value &toml_) +FUSE::CHOWN::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::CHOWN::POLICY::all::operator()(const gfs::path &fusepath_, +FUSE::CHOWN::POLICY::ALL::operator()(const gfs::path &fusepath_, const uid_t uid_, const gid_t gid_) { diff --git a/src/fuse_create_policy.hpp b/src/fuse_create_policy.hpp index 222154e0..1c7e8662 100644 --- a/src/fuse_create_policy.hpp +++ b/src/fuse_create_policy.hpp @@ -19,8 +19,7 @@ #pragma once #include "fuse_create_policy_base.hpp" - -#include "toml.hpp" +#include "fuse_create_policy_factory.hpp" namespace FUSE::CREATE @@ -28,13 +27,20 @@ namespace FUSE::CREATE class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _create = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - const mode_t mode, - const mode_t umask, - fuse_file_info_t *ffi); + int + operator()(const gfs::path &fusepath_, + const mode_t mode_, + const mode_t umask_, + fuse_file_info_t *ffi_) + { + return (*_create)(fusepath_,mode_,umask_,ffi_); + } private: POLICY::Base::Ptr _create; diff --git a/src/fuse_getattr_policy.hpp b/src/fuse_getattr_policy.hpp index 6598d877..6547633c 100644 --- a/src/fuse_getattr_policy.hpp +++ b/src/fuse_getattr_policy.hpp @@ -19,6 +19,7 @@ #pragma once #include "fuse_getattr_policy_base.hpp" +#include "fuse_getattr_policy_factory.hpp" #include "fuse_timeouts.h" @@ -32,12 +33,19 @@ namespace FUSE::GETATTR class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _getattr = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - struct stat *st, - fuse_timeouts_t *timeout); + int + operator()(const gfs::path &fusepath_, + struct stat *st_, + fuse_timeouts_t *timeout_) + { + return (*_getattr)(fusepath_,st_,timeout_); + } private: POLICY::Base::Ptr _getattr; diff --git a/src/fuse_getxattr_policy.hpp b/src/fuse_getxattr_policy.hpp index c996efa4..d02fdfe7 100644 --- a/src/fuse_getxattr_policy.hpp +++ b/src/fuse_getxattr_policy.hpp @@ -19,11 +19,10 @@ #pragma once #include "fuse_getxattr_policy_base.hpp" +#include "fuse_getxattr_policy_factory.hpp" #include "fuse_timeouts.h" -#include "toml.hpp" - #include #include @@ -34,13 +33,20 @@ namespace FUSE::GETXATTR class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _getxattr = POLICY::factory(toml_); + } public: - int operator()(const gfs::path &fusepath, - const char *attrname, - char *buf, - size_t count); + int + operator()(const gfs::path &fusepath_, + const char *attrname_, + char *buf_, + size_t count_) + { + return (*_getxattr)(fusepath_,attrname_,buf_,count_); + } private: POLICY::Base::Ptr _getxattr; diff --git a/src/fuse_getxattr_policy_factory.hpp b/src/fuse_getxattr_policy_factory.hpp index 084d9467..c6d450c5 100644 --- a/src/fuse_getxattr_policy_factory.hpp +++ b/src/fuse_getxattr_policy_factory.hpp @@ -18,7 +18,7 @@ #pragma once -#include "fuse_getxattr_func_base.hpp" +#include "fuse_getxattr_policy_base.hpp" #include "toml.hpp" diff --git a/src/fuse_ioctl_policy.hpp b/src/fuse_ioctl_policy.hpp index f67a1cd2..f95cee5a 100644 --- a/src/fuse_ioctl_policy.hpp +++ b/src/fuse_ioctl_policy.hpp @@ -19,6 +19,7 @@ #pragma once #include "fuse_ioctl_policy_base.hpp" +#include "fuse_ioctl_policy_factory.hpp" #include "toml.hpp" @@ -28,14 +29,21 @@ namespace FUSE::IOCTL class Policy { public: - Policy(const toml::value &); + Policy(const toml::value &toml_) + { + _ioctl = POLICY::factory(toml_); + } public: - int operator()(const fuse_file_info_t *ffi_, - const unsigned long cmd, - const unsigned int flags, - void *data, - uint32_t *out_bufsz); + int + operator()(const fuse_file_info_t *ffi_, + const unsigned long cmd_, + const unsigned int flags_, + void *data_, + uint32_t *out_bufsz_) + { + return (*_ioctl)(ffi_,cmd_,flags_,data_,out_bufsz_); + } private: POLICY::Base::Ptr _ioctl; diff --git a/src/fuse_setxattr_policy_all.cpp b/src/fuse_setxattr_policy_all.cpp index 8fb12055..c3e429f9 100644 --- a/src/fuse_setxattr_policy_all.cpp +++ b/src/fuse_setxattr_policy_all.cpp @@ -16,38 +16,33 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_setxattr_func_all.hpp" #include "fuse_setxattr_err.hpp" +#include "fuse_setxattr_policy_all.hpp" #include "fs_lsetxattr.hpp" -namespace gfs = ghc::filesystem; - - -FUSE::SETXATTR::FuncALL::FuncALL(const toml::value &toml_) +FUSE::SETXATTR::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::SETXATTR::FuncALL::operator()(const char *fusepath_, - const char *attrname_, - const char *attrval_, - const size_t attrvalsize_, - const int flags_) +FUSE::SETXATTR::POLICY::ALL::operator()(const gfs::path &fusepath_, + const char *attrname_, + const char *attrval_, + const size_t attrvalsize_, + const int flags_) { Err rv; - gfs::path fusepath; gfs::path fullpath; - fusepath = &fusepath_[1]; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) { - fullpath = branch.path / fusepath; + fullpath = branch.path / fusepath_; rv = fs::lsetxattr(fullpath, attrname_, diff --git a/src/fuse_setxattr_policy_all.hpp b/src/fuse_setxattr_policy_all.hpp index e97a8822..9b185d5a 100644 --- a/src/fuse_setxattr_policy_all.hpp +++ b/src/fuse_setxattr_policy_all.hpp @@ -18,24 +18,24 @@ #pragma once -#include "fuse_setxattr_func_base.hpp" +#include "fuse_setxattr_policy_base.hpp" #include "branches.hpp" -namespace FUSE::SETXATTR +namespace FUSE::SETXATTR::POLICY { - class FuncALL : public FuncBase + class ALL : public Base { public: - FuncALL(const toml::value &); + ALL(const toml::value &); public: - int operator()(const char *fusepath, - const char *attrname, - const char *attrval, - const size_t attrvalsize, - const int flags) final; + int operator()(const gfs::path &fusepath, + const char *attrname, + const char *attrval, + const size_t attrvalsize, + const int flags) final; private: Branches2 _branches; diff --git a/src/fuse_setxattr_policy_factory.cpp b/src/fuse_setxattr_policy_factory.cpp index 0adcc1f9..c2552885 100644 --- a/src/fuse_setxattr_policy_factory.cpp +++ b/src/fuse_setxattr_policy_factory.cpp @@ -16,15 +16,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_setxattr_func_factory.hpp" -#include "fuse_setxattr_func_all.hpp" +#include "fuse_setxattr_policy_factory.hpp" + +#include "fuse_setxattr_policy_all.hpp" #include -namespace FUSE::SETXATTR +namespace FUSE::SETXATTR::POLICY { - FuncBase::Ptr + Base::Ptr factory(const toml::value &toml_) { std::string str; diff --git a/src/fuse_symlink_policy.hpp b/src/fuse_symlink_policy.hpp index c92c2aec..4acd89ba 100644 --- a/src/fuse_symlink_policy.hpp +++ b/src/fuse_symlink_policy.hpp @@ -36,8 +36,8 @@ namespace FUSE::SYMLINK public: int - operator()(const gfs::path &target_, - const char *linkpath_) + operator()(const char *target_, + const gfs::path &linkpath_) { return (*_symlink)(target_,linkpath_); } diff --git a/src/fuse_symlink_policy_base.hpp b/src/fuse_symlink_policy_base.hpp index 77b4292e..faf81e9e 100644 --- a/src/fuse_symlink_policy_base.hpp +++ b/src/fuse_symlink_policy_base.hpp @@ -31,7 +31,7 @@ namespace FUSE::SYMLINK::POLICY typedef std::shared_ptr Ptr; public: - virtual int operator()(const gfs::path &target, - const char *linkpath) = 0; + virtual int operator()(const char *target, + const gfs::path &linkpath) = 0; }; } diff --git a/src/fuse_symlink_policy_epff.cpp b/src/fuse_symlink_policy_epff.cpp index 9f605e8a..654323d8 100644 --- a/src/fuse_symlink_policy_epff.cpp +++ b/src/fuse_symlink_policy_epff.cpp @@ -16,34 +16,29 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_symlink_func_epff.hpp" +#include "fuse_symlink_policy_epff.hpp" #include "fs_symlink.hpp" -namespace gfs = ghc::filesystem; - - -FUSE::SYMLINK::FuncEPFF::FuncEPFF(const toml::value &toml_) +FUSE::SYMLINK::POLICY::EPFF::EPFF(const toml::value &toml_) : _branches(toml_) { } int -FUSE::SYMLINK::FuncEPFF::operator()(const char *target_, - const char *linkpath_) +FUSE::SYMLINK::POLICY::EPFF::operator()(const char *target_, + const gfs::path &linkpath_) { int rv; - gfs::path linkpath; gfs::path fullpath; - linkpath = &linkpath_[1]; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) { - fullpath = branch.path / linkpath; + fullpath = branch.path / linkpath_; rv = fs::symlink(target_,fullpath); if(rv == -ENOENT) diff --git a/src/fuse_symlink_policy_epff.hpp b/src/fuse_symlink_policy_epff.hpp index 347be51d..8e690bbe 100644 --- a/src/fuse_symlink_policy_epff.hpp +++ b/src/fuse_symlink_policy_epff.hpp @@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY EPFF(const toml::value &); public: - int operator()(const gfs::path &target, - const char *linkpath) final; + int operator()(const char *target, + const gfs::path &linkpath) final; private: Branches2 _branches; diff --git a/src/fuse_symlink_policy_ff.hpp b/src/fuse_symlink_policy_ff.hpp index 36efc892..f168a11f 100644 --- a/src/fuse_symlink_policy_ff.hpp +++ b/src/fuse_symlink_policy_ff.hpp @@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY FF(const toml::value &); public: - int operator()(const gfs::path &target, - const char *linkpath) final; + int operator()(const char *target, + const gfs::path &linkpath) final; private: Branches2 _branches; diff --git a/src/fuse_unlink_err.hpp b/src/fuse_unlink_err.hpp index 58b80680..959dc95a 100644 --- a/src/fuse_unlink_err.hpp +++ b/src/fuse_unlink_err.hpp @@ -18,6 +18,9 @@ #pragma once +#include "errno.hpp" + + namespace FUSE::UNLINK { class Err diff --git a/src/fuse_unlink_policy_all.cpp b/src/fuse_unlink_policy_all.cpp index b053b260..37a18f00 100644 --- a/src/fuse_unlink_policy_all.cpp +++ b/src/fuse_unlink_policy_all.cpp @@ -16,34 +16,29 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_unlink_func_all.hpp" #include "fuse_unlink_err.hpp" +#include "fuse_unlink_policy_all.hpp" #include "fs_unlink.hpp" -namespace gfs = ghc::filesystem; - - -FUSE::UNLINK::FuncALL::FuncALL(const toml::value &toml_) +FUSE::UNLINK::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::UNLINK::FuncALL::operator()(const char *fusepath_) +FUSE::UNLINK::POLICY::ALL::operator()(const gfs::path &fusepath_) { Err rv; - gfs::path fusepath; gfs::path fullpath; - fusepath = &fusepath_[1]; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) { - fullpath = branch.path / fusepath; + fullpath = branch.path / fusepath_; rv = fs::unlink(fullpath); } diff --git a/src/fuse_unlink_policy_all.hpp b/src/fuse_unlink_policy_all.hpp index 2afce42b..5d9970e4 100644 --- a/src/fuse_unlink_policy_all.hpp +++ b/src/fuse_unlink_policy_all.hpp @@ -18,20 +18,20 @@ #pragma once -#include "fuse_unlink_func_base.hpp" +#include "fuse_unlink_policy_base.hpp" #include "branches.hpp" -namespace FUSE::UNLINK +namespace FUSE::UNLINK::POLICY { - class FuncALL : public FuncBase + class ALL : public Base { public: - FuncALL(const toml::value &); + ALL(const toml::value &); public: - int operator()(const char *fusepath) final; + int operator()(const gfs::path &fusepath) final; private: Branches2 _branches; diff --git a/src/fuse_utimens_policy_all.cpp b/src/fuse_utimens_policy_all.cpp index e169c93d..45f6ca80 100644 --- a/src/fuse_utimens_policy_all.cpp +++ b/src/fuse_utimens_policy_all.cpp @@ -16,35 +16,30 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "fuse_utimens_func_all.hpp" +#include "fuse_utimens_policy_all.hpp" #include "fuse_utimens_err.hpp" #include "fs_lutimens.hpp" -namespace gfs = ghc::filesystem; - - -FUSE::UTIMENS::FuncALL::FuncALL(const toml::value &toml_) +FUSE::UTIMENS::POLICY::ALL::ALL(const toml::value &toml_) : _branches(toml_) { } int -FUSE::UTIMENS::FuncALL::operator()(const char *fusepath_, - const timespec ts_[2]) +FUSE::UTIMENS::POLICY::ALL::operator()(const gfs::path &fusepath_, + const timespec ts_[2]) { Err rv; - gfs::path fusepath; gfs::path fullpath; - fusepath = &fusepath_[1]; for(const auto &branch_group : _branches) { for(const auto &branch : branch_group) { - fullpath = branch.path / fusepath; + fullpath = branch.path / fusepath_; rv = fs::lutimens(fullpath,ts_); }