Browse Source

checkpoint

toml
Antonio SJ Musumeci 3 years ago
parent
commit
c8e8865495
  1. 2
      src/fuse_access_policy_factory.cpp
  2. 2
      src/fuse_access_policy_factory.hpp
  3. 2
      src/fuse_chmod_policy_factory.cpp
  4. 2
      src/fuse_chmod_policy_factory.hpp
  5. 8
      src/fuse_getattr_policy_factory.cpp
  6. 4
      src/fuse_getattr_policy_ff.hpp
  7. 3
      src/fuse_link_policy_factory.cpp
  8. 2
      src/fuse_removexattr_policy_base.hpp
  9. 4
      src/fuse_setxattr_policy_factory.cpp
  10. 10
      src/fuse_symlink_policy_epff.hpp
  11. 18
      src/fuse_symlink_policy_factory.cpp
  12. 15
      src/fuse_symlink_policy_ff.cpp
  13. 10
      src/fuse_symlink_policy_ff.hpp
  14. 13
      src/fuse_truncate_policy_all.cpp
  15. 12
      src/fuse_unlink_policy_factory.cpp
  16. 10
      src/fuse_utimens_policy_all.hpp
  17. 9
      src/fuse_utimens_policy_base.hpp
  18. 12
      src/fuse_utimens_policy_factory.cpp
  19. 8
      src/fuse_utimens_policy_factory.hpp

2
src/fuse_access_policy_factory.cpp

