Browse Source

checkpoint

toml
Antonio SJ Musumeci 3 years ago
parent
commit
202f29286b
  1. 6
      src/fuse_chmod_policy_all.cpp
  2. 4
      src/fuse_chown_policy_all.hpp
  3. 36
      src/fuse_getattr_func.cpp
  4. 46
      src/fuse_getattr_func.hpp
  5. 41
      src/fuse_getattr_func_base.hpp
  6. 5
      src/fuse_ioctl_policy_all.cpp
  7. 2
      src/fuse_listxattr_policy.hpp
  8. 5
      src/fuse_mkdir_policy.hpp
  9. 10
      src/fuse_mknod_policy.hpp
  10. 2
      src/fuse_mknod_policy_base.hpp
  11. 1
      src/fuse_readlink_policy.hpp
  12. 2
      src/fuse_readlink_policy_base.hpp
  13. 2
      src/fuse_readlink_policy_factory.hpp
  14. 2
      src/fuse_readlink_policy_ff.hpp
  15. 1
      src/fuse_removexattr_policy.hpp
  16. 1
      src/fuse_rename_policy.hpp
  17. 13
      src/fuse_rmdir_policy_all.cpp
  18. 10
      src/fuse_rmdir_policy_all.hpp
  19. 9
      src/fuse_rmdir_policy_base.hpp
  20. 13
      src/fuse_rmdir_policy_factory.cpp
  21. 8
      src/fuse_rmdir_policy_factory.hpp
  22. 26
      src/fuse_setxattr_policy.hpp
  23. 18
      src/fuse_setxattr_policy_base.hpp
  24. 8
      src/fuse_setxattr_policy_factory.hpp
  25. 20
      src/fuse_symlink_policy.hpp
  26. 12
      src/fuse_symlink_policy_base.hpp
  27. 8
      src/fuse_symlink_policy_factory.hpp
  28. 20
      src/fuse_truncate_policy.hpp
  29. 12
      src/fuse_truncate_policy_all.hpp
  30. 11
      src/fuse_truncate_policy_base.hpp
  31. 12
      src/fuse_truncate_policy_factory.cpp
  32. 8
      src/fuse_truncate_policy_factory.hpp
  33. 18
      src/fuse_unlink_policy.hpp
  34. 9
      src/fuse_unlink_policy_base.hpp
  35. 8
      src/fuse_unlink_policy_factory.hpp

6
src/fuse_chmod_policy_all.cpp

