Browse Source

checkpoint

toml
Antonio SJ Musumeci 3 years ago
parent
commit
a675e14508
  1. 3
      src/fuse_access.cpp
  2. 16
      src/fuse_access_policy.hpp
  3. 16
      src/fuse_chmod_policy.hpp
  4. 18
      src/fuse_chown_policy.hpp
  5. 4
      src/fuse_chown_policy_all.cpp
  6. 20
      src/fuse_create_policy.hpp
  7. 16
      src/fuse_getattr_policy.hpp
  8. 20
      src/fuse_getxattr_policy.hpp
  9. 2
      src/fuse_getxattr_policy_factory.hpp
  10. 20
      src/fuse_ioctl_policy.hpp
  11. 13
      src/fuse_setxattr_policy_all.cpp
  12. 10
      src/fuse_setxattr_policy_all.hpp
  13. 9
      src/fuse_setxattr_policy_factory.cpp
  14. 4
      src/fuse_symlink_policy.hpp
  15. 4
      src/fuse_symlink_policy_base.hpp
  16. 15
      src/fuse_symlink_policy_epff.cpp
  17. 4
      src/fuse_symlink_policy_epff.hpp
  18. 4
      src/fuse_symlink_policy_ff.hpp
  19. 3
      src/fuse_unlink_err.hpp
  20. 13
      src/fuse_unlink_policy_all.cpp
  21. 10
      src/fuse_unlink_policy_all.hpp
  22. 13
      src/fuse_utimens_policy_all.cpp

3
src/fuse_access.cpp

@ -28,10 +28,9 @@ namespace FUSE::ACCESS
int mode_) int mode_)
{ {
State s; State s;
gfs::path fusepath(&fusepath_[1]);
const fuse_context *fc = fuse_get_context(); const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid); const ugid::Set ugid(fc->uid,fc->gid);
return s->access(fusepath,mode_);
return s->access(&fusepath_[1],mode_);
} }
} }

16
src/fuse_access_policy.hpp

@ -19,8 +19,7 @@
#pragma once #pragma once
#include "fuse_access_policy_base.hpp" #include "fuse_access_policy_base.hpp"
#include "toml.hpp"
#include "fuse_access_policy_factory.hpp"
namespace FUSE::ACCESS namespace FUSE::ACCESS
@ -28,11 +27,18 @@ namespace FUSE::ACCESS
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_access = POLICY::factory(toml_);
}
public: public:
int operator()(const gfs::path &fusepath,
const int mask);
int
operator()(const gfs::path &fusepath_,
const int mask_)
{
return (*_access)(fusepath_,mask_);
}
private: private:
POLICY::Base::Ptr _access; POLICY::Base::Ptr _access;

16
src/fuse_chmod_policy.hpp

@ -19,8 +19,7 @@
#pragma once #pragma once
#include "fuse_chmod_policy_base.hpp" #include "fuse_chmod_policy_base.hpp"
#include "toml.hpp"
#include "fuse_chmod_policy_factory.hpp"
#include <sys/stat.h> #include <sys/stat.h>
@ -30,11 +29,18 @@ namespace FUSE::CHMOD
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_chmod = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _chmod; POLICY::Base::Ptr _chmod;

18
src/fuse_chown_policy.hpp

@ -19,8 +19,7 @@
#pragma once #pragma once
#include "fuse_chown_policy_base.hpp" #include "fuse_chown_policy_base.hpp"
#include "toml.hpp"
#include "fuse_chown_policy_factory.hpp"
#include <sys/stat.h> #include <sys/stat.h>
@ -30,12 +29,19 @@ namespace FUSE::CHOWN
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_chown = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _chown; POLICY::Base::Ptr _chown;

4
src/fuse_chown_policy_all.cpp