@ -25,7 +25,7 @@
namespace FUSE::ACCESS::POLICY namespace FUSE::ACCESS::POLICY
{ {
Base::Ptr Base::Ptr
Factory(const toml::value &toml_)
factory(const toml::value &toml_)
{ {
std::string str; std::string str;

2
src/fuse_access_policy_factory.hpp

@ -26,5 +26,5 @@
namespace FUSE::ACCESS::POLICY namespace FUSE::ACCESS::POLICY
{ {
Base::Ptr Base::Ptr
Factory(const toml::value &);
factory(const toml::value &);
} }

2
src/fuse_chmod_policy_factory.cpp

@ -25,7 +25,7 @@
namespace FUSE::CHMOD::POLICY namespace FUSE::CHMOD::POLICY
{ {
Base::Ptr Base::Ptr
Factory(const toml::value &toml_)
factory(const toml::value &toml_)
{ {
std::string str; std::string str;

2
src/fuse_chmod_policy_factory.hpp

@ -26,5 +26,5 @@
namespace FUSE::CHMOD::POLICY namespace FUSE::CHMOD::POLICY
{ {
Base::Ptr Base::Ptr
Factory(const toml::value &);
factory(const toml::value &);
} }

8
src/fuse_getattr_policy_factory.cpp

@ -35,13 +35,13 @@ namespace FUSE::GETATTR::POLICY
str = toml::find_or(toml_,"func","getattr","policy","ff"); str = toml::find_or(toml_,"func","getattr","policy","ff");
if(str == "ff") if(str == "ff")
return std::make_shared<FuncFF>(toml_);
return std::make_shared<FF>(toml_);
if(str == "newest") if(str == "newest")
return std::make_shared<FuncNewest>(toml_);
return std::make_shared<Newest>(toml_);
if(str == "aggregate") if(str == "aggregate")
return std::make_shared<FuncAggregate>(toml_);
return std::make_shared<Aggregate>(toml_);
if(str == "check-ff") if(str == "check-ff")
return std::make_shared<FuncCheckFF>(toml_);
return std::make_shared<CheckFF>(toml_);
throw std::runtime_error(""); throw std::runtime_error("");
} }

4
src/fuse_getattr_policy_ff.hpp

@ -26,12 +26,12 @@
#include "toml.hpp" #include "toml.hpp"
namespace FUSE::GETATTR
namespace FUSE::GETATTR::POLICY
{ {
class FF : public Base class FF : public Base
{ {
public: public:
FF(const toml::value&);
FF(const toml::value &);
public: public:
int operator()(const gfs::path &fusepath, int operator()(const gfs::path &fusepath,

3
src/fuse_link_policy_factory.cpp

@ -17,7 +17,8 @@
*/ */
#include "fuse_link_policy_factory.hpp" #include "fuse_link_policy_factory.hpp"
#include "fuse_link_all_all.hpp"
#include "fuse_link_policy_all.hpp"
#include <stdexcept> #include <stdexcept>

2
src/fuse_removexattr_policy_base.hpp

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

4
src/fuse_setxattr_policy_factory.cpp

@ -25,13 +25,13 @@
namespace FUSE::SETXATTR namespace FUSE::SETXATTR
{ {
FuncBase::Ptr FuncBase::Ptr
FuncFactory(const toml::value &toml_)
factory(const toml::value &toml_)
{ {
std::string str; std::string str;
str = toml::find_or(toml_,"func","setxattr","policy","all"); str = toml::find_or(toml_,"func","setxattr","policy","all");
if(str == "all") if(str == "all")
return std::make_shared<FuncALL>(toml_);
return std::make_shared<ALL>(toml_);
throw std::runtime_error(""); throw std::runtime_error("");
} }

10
src/fuse_symlink_policy_epff.hpp

@ -18,20 +18,20 @@
#pragma once #pragma once
#include "fuse_symlink_func_base.hpp"
#include "fuse_symlink_policy_base.hpp"
#include "branches.hpp" #include "branches.hpp"
namespace FUSE::SYMLINK
namespace FUSE::SYMLINK::POLICY
{ {
class FuncEPFF : public FuncBase
class EPFF : public Base
{ {
public: public:
FuncEPFF(const toml::value&);
EPFF(const toml::value &);
public: public:
int operator()(const char *target,
int operator()(const gfs::path &target,
const char *linkpath) final; const char *linkpath) final;
private: private:

18
src/fuse_symlink_policy_factory.cpp

@ -16,24 +16,26 @@
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_factory.hpp"
#include "fuse_symlink_func_ff.hpp"
#include "fuse_symlink_func_epff.hpp"
#include "fuse_symlink_policy_factory.hpp"
#include "fuse_symlink_policy_ff.hpp"
#include "fuse_symlink_policy_epff.hpp"
#include <stdexcept> #include <stdexcept>
namespace FUSE::SYMLINK
namespace FUSE::SYMLINK::POLICY
{ {
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
Base::Ptr
factory(const toml::value &toml_)
{ {
std::string str; std::string str;
str = toml::find_or(toml_,"func","symlink","policy","ff"); str = toml::find_or(toml_,"func","symlink","policy","ff");
if(str == "ff") if(str == "ff")
return std::make_shared<FuncFF>(toml_);
return std::make_shared<FF>(toml_);
if(str == "epff") if(str == "epff")
return std::make_shared<FuncEPFF>(toml_);
return std::make_shared<EPFF>(toml_);
throw std::runtime_error(""); throw std::runtime_error("");
} }

15
src/fuse_symlink_policy_ff.cpp

@ -16,7 +16,7 @@
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_ff.hpp"
#include "fuse_symlink_policy_ff.hpp"
#include "fs_clonepath.hpp" #include "fs_clonepath.hpp"
#include "fs_clonepath_branches.hpp" #include "fs_clonepath_branches.hpp"
@ -24,29 +24,24 @@
#include "ugid.hpp" #include "ugid.hpp"
namespace gfs = ghc::filesystem;
FUSE::SYMLINK::FuncFF::FuncFF(const toml::value &toml_)
FUSE::SYMLINK::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_) : _branches(toml_)
{ {
} }
int int
FUSE::SYMLINK::FuncFF::operator()(const char *target_,
const char *linkpath_)
FUSE::SYMLINK::POLICY::FF::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)

10
src/fuse_symlink_policy_ff.hpp

@ -18,20 +18,20 @@
#pragma once #pragma once
#include "fuse_symlink_func_base.hpp"
#include "fuse_symlink_policy_base.hpp"
#include "branches.hpp" #include "branches.hpp"
namespace FUSE::SYMLINK
namespace FUSE::SYMLINK::POLICY
{ {
class FuncFF : public FuncBase
class FF : public Base
{ {
public: public:
FuncFF(const toml::value&);
FF(const toml::value &);
public: public:
int operator()(const char *target,
int operator()(const gfs::path &target,
const char *linkpath) final; const char *linkpath) final;
private: private:

13
src/fuse_truncate_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_truncate_func_all.hpp"
#include "fuse_truncate_policy_all.hpp"
#include "fuse_truncate_err.hpp" #include "fuse_truncate_err.hpp"
#include "fs_truncate.hpp" #include "fs_truncate.hpp"
namespace gfs = ghc::filesystem;
FUSE::TRUNCATE::FuncALL::FuncALL(const toml::value &toml_)
FUSE::TRUNCATE::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_) : _branches(toml_)
{ {
} }
int int
FUSE::TRUNCATE::FuncALL::operator()(const char *fusepath_,
FUSE::TRUNCATE::POLICY::ALL::operator()(const gfs::path &fusepath_,
const off_t length_) const off_t length_)
{ {
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::truncate(fullpath,length_); rv = fs::truncate(fullpath,length_);
} }

12
src/fuse_unlink_policy_factory.cpp

@ -16,22 +16,22 @@
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_factory.hpp"
#include "fuse_unlink_func_all.hpp"
#include "fuse_unlink_policy_factory.hpp"
#include "fuse_unlink_policy_all.hpp"
#include <stdexcept> #include <stdexcept>
namespace FUSE::UNLINK
namespace FUSE::UNLINK::POLICY
{ {
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
Base::Ptr
factory(const toml::value &toml_)
{ {
std::string str; std::string str;
str = toml::find_or(toml_,"func","unlink","policy","all"); str = toml::find_or(toml_,"func","unlink","policy","all");
if(str == "all") if(str == "all")
return std::make_shared<FuncALL>(toml_);
return std::make_shared<ALL>(toml_);
throw std::runtime_error(""); throw std::runtime_error("");
} }

10
src/fuse_utimens_policy_all.hpp

@ -18,20 +18,20 @@
#pragma once #pragma once
#include "fuse_utimens_func_base.hpp"
#include "fuse_utimens_policy_base.hpp"
#include "branches.hpp" #include "branches.hpp"
namespace FUSE::UTIMENS
namespace FUSE::UTIMENS::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 timespec ts[2]) final; const timespec ts[2]) final;
private: private:

9
src/fuse_utimens_policy_base.hpp

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

12
src/fuse_utimens_policy_factory.cpp

@ -16,22 +16,22 @@
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_factory.hpp"
#include "fuse_utimens_func_all.hpp"
#include "fuse_utimens_policy_factory.hpp"
#include "fuse_utimens_policy_all.hpp"
#include <stdexcept> #include <stdexcept>
namespace FUSE::UTIMENS
namespace FUSE::UTIMENS::POLICY
{ {
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
Base::Ptr
factory(const toml::value &toml_)
{ {
std::string str; std::string str;
str = toml::find_or(toml_,"func","utimens","policy","all"); str = toml::find_or(toml_,"func","utimens","policy","all");
if(str == "all") if(str == "all")
return std::make_shared<FuncALL>(toml_);
return std::make_shared<ALL>(toml_);
throw std::runtime_error(""); throw std::runtime_error("");
} }

8
src/fuse_utimens_policy_factory.hpp

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