@ -22,15 +22,15 @@
#include "fs_lchmod.hpp"
FUSE::CHMOD::POLICY::ALL(const toml::value &toml_)
FUSE::CHMOD::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHMOD::POLICYALL::operator()(const gfs::path &fusepath_,
const mode_t mode_)
FUSE::CHMOD::POLICY::ALL::operator()(const gfs::path &fusepath_,
const mode_t mode_)
{
Err rv;
gfs::path fullpath;

4
src/fuse_chown_policy_all.hpp

@ -25,10 +25,10 @@
namespace FUSE::CHOWN::POLICY
{
class all : public base
class ALL : public Base
{
public:
all(const toml::value &);
ALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,

36
src/fuse_getattr_func.cpp

@ -1,36 +0,0 @@
/*
ISC License
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fuse_getattr_func.hpp"
#include "fuse_getattr_func_factory.hpp"
#include "state.hpp"
FUSE::GETATTR::Func::Func(const toml::value &toml_)
{
_getattr = FuncFactory(toml_);
}
int
FUSE::GETATTR::Func::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
return (*_getattr)(fusepath_,st_,timeout_);
}

46
src/fuse_getattr_func.hpp

@ -1,46 +0,0 @@
/*
ISC License
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "from_toml.hpp"
#include "fuse_getattr_func_base.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETATTR
{
class Func
{
public:
Func(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout);
private:
FuncBase::Ptr _getattr;
};
}

41
src/fuse_getattr_func_base.hpp

@ -1,41 +0,0 @@
/*
ISC License
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "fs_path.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETATTR
{
class FuncBase
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) = 0;
};
}

5
src/fuse_ioctl_policy_all.cpp

@ -19,8 +19,12 @@
#include "fuse_ioctl_policy_all.hpp"
#include "fuse_ioctl_err.hpp"
#include "fs_path.hpp"
#include "fs_ioctl.hpp"
#include "fh.hpp"
FUSE::IOCTL::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
@ -39,6 +43,7 @@ FUSE::IOCTL::POLICY::ALL::operator()(const fuse_file_info_t *ffi_,
gfs::path fusepath;
gfs::path fullpath;
fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)

2
src/fuse_listxattr_policy.hpp

@ -38,7 +38,7 @@ namespace FUSE::LISTXATTR
char *buf_,
size_t count_)
{
return (*_listxattr)(fusepath_,list_,size_);
return (*_listxattr)(fusepath_,buf_,count_);
}
private:

5
src/fuse_mkdir_policy.hpp

@ -18,7 +18,8 @@
#pragma once
#include "fuse_mkdir_func_base.hpp"
#include "fuse_mkdir_policy_base.hpp"
#include "fuse_mkdir_policy_factory.hpp"
#include "toml.hpp"
@ -42,6 +43,6 @@ namespace FUSE::MKDIR
}
private:
FuncBase::Ptr _mkdir;
POLICY::Base::Ptr _mkdir;
};
}

10
src/fuse_mknod_policy.hpp

@ -31,15 +31,15 @@ namespace FUSE::MKNOD
public:
Policy(const toml::value &toml_)
{
_mknod = FuncFactory(toml_);
_mknod = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev)
operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
const dev_t dev_)
{
return (*_mknod)(fusepath_,mode_,umask_,dev_);
}

2
src/fuse_mknod_policy_base.hpp

@ -33,7 +33,7 @@ namespace FUSE::MKNOD::POLICY
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,

1
src/fuse_readlink_policy.hpp

@ -19,6 +19,7 @@
#pragma once
#include "fuse_readlink_policy_base.hpp"
#include "fuse_readlink_policy_factory.hpp"
#include "fuse_timeouts.h"

2
src/fuse_readlink_policy_base.hpp

@ -18,6 +18,8 @@
#pragma once
#include "fs_path.hpp"
#include <memory>

2
src/fuse_readlink_policy_factory.hpp

@ -18,7 +18,7 @@
#pragma once
#include "fuse_readlink_func_base.hpp"
#include "fuse_readlink_policy_base.hpp"
#include "toml.hpp"

2
src/fuse_readlink_policy_ff.hpp

@ -33,7 +33,7 @@ namespace FUSE::READLINK::POLICY
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,,
int operator()(const gfs::path &fusepath,
char *buf,
const size_t bufsiz) final;

1
src/fuse_removexattr_policy.hpp

@ -19,6 +19,7 @@
#pragma once
#include "fuse_removexattr_policy_base.hpp"
#include "fuse_removexattr_policy_factory.hpp"
#include "toml.hpp"

1
src/fuse_rename_policy.hpp

@ -19,6 +19,7 @@
#pragma once
#include "fuse_rename_policy_base.hpp"
#include "fuse_rename_policy_factory.hpp"
#include "toml.hpp"

13
src/fuse_rmdir_policy_all.cpp

@ -16,34 +16,29 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fuse_rmdir_func_all.hpp"
#include "fuse_rmdir_policy_all.hpp"
#include "fuse_rmdir_err.hpp"
#include "fs_rmdir.hpp"
namespace gfs = ghc::filesystem;
FUSE::RMDIR::FuncALL::FuncALL(const toml::value &toml_)
FUSE::RMDIR::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::RMDIR::FuncALL::operator()(const char *fusepath_)
FUSE::RMDIR::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::rmdir(fullpath);
}

10
src/fuse_rmdir_policy_all.hpp

@ -18,20 +18,20 @@
#pragma once
#include "fuse_rmdir_func_base.hpp"
#include "fuse_rmdir_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::RMDIR
namespace FUSE::RMDIR::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;

9
src/fuse_rmdir_policy_base.hpp

@ -18,18 +18,19 @@
#pragma once
#include "fs_path.hpp"
#include <memory>
namespace FUSE::RMDIR
namespace FUSE::RMDIR::POLICY
{
class FuncBase
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const char *fusepath) = 0;
virtual int operator()(const gfs::path &fusepath) = 0;
};
}

13
src/fuse_rmdir_policy_factory.cpp

@ -16,22 +16,23 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fuse_rmdir_func_factory.hpp"
#include "fuse_rmdir_func_all.hpp"
#include "fuse_rmdir_policy_factory.hpp"
#include "fuse_rmdir_policy_all.hpp"
#include <stdexcept>
namespace FUSE::RMDIR
namespace FUSE::RMDIR::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","rmdir","policy","all");
if(str == "all")
return std::make_shared<FuncALL>(toml_);
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}

8
src/fuse_rmdir_policy_factory.hpp

@ -18,13 +18,13 @@
#pragma once
#include "fuse_rmdir_func_base.hpp"
#include "fuse_rmdir_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::RMDIR
namespace FUSE::RMDIR::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &);
Base::Ptr
factory(const toml::value &);
}

26
src/fuse_setxattr_policy.hpp

@ -18,26 +18,34 @@
#pragma once
#include "fuse_setxattr_func_base.hpp"
#include "fuse_setxattr_policy_base.hpp"
#include "fuse_setxattr_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::SETXATTR
{
class Func
class Policy
{
public:
Func(const toml::value &);
Policy(const toml::value &toml_)
{
_setxattr = POLICY::factory(toml_);
}
public:
int operator()(const char *fusepath,
const char *attrname,
const char *attrval,
const size_t attrvalsize,
const int flags);
int
operator()(const gfs::path &fusepath_,
const char *attrname_,
const char *attrval_,
const size_t attrvalsize_,
const int flags_)
{
return (*_setxattr)(fusepath_,attrname_,attrval_,attrvalsize_,flags_);
}
private:
FuncBase::Ptr _setxattr;
POLICY::Base::Ptr _setxattr;
};
}

18
src/fuse_setxattr_policy_base.hpp

@ -18,21 +18,23 @@
#pragma once
#include "fs_path.hpp"
#include <memory>
namespace FUSE::SETXATTR
namespace FUSE::SETXATTR::POLICY
{
class FuncBase
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const char *fusepath,
const char *attrname,
const char *attrval,
const size_t attrvalsize,
const int flags) = 0;
virtual int operator()(const gfs::path &fusepath,
const char *attrname,
const char *attrval,
const size_t attrvalsize,
const int flags) = 0;
};
}

8
src/fuse_setxattr_policy_factory.hpp

@ -18,13 +18,13 @@
#pragma once
#include "fuse_setxattr_func_base.hpp"
#include "fuse_setxattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::SETXATTR
namespace FUSE::SETXATTR::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &);
Base::Ptr
factory(const toml::value &);
}

20
src/fuse_symlink_policy.hpp

@ -18,23 +18,31 @@
#pragma once
#include "fuse_symlink_func_base.hpp"
#include "fuse_symlink_policy_base.hpp"
#include "fuse_symlink_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::SYMLINK
{
class Func
class Policy
{
public:
Func(const toml::value &);
Policy(const toml::value &toml_)
{
_symlink = POLICY::factory(toml_);
}
public:
int operator()(const char *target,
const char *linkpath);
int
operator()(const gfs::path &target_,
const char *linkpath_)
{
return (*_symlink)(target_,linkpath_);
}
private:
FuncBase::Ptr _symlink;
POLICY::Base::Ptr _symlink;
};
}

12
src/fuse_symlink_policy_base.hpp

@ -18,20 +18,20 @@
#pragma once
#include "fuse.h"
#include "fs_path.hpp"
#include <memory>
namespace FUSE::SYMLINK
namespace FUSE::SYMLINK::POLICY
{
class FuncBase
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const char *target,
const char *linkpath) = 0;
virtual int operator()(const gfs::path &target,
const char *linkpath) = 0;
};
}

8
src/fuse_symlink_policy_factory.hpp

@ -18,13 +18,13 @@
#pragma once
#include "fuse_symlink_func_base.hpp"
#include "fuse_symlink_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::SYMLINK
namespace FUSE::SYMLINK::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &);
Base::Ptr
factory(const toml::value &);
}

20
src/fuse_truncate_policy.hpp

@ -18,23 +18,31 @@
#pragma once
#include "fuse_truncate_func_base.hpp"
#include "fuse_truncate_policy_base.hpp"
#include "fuse_truncate_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::TRUNCATE
{
class Func
class Policy
{
public:
Func(const toml::value &);
Policy(const toml::value &toml_)
{
_truncate = POLICY::factory(toml_);
}
public:
int operator()(const char *fusepath,
const off_t length);
int
operator()(const gfs::path &fusepath_,
const off_t length_)
{
return (*_truncate)(fusepath_,length_);
}
private:
FuncBase::Ptr _truncate;
POLICY::Base::Ptr _truncate;
};
}

12
src/fuse_truncate_policy_all.hpp

@ -18,21 +18,21 @@
#pragma once
#include "fuse_truncate_func_base.hpp"
#include "fuse_truncate_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::TRUNCATE
namespace FUSE::TRUNCATE::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 off_t length) final;
int operator()(const gfs::path &fusepath,
const off_t length) final;
private:
Branches2 _branches;

11
src/fuse_truncate_policy_base.hpp

@ -18,21 +18,22 @@
#pragma once
#include "fs_path.hpp"
#include <memory>
#include <sys/types.h>
namespace FUSE::TRUNCATE
namespace FUSE::TRUNCATE::POLICY
{
class FuncBase
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const char *fusepath,
const off_t length) = 0;
virtual int operator()(const gfs::path &fusepath,
const off_t length) = 0;
};
}

12
src/fuse_truncate_policy_factory.cpp

@ -16,22 +16,22 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fuse_truncate_func_factory.hpp"
#include "fuse_truncate_func_all.hpp"
#include "fuse_truncate_policy_factory.hpp"
#include "fuse_truncate_policy_all.hpp"
#include <stdexcept>
namespace FUSE::TRUNCATE
namespace FUSE::TRUNCATE::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","truncate","policy","all");
if(str == "all")
return std::make_shared<FuncALL>(toml_);
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}

8
src/fuse_truncate_policy_factory.hpp

@ -18,13 +18,13 @@
#pragma once
#include "fuse_truncate_func_base.hpp"
#include "fuse_truncate_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::TRUNCATE
namespace FUSE::TRUNCATE::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &);
Base::Ptr
factory(const toml::value &);
}

18
src/fuse_unlink_policy.hpp

@ -18,22 +18,30 @@
#pragma once
#include "fuse_unlink_func_base.hpp"
#include "fuse_unlink_policy_base.hpp"
#include "fuse_unlink_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::UNLINK
{
class Func
class Policy
{
public:
Func(const toml::value &);
Policy(const toml::value &toml_)
{
_unlink = POLICY::factory(toml_);
}
public:
int operator()(const char *fusepath);
int
operator()(const gfs::path &fusepath_)
{
return (*_unlink)(fusepath_);
}
private:
FuncBase::Ptr _unlink;
POLICY::Base::Ptr _unlink;
};
}

9
src/fuse_unlink_policy_base.hpp

@ -18,18 +18,19 @@
#pragma once
#include "fs_path.hpp"
#include <memory>
namespace FUSE::UNLINK
namespace FUSE::UNLINK::POLICY
{
class FuncBase
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const char *fusepath) = 0;
virtual int operator()(const gfs::path &fusepath) = 0;
};
}

8
src/fuse_unlink_policy_factory.hpp

@ -18,13 +18,13 @@
#pragma once
#include "fuse_unlink_func_base.hpp"
#include "fuse_unlink_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::UNLINK
namespace FUSE::UNLINK::POLICY
{
FuncBase::Ptr
FuncFactory(const toml::value &);
Base::Ptr
factory(const toml::value &);
}
Loading…
Cancel
Save