@ -22,14 +22,14 @@
#include "fs_lchown.hpp" #include "fs_lchown.hpp"
FUSE::CHOWN::POLICY::all::all(const toml::value &toml_)
FUSE::CHOWN::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_) : _branches(toml_)
{ {
} }
int int
FUSE::CHOWN::POLICY::all::operator()(const gfs::path &fusepath_,
FUSE::CHOWN::POLICY::ALL::operator()(const gfs::path &fusepath_,
const uid_t uid_, const uid_t uid_,
const gid_t gid_) const gid_t gid_)
{ {

20
src/fuse_create_policy.hpp

@ -19,8 +19,7 @@
#pragma once #pragma once
#include "fuse_create_policy_base.hpp" #include "fuse_create_policy_base.hpp"
#include "toml.hpp"
#include "fuse_create_policy_factory.hpp"
namespace FUSE::CREATE namespace FUSE::CREATE
@ -28,13 +27,20 @@ namespace FUSE::CREATE
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_create = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _create; POLICY::Base::Ptr _create;

16
src/fuse_getattr_policy.hpp

@ -19,6 +19,7 @@
#pragma once #pragma once
#include "fuse_getattr_policy_base.hpp" #include "fuse_getattr_policy_base.hpp"
#include "fuse_getattr_policy_factory.hpp"
#include "fuse_timeouts.h" #include "fuse_timeouts.h"
@ -32,12 +33,19 @@ namespace FUSE::GETATTR
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_getattr = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _getattr; POLICY::Base::Ptr _getattr;

20
src/fuse_getxattr_policy.hpp

@ -19,11 +19,10 @@
#pragma once #pragma once
#include "fuse_getxattr_policy_base.hpp" #include "fuse_getxattr_policy_base.hpp"
#include "fuse_getxattr_policy_factory.hpp"
#include "fuse_timeouts.h" #include "fuse_timeouts.h"
#include "toml.hpp"
#include <memory> #include <memory>
#include <sys/stat.h> #include <sys/stat.h>
@ -34,13 +33,20 @@ namespace FUSE::GETXATTR
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_getxattr = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _getxattr; POLICY::Base::Ptr _getxattr;

2
src/fuse_getxattr_policy_factory.hpp

@ -18,7 +18,7 @@
#pragma once #pragma once
#include "fuse_getxattr_func_base.hpp"
#include "fuse_getxattr_policy_base.hpp"
#include "toml.hpp" #include "toml.hpp"

20
src/fuse_ioctl_policy.hpp

@ -19,6 +19,7 @@
#pragma once #pragma once
#include "fuse_ioctl_policy_base.hpp" #include "fuse_ioctl_policy_base.hpp"
#include "fuse_ioctl_policy_factory.hpp"
#include "toml.hpp" #include "toml.hpp"
@ -28,14 +29,21 @@ namespace FUSE::IOCTL
class Policy class Policy
{ {
public: public:
Policy(const toml::value &);
Policy(const toml::value &toml_)
{
_ioctl = POLICY::factory(toml_);
}
public: 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: private:
POLICY::Base::Ptr _ioctl; POLICY::Base::Ptr _ioctl;

13
src/fuse_setxattr_policy_all.cpp

@ -16,38 +16,33 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 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_err.hpp"
#include "fuse_setxattr_policy_all.hpp"
#include "fs_lsetxattr.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_) : _branches(toml_)
{ {
} }
int int
FUSE::SETXATTR::FuncALL::operator()(const char *fusepath_,
FUSE::SETXATTR::POLICY::ALL::operator()(const gfs::path &fusepath_,
const char *attrname_, const char *attrname_,
const char *attrval_, const char *attrval_,
const size_t attrvalsize_, const size_t attrvalsize_,
const int flags_) const int flags_)
{ {
Err rv; Err rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath;
fullpath = branch.path / fusepath_;
rv = fs::lsetxattr(fullpath, rv = fs::lsetxattr(fullpath,
attrname_, attrname_,

10
src/fuse_setxattr_policy_all.hpp

@ -18,20 +18,20 @@
#pragma once #pragma once
#include "fuse_setxattr_func_base.hpp"
#include "fuse_setxattr_policy_base.hpp"
#include "branches.hpp" #include "branches.hpp"
namespace FUSE::SETXATTR
namespace FUSE::SETXATTR::POLICY
{ {
class FuncALL : public FuncBase
class ALL : public Base
{ {
public: public:
FuncALL(const toml::value &);
ALL(const toml::value &);
public: public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
const char *attrname, const char *attrname,
const char *attrval, const char *attrval,
const size_t attrvalsize, const size_t attrvalsize,

9
src/fuse_setxattr_policy_factory.cpp

@ -16,15 +16,16 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 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 <stdexcept> #include <stdexcept>
namespace FUSE::SETXATTR
namespace FUSE::SETXATTR::POLICY
{ {
FuncBase::Ptr
Base::Ptr
factory(const toml::value &toml_) factory(const toml::value &toml_)
{ {
std::string str; std::string str;

4
src/fuse_symlink_policy.hpp

@ -36,8 +36,8 @@ namespace FUSE::SYMLINK
public: public:
int int
operator()(const gfs::path &target_,
const char *linkpath_)
operator()(const char *target_,
const gfs::path &linkpath_)
{ {
return (*_symlink)(target_,linkpath_); return (*_symlink)(target_,linkpath_);
} }

4
src/fuse_symlink_policy_base.hpp

@ -31,7 +31,7 @@ namespace FUSE::SYMLINK::POLICY
typedef std::shared_ptr<Base> Ptr; typedef std::shared_ptr<Base> Ptr;
public: public:
virtual int operator()(const gfs::path &target,
const char *linkpath) = 0;
virtual int operator()(const char *target,
const gfs::path &linkpath) = 0;
}; };
} }

15
src/fuse_symlink_policy_epff.cpp

@ -16,34 +16,29 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 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" #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_) : _branches(toml_)
{ {
} }
int 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; int rv;
gfs::path linkpath;
gfs::path fullpath; gfs::path fullpath;
linkpath = &linkpath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / linkpath;
fullpath = branch.path / linkpath_;
rv = fs::symlink(target_,fullpath); rv = fs::symlink(target_,fullpath);
if(rv == -ENOENT) if(rv == -ENOENT)

4
src/fuse_symlink_policy_epff.hpp

@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY
EPFF(const toml::value &); EPFF(const toml::value &);
public: public:
int operator()(const gfs::path &target,
const char *linkpath) final;
int operator()(const char *target,
const gfs::path &linkpath) final;
private: private:
Branches2 _branches; Branches2 _branches;

4
src/fuse_symlink_policy_ff.hpp

@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY
FF(const toml::value &); FF(const toml::value &);
public: public:
int operator()(const gfs::path &target,
const char *linkpath) final;
int operator()(const char *target,
const gfs::path &linkpath) final;
private: private:
Branches2 _branches; Branches2 _branches;

3
src/fuse_unlink_err.hpp

@ -18,6 +18,9 @@
#pragma once #pragma once
#include "errno.hpp"
namespace FUSE::UNLINK namespace FUSE::UNLINK
{ {
class Err class Err

13
src/fuse_unlink_policy_all.cpp

@ -16,34 +16,29 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 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_err.hpp"
#include "fuse_unlink_policy_all.hpp"
#include "fs_unlink.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_) : _branches(toml_)
{ {
} }
int int
FUSE::UNLINK::FuncALL::operator()(const char *fusepath_)
FUSE::UNLINK::POLICY::ALL::operator()(const gfs::path &fusepath_)
{ {
Err rv; Err rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath;
fullpath = branch.path / fusepath_;
rv = fs::unlink(fullpath); rv = fs::unlink(fullpath);
} }

10
src/fuse_unlink_policy_all.hpp

@ -18,20 +18,20 @@
#pragma once #pragma once
#include "fuse_unlink_func_base.hpp"
#include "fuse_unlink_policy_base.hpp"
#include "branches.hpp" #include "branches.hpp"
namespace FUSE::UNLINK
namespace FUSE::UNLINK::POLICY
{ {
class FuncALL : public FuncBase
class ALL : public Base
{ {
public: public:
FuncALL(const toml::value &);
ALL(const toml::value &);
public: public:
int operator()(const char *fusepath) final;
int operator()(const gfs::path &fusepath) final;
private: private:
Branches2 _branches; Branches2 _branches;

13
src/fuse_utimens_policy_all.cpp

@ -16,35 +16,30 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 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 "fuse_utimens_err.hpp"
#include "fs_lutimens.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_) : _branches(toml_)
{ {
} }
int int
FUSE::UTIMENS::FuncALL::operator()(const char *fusepath_,
FUSE::UTIMENS::POLICY::ALL::operator()(const gfs::path &fusepath_,
const timespec ts_[2]) const timespec ts_[2])
{ {
Err rv; Err rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath;
fullpath = branch.path / fusepath_;
rv = fs::lutimens(fullpath,ts_); rv = fs::lutimens(fullpath,ts_);
} }

Loading…
Cancel
Save