Browse Source

checkpoint

toml
Antonio SJ Musumeci 3 years ago
parent
commit
551ee1ab05
  1. 2417
      src/EmbeddableWebServer.h
  2. 40
      src/fuse_access_policy.hpp
  3. 37
      src/fuse_access_policy_base.hpp
  4. 38
      src/fuse_access_policy_factory.cpp
  5. 30
      src/fuse_access_policy_factory.hpp
  6. 52
      src/fuse_access_policy_ff.cpp
  7. 40
      src/fuse_access_policy_ff.hpp
  8. 42
      src/fuse_chmod_policy.hpp
  9. 49
      src/fuse_chmod_policy_all.cpp
  10. 40
      src/fuse_chmod_policy_all.hpp
  11. 37
      src/fuse_chmod_policy_base.hpp
  12. 38
      src/fuse_chmod_policy_factory.cpp
  13. 30
      src/fuse_chmod_policy_factory.hpp
  14. 43
      src/fuse_chown_policy.hpp
  15. 50
      src/fuse_chown_policy_all.cpp
  16. 41
      src/fuse_chown_policy_all.hpp
  17. 40
      src/fuse_chown_policy_base.hpp
  18. 38
      src/fuse_chown_policy_factory.cpp
  19. 30
      src/fuse_chown_policy_factory.hpp
  20. 42
      src/fuse_create_policy.hpp
  21. 41
      src/fuse_create_policy_base.hpp
  22. 68
      src/fuse_create_policy_epff.cpp
  23. 44
      src/fuse_create_policy_epff.hpp
  24. 40
      src/fuse_create_policy_factory.cpp
  25. 30
      src/fuse_create_policy_factory.hpp
  26. 86
      src/fuse_create_policy_ff.cpp
  27. 42
      src/fuse_create_policy_ff.hpp
  28. 45
      src/fuse_getattr_policy.hpp
  29. 75
      src/fuse_getattr_policy_aggregate.cpp
  30. 45
      src/fuse_getattr_policy_aggregate.hpp
  31. 42
      src/fuse_getattr_policy_base.hpp
  32. 95
      src/fuse_getattr_policy_check_ff.cpp
  33. 45
      src/fuse_getattr_policy_check_ff.hpp
  34. 48
      src/fuse_getattr_policy_factory.cpp
  35. 29
      src/fuse_getattr_policy_factory.hpp
  36. 53
      src/fuse_getattr_policy_ff.cpp
  37. 45
      src/fuse_getattr_policy_ff.hpp
  38. 62
      src/fuse_getattr_policy_newest.cpp
  39. 45
      src/fuse_getattr_policy_newest.hpp
  40. 48
      src/fuse_getxattr_policy.hpp
  41. 41
      src/fuse_getxattr_policy_base.hpp
  42. 39
      src/fuse_getxattr_policy_factory.cpp
  43. 30
      src/fuse_getxattr_policy_factory.hpp
  44. 54
      src/fuse_getxattr_policy_ff.cpp
  45. 45
      src/fuse_getxattr_policy_ff.hpp
  46. 43
      src/fuse_ioctl_policy.hpp
  47. 52
      src/fuse_ioctl_policy_all.cpp
  48. 43
      src/fuse_ioctl_policy_all.hpp
  49. 40
      src/fuse_ioctl_policy_base.hpp
  50. 38
      src/fuse_ioctl_policy_factory.cpp
  51. 30
      src/fuse_ioctl_policy_factory.hpp
  52. 48
      src/fuse_link_policy.hpp
  53. 67
      src/fuse_link_policy_all.cpp
  54. 40
      src/fuse_link_policy_all.hpp
  55. 40
      src/fuse_link_policy_base.hpp
  56. 38
      src/fuse_link_policy_factory.cpp
  57. 30
      src/fuse_link_policy_factory.hpp
  58. 47
      src/fuse_listxattr_policy.hpp
  59. 38
      src/fuse_listxattr_policy_base.hpp
  60. 39
      src/fuse_listxattr_policy_factory.cpp
  61. 29
      src/fuse_listxattr_policy_factory.hpp
  62. 53
      src/fuse_listxattr_policy_ff.cpp
  63. 43
      src/fuse_listxattr_policy_ff.hpp
  64. 47
      src/fuse_mkdir_policy.hpp
  65. 40
      src/fuse_mkdir_policy_base.hpp
  66. 52
      src/fuse_mkdir_policy_epff.cpp
  67. 41
      src/fuse_mkdir_policy_epff.hpp
  68. 41
      src/fuse_mkdir_policy_factory.cpp
  69. 30
      src/fuse_mkdir_policy_factory.hpp
  70. 58
      src/fuse_mkdir_policy_ff.cpp
  71. 41
      src/fuse_mkdir_policy_ff.hpp
  72. 50
      src/fuse_mknod_policy.hpp
  73. 44
      src/fuse_mknod_policy_base.hpp
  74. 64
      src/fuse_mknod_policy_epff.cpp
  75. 42
      src/fuse_mknod_policy_epff.hpp
  76. 41
      src/fuse_mknod_policy_factory.cpp
  77. 30
      src/fuse_mknod_policy_factory.hpp
  78. 81
      src/fuse_mknod_policy_ff.cpp
  79. 42
      src/fuse_mknod_policy_ff.hpp
  80. 52
      src/fuse_open_policy.hpp
  81. 39
      src/fuse_open_policy_base.hpp
  82. 39
      src/fuse_open_policy_factory.cpp
  83. 30
      src/fuse_open_policy_factory.hpp
  84. 57
      src/fuse_open_policy_ff.cpp
  85. 42
      src/fuse_open_policy_ff.hpp
  86. 52
      src/fuse_readlink_policy.hpp
  87. 36
      src/fuse_readlink_policy_base.hpp
  88. 38
      src/fuse_readlink_policy_factory.cpp
  89. 30
      src/fuse_readlink_policy_factory.hpp
  90. 53
      src/fuse_readlink_policy_ff.cpp
  91. 43
      src/fuse_readlink_policy_ff.hpp
  92. 47
      src/fuse_removexattr_policy.hpp
  93. 49
      src/fuse_removexattr_policy_all.cpp
  94. 40
      src/fuse_removexattr_policy_all.hpp
  95. 35
      src/fuse_removexattr_policy_base.hpp
  96. 38
      src/fuse_removexattr_policy_factory.cpp
  97. 30
      src/fuse_removexattr_policy_factory.hpp
  98. 47
      src/fuse_rename_policy.hpp
  99. 51
      src/fuse_rename_policy_all.cpp
  100. 42
      src/fuse_rename_policy_all.hpp

2417
src/EmbeddableWebServer.h
File diff suppressed because it is too large
View File

40
src/fuse_access_policy.hpp

@ -0,0 +1,40 @@
/*
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 "fuse_access_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const int mask);
private:
POLICY::Base::Ptr _access;
};
}

37
src/fuse_access_policy_base.hpp

@ -0,0 +1,37 @@
/*
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 <memory>
namespace FUSE::ACCESS::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const int mask) = 0;
};
}

38
src/fuse_access_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_access_policy_factory.hpp"
#include "fuse_access_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::ACCESS::POLICY
{
Base::Ptr
Factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","access","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_access_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_access_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS::POLICY
{
Base::Ptr
Factory(const toml::value &);
}

52
src/fuse_access_policy_ff.cpp

@ -0,0 +1,52 @@
/*
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_access_policy_ff.hpp"
#include "fs_eaccess.hpp"
FUSE::ACCESS::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::ACCESS::POLICY::FF::operator()(const gfs::path &fusepath_,
const int mode_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::eaccess(fullpath,mode_);
if(rv != 0)
continue;
return 0;
}
}
return -errno;
}

40
src/fuse_access_policy_ff.hpp

@ -0,0 +1,40 @@
/*
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 "fuse_access_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::ACCESS::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const int mode) final;
private:
Branches2 _branches;
};
}

42
src/fuse_chmod_policy.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_chmod_policy_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHMOD
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode);
private:
POLICY::Base::Ptr _chmod;
};
}

49
src/fuse_chmod_policy_all.cpp

@ -0,0 +1,49 @@
/*
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_chmod_policy_all.hpp"
#include "fuse_chmod_err.hpp"
#include "fs_lchmod.hpp"
FUSE::CHMOD::POLICY::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHMOD::POLICYALL::operator()(const gfs::path &fusepath_,
const mode_t mode_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lchmod(fullpath,mode_);
}
}
return rv;
}

40
src/fuse_chmod_policy_all.hpp

@ -0,0 +1,40 @@
/*
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 "fuse_chmod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CHMOD::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode) final;
private:
Branches2 _branches;
};
}

37
src/fuse_chmod_policy_base.hpp

@ -0,0 +1,37 @@
/*
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 <memory>
namespace FUSE::CHMOD::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode) = 0;
};
}

38
src/fuse_chmod_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_chmod_policy_factory.hpp"
#include "fuse_chmod_policy_all.hpp"
#include <stdexcept>
namespace FUSE::CHMOD::POLICY
{
Base::Ptr
Factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chmod","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_chmod_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_chmod_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CHMOD::POLICY
{
Base::Ptr
Factory(const toml::value &);
}

43
src/fuse_chown_policy.hpp

@ -0,0 +1,43 @@
/*
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 "fuse_chown_policy_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHOWN
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid);
private:
POLICY::Base::Ptr _chown;
};
}

50
src/fuse_chown_policy_all.cpp

@ -0,0 +1,50 @@
/*
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_chown_policy_all.hpp"
#include "fuse_chown_err.hpp"
#include "fs_lchown.hpp"
FUSE::CHOWN::POLICY::all::all(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHOWN::POLICY::all::operator()(const gfs::path &fusepath_,
const uid_t uid_,
const gid_t gid_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lchown(fullpath,uid_,gid_);
}
}
return rv;
}

41
src/fuse_chown_policy_all.hpp

@ -0,0 +1,41 @@
/*
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 "fuse_chown_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CHOWN::POLICY
{
class all : public base
{
public:
all(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid) final;
private:
Branches2 _branches;
};
}

40
src/fuse_chown_policy_base.hpp

@ -0,0 +1,40 @@
/*
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 <memory>
#include <unistd.h>
namespace FUSE::CHOWN::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid) = 0;
};
}

38
src/fuse_chown_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_chown_policy_factory.hpp"
#include "fuse_chown_policy_all.hpp"
#include <stdexcept>
namespace FUSE::CHOWN::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chown","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_chown_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_chown_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CHOWN::POLICY
{
Base::Ptr
factory(const toml::value &);
}

42
src/fuse_create_policy.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_create_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi);
private:
POLICY::Base::Ptr _create;
};
}

41
src/fuse_create_policy_base.hpp

@ -0,0 +1,41 @@
/*
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.h"
#include <memory>
namespace FUSE::CREATE::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) = 0;
};
}

68
src/fuse_create_policy_epff.cpp

@ -0,0 +1,68 @@
/*
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_create_policy_epff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_open.hpp"
FUSE::CREATE::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
continue;
if(rv >= 0)
mode &= umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
if(rv == -ENOENT)
continue;
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

44
src/fuse_create_policy_epff.hpp

@ -0,0 +1,44 @@
/*
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 "fuse_create_policy_base.hpp"
#include "branches.hpp"
#include "fs_path.hpp"
namespace FUSE::CREATE::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

40
src/fuse_create_policy_factory.cpp

@ -0,0 +1,40 @@
/*
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_create_policy_factory.hpp"
#include "fuse_create_policy_ff.hpp"
#include "fuse_create_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::CREATE::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","create","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_create_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_create_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE::POLICY
{
Base::Ptr
factory(const toml::value &);
}

86
src/fuse_create_policy_ff.cpp

@ -0,0 +1,86 @@
/*
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_create_policy_ff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_clonepath.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_open.hpp"
#include "ugid.hpp"
FUSE::CREATE::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = fs::acl::dir_has_defaults(fullpath);
}
if(rv >= 0)
mode &= ~umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
{
rv = fs::acl::dir_has_defaults(fullpath);
if(rv >= 0)
mode &= ~umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
}
}
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

42
src/fuse_create_policy_ff.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_create_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CREATE::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

45
src/fuse_getattr_policy.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETATTR
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout);
private:
POLICY::Base::Ptr _getattr;
};
}

75
src/fuse_getattr_policy_aggregate.cpp

@ -0,0 +1,75 @@
/*
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_policy_aggregate.hpp"
#include "timespec.hpp"
#include <limits.h>
FUSE::GETATTR::POLICY::Aggregate::Aggregate(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::Aggregate::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
gfs::path fullpath;
struct stat st = {0};
st_->st_mtime = std::numeric_limits<time_t>::min();
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st_->st_mtime == std::numeric_limits<time_t>::min())
{
*st_ = st;
}
else
{
st_->st_nlink += st.st_nlink;
if(st_->st_atim < st.st_atim)
st_->st_atim = st.st_atim;
if(st_->st_mtim < st.st_mtim)
st_->st_mtim = st.st_mtim;
if(st_->st_ctim < st.st_ctim)
st_->st_ctim = st.st_ctim;
}
}
}
if(st_->st_mtime == std::numeric_limits<time_t>::min())
return -ENOENT;
return 0;
}

45
src/fuse_getattr_policy_aggregate.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class Aggregate : public Base
{
public:
Aggregate(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

42
src/fuse_getattr_policy_base.hpp

@ -0,0 +1,42 @@
/*
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::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) = 0;
};
}

95
src/fuse_getattr_policy_check_ff.cpp

@ -0,0 +1,95 @@
/*
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_policy_check_ff.hpp"
#include <cstdio>
namespace l
{
static
void
alert(const gfs::path &fullpath_,
const char *attr_,
const uint64_t val1_,
const uint64_t val2_)
{
fprintf(stderr,
"%s: %s - %lx != %lx",
fullpath_.c_str(),
attr_,
val1_,
val2_);
}
}
FUSE::GETATTR::POLICY::CheckFF::CheckFF(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::CheckFF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
size_t i, ei;
size_t j, ej;
gfs::path fullpath;
struct stat st = {0};
for(i = 0, ei = _branches.size(); i < ei; i++)
{
for(j = 0, ej = _branches[i].size(); j < ej; j++)
{
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
j++;
*st_ = st;
goto main_loop;
}
}
main_loop:
for(; i < ei; i++)
{
for(; j < ej; j++)
{
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st.st_mode != st_->st_mode)
l::alert(fullpath,"mode",st_->st_mode,st.st_mode);
}
}
return 0;
}

45
src/fuse_getattr_policy_check_ff.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class CheckFF : public Base
{
public:
CheckFF(const toml::value&);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

48
src/fuse_getattr_policy_factory.cpp

@ -0,0 +1,48 @@
/*
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_policy_factory.hpp"
#include "fuse_getattr_policy_base.hpp"
#include "fuse_getattr_policy_ff.hpp"
#include "fuse_getattr_policy_newest.hpp"
#include "fuse_getattr_policy_aggregate.hpp"
#include "fuse_getattr_policy_check_ff.hpp"
#include <stdexcept>
namespace FUSE::GETATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","getattr","policy","ff");
if(str == "ff")
return std::make_shared<FuncFF>(toml_);
if(str == "newest")
return std::make_shared<FuncNewest>(toml_);
if(str == "aggregate")
return std::make_shared<FuncAggregate>(toml_);
if(str == "check-ff")
return std::make_shared<FuncCheckFF>(toml_);
throw std::runtime_error("");
}
}

29
src/fuse_getattr_policy_factory.hpp

@ -0,0 +1,29 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

53
src/fuse_getattr_policy_ff.cpp

@ -0,0 +1,53 @@
/*
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_policy_ff.hpp"
FUSE::GETATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,st_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

45
src/fuse_getattr_policy_ff.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR
{
class FF : public Base
{
public:
FF(const toml::value&);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

62
src/fuse_getattr_policy_newest.cpp

@ -0,0 +1,62 @@
/*
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_policy_newest.hpp"
#include <limits.h>
FUSE::GETATTR::POLICY::Newest::Newest(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::Newest::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
struct stat st;
gfs::path fullpath;
st_->st_mtime = std::numeric_limits<time_t>::min();
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st_->st_mtime < st.st_mtime)
continue;
*st_ = st;
}
}
if(st_->st_mtime == std::numeric_limits<time_t>::min())
return -ENOENT;
return 0;
}

45
src/fuse_getattr_policy_newest.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class Newest : public Base
{
public:
Newest(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

48
src/fuse_getxattr_policy.hpp

@ -0,0 +1,48 @@
/*
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 "fuse_getxattr_policy_base.hpp"
#include "fuse_timeouts.h"
#include "toml.hpp"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETXATTR
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count);
private:
POLICY::Base::Ptr _getxattr;
};
}

41
src/fuse_getxattr_policy_base.hpp

@ -0,0 +1,41 @@
/*
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 <memory>
#include <sys/stat.h>
namespace FUSE::GETXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) = 0;
};
}

39
src/fuse_getxattr_policy_factory.cpp

@ -0,0 +1,39 @@
/*
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_getxattr_policy_factory.hpp"
#include "fuse_getxattr_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::GETXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","getxattr","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_getxattr_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_getxattr_func_base.hpp"
#include "toml.hpp"
namespace FUSE::GETXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

54
src/fuse_getxattr_policy_ff.cpp

@ -0,0 +1,54 @@
/*
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_getxattr_policy_ff.hpp"
#include "fs_lgetxattr.hpp"
FUSE::GETXATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::GETXATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lgetxattr(fullpath,attrname_,buf_,count_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

45
src/fuse_getxattr_policy_ff.hpp

@ -0,0 +1,45 @@
/*
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 "fuse_getxattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETXATTR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) final;
private:
Branches2 _branches;
};
}

43
src/fuse_ioctl_policy.hpp

@ -0,0 +1,43 @@
/*
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 "fuse_ioctl_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::IOCTL
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const fuse_file_info_t *ffi_,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz);
private:
POLICY::Base::Ptr _ioctl;
};
}

52
src/fuse_ioctl_policy_all.cpp

@ -0,0 +1,52 @@
/*
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_ioctl_policy_all.hpp"
#include "fuse_ioctl_err.hpp"
#include "fs_ioctl.hpp"
FUSE::IOCTL::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::IOCTL::POLICY::ALL::operator()(const fuse_file_info_t *ffi_,
const unsigned long cmd_,
const unsigned int flags_,
void *data_,
uint32_t *out_bufsz_)
{
Err rv;
gfs::path fusepath;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath;
}
}
return rv;
}

43
src/fuse_ioctl_policy_all.hpp

@ -0,0 +1,43 @@
/*
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 "fuse_ioctl_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::IOCTL::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const fuse_file_info_t *ffi,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz) final;
private:
Branches2 _branches;
};
}

40
src/fuse_ioctl_policy_base.hpp

@ -0,0 +1,40 @@
/*
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 "fuse.h"
#include <memory>
namespace FUSE::IOCTL::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const fuse_file_info_t *ffi,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz) = 0;
};
}

38
src/fuse_ioctl_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_ioctl_policy_factory.hpp"
#include "fuse_ioctl_policy_all.hpp"
#include <stdexcept>
namespace FUSE::IOCTL::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","ioctl","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_ioctl_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_ioctl_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::IOCTL::POLICY
{
Base::Ptr
factory(const toml::value &);
}

48
src/fuse_link_policy.hpp

@ -0,0 +1,48 @@
/*
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 "fuse_link_policy_base.hpp"
#include "fuse_link_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::LINK
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_link = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
return (*_link)(oldpath_,newpath_);
}
private:
POLICY::Base::Ptr _link;
};
}

67
src/fuse_link_policy_all.cpp

@ -0,0 +1,67 @@
/*
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_link_policy_all.hpp"
#include "fuse_link_err.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_exists.hpp"
#include "fs_link.hpp"
FUSE::LINK::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::LINK::POLICY::ALL::operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
int rv;
Err err;
gfs::path fulloldpath;
gfs::path fullnewpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fulloldpath = branch.path / oldpath_;
fullnewpath = branch.path / newpath_;
rv = fs::link(fulloldpath,fullnewpath);
if(rv == -ENOENT)
{
if(!fs::exists(fulloldpath))
continue;
rv = fs::clonepath_as_root(_branches,branch.path,newpath_.parent_path());
if(rv < 0)
continue;
rv = fs::link(fulloldpath,fullnewpath);
}
err = rv;
}
}
return err;
}

40
src/fuse_link_policy_all.hpp

@ -0,0 +1,40 @@
/*
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 "fuse_link_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::LINK::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value&);
public:
int operator()(const gfs::path &oldpath,
const gfs::path &newpath) final;
private:
Branches2 _branches;
};
}

40
src/fuse_link_policy_base.hpp

@ -0,0 +1,40 @@
/*
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.h"
#include <memory>
namespace FUSE::LINK::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &oldpath,
const gfs::path &newpath) = 0;
};
}

38
src/fuse_link_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_link_policy_factory.hpp"
#include "fuse_link_all_all.hpp"
#include <stdexcept>
namespace FUSE::LINK::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","link","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_link_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_link_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::LINK::POLICY
{
Base::Ptr
factory(const toml::value &);
}

47
src/fuse_listxattr_policy.hpp

@ -0,0 +1,47 @@
/*
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 "fuse_listxattr_policy_base.hpp"
#include "fuse_listxattr_policy_factory.hpp"
namespace FUSE::LISTXATTR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_listxattr = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
char *buf_,
size_t count_)
{
return (*_listxattr)(fusepath_,list_,size_);
}
private:
POLICY::Base::Ptr _listxattr;
};
}

38
src/fuse_listxattr_policy_base.hpp

@ -0,0 +1,38 @@
/*
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 <memory>
namespace FUSE::LISTXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
char *list,
const size_t size) = 0;
};
}

39
src/fuse_listxattr_policy_factory.cpp

@ -0,0 +1,39 @@
/*
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_listxattr_policy_factory.hpp"
#include "fuse_listxattr_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::LISTXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","listxattr","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

29
src/fuse_listxattr_policy_factory.hpp

@ -0,0 +1,29 @@
/*
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 "fuse_listxattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::LISTXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

53
src/fuse_listxattr_policy_ff.cpp

@ -0,0 +1,53 @@
/*
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_listxattr_policy_ff.hpp"
#include "fs_llistxattr.hpp"
FUSE::LISTXATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::LISTXATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
char *list_,
const size_t size_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::llistxattr(fullpath,list_,size_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

43
src/fuse_listxattr_policy_ff.hpp

@ -0,0 +1,43 @@
/*
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 "fuse_listxattr_policy_base.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::LISTXATTR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
char *list,
const size_t size) final;
private:
Branches2 _branches;
};
}

47
src/fuse_mkdir_policy.hpp

@ -0,0 +1,47 @@
/*
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 "fuse_mkdir_func_base.hpp"
#include "toml.hpp"
namespace FUSE::MKDIR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_mkdir = POLICY::factory(toml_);
}
public:
int operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
return (*_mkdir)(fusepath_,mode_,umask_);
}
private:
FuncBase::Ptr _mkdir;
};
}

40
src/fuse_mkdir_policy_base.hpp

@ -0,0 +1,40 @@
/*
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.h"
#include <memory>
namespace FUSE::MKDIR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) = 0;
};
}

52
src/fuse_mkdir_policy_epff.cpp

@ -0,0 +1,52 @@
/*
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_mkdir_policy_epff.hpp"
#include "fuse_mkdir_mkdir.hpp"
FUSE::MKDIR::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKDIR::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

41
src/fuse_mkdir_policy_epff.hpp

@ -0,0 +1,41 @@
/*
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 "fuse_mkdir_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKDIR::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) final;
private:
Branches2 _branches;
};
}

41
src/fuse_mkdir_policy_factory.cpp

@ -0,0 +1,41 @@
/*
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_mkdir_policy_factory.hpp"
#include "fuse_mkdir_policy_ff.hpp"
#include "fuse_mkdir_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::MKDIR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","mkdir","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_mkdir_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_mkdir_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::MKDIR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

58
src/fuse_mkdir_policy_ff.cpp

@ -0,0 +1,58 @@
/*
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_mkdir_policy_ff.hpp"
#include "fuse_mkdir_mkdir.hpp"
#include "fs_clonepath_branches.hpp"
FUSE::MKDIR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKDIR::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
}
return rv;
}
}
return -ENOENT;
}

41
src/fuse_mkdir_policy_ff.hpp

@ -0,0 +1,41 @@
/*
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 "fuse_mkdir_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKDIR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) final;
private:
Branches2 _branches;
};
}

50
src/fuse_mknod_policy.hpp

@ -0,0 +1,50 @@
/*
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 "fuse_mknod_policy_base.hpp"
#include "fuse_mknod_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::MKNOD
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_mknod = FuncFactory(toml_);
}
public:
int
operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev)
{
return (*_mknod)(fusepath_,mode_,umask_,dev_);
}
private:
POLICY::Base::Ptr _mknod;
};
}

44
src/fuse_mknod_policy_base.hpp

@ -0,0 +1,44 @@
/*
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 <memory>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace FUSE::MKNOD::POLICY
{
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) = 0;
};
}

64
src/fuse_mknod_policy_epff.cpp

@ -0,0 +1,64 @@
/*
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_mknod_policy_epff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_mknod.hpp"
FUSE::MKNOD::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKNOD::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
const dev_t dev_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
continue;
if(rv >= 0)
mode &= umask_;
rv = fs::mknod(fullpath,mode,dev_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

42
src/fuse_mknod_policy_epff.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_mknod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKNOD::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) final;
private:
Branches2 _branches;
};
}

41
src/fuse_mknod_policy_factory.cpp

@ -0,0 +1,41 @@
/*
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_mknod_policy_factory.hpp"
#include "fuse_mknod_policy_ff.hpp"
#include "fuse_mknod_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::MKNOD::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","mknod","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_mknod_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_mknod_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::MKNOD::POLICY
{
Base::Ptr
factory(const toml::value &);
}

81
src/fuse_mknod_policy_ff.cpp

@ -0,0 +1,81 @@
/*
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_mknod_policy_ff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_clonepath.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_mknod.hpp"
#include "ugid.hpp"
FUSE::MKNOD::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKNOD::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
const dev_t dev_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = fs::acl::dir_has_defaults(fullpath);
}
if(rv >= 0)
mode &= ~umask_;
rv = fs::mknod(fullpath,mode,dev_);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
{
rv = fs::acl::dir_has_defaults(fullpath);
if(rv >= 0)
mode &= ~umask_;
rv = fs::mknod(fullpath,mode,dev_);
}
}
return rv;
}
}
return -ENOENT;
}

42
src/fuse_mknod_policy_ff.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_mknod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKNOD::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) final;
private:
Branches2 _branches;
};
}

52
src/fuse_open_policy.hpp

@ -0,0 +1,52 @@
/*
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 "fuse_open_policy_base.hpp"
#include "fuse_open_policy_factory.hpp"
#include "fuse.h"
#include "toml.hpp"
#include <memory>
namespace FUSE::OPEN
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_open = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
fuse_file_info_t *ffi_)
{
return (*_open)(fusepath_,ffi_);
}
private:
POLICY::Base::Ptr _open;
};
}

39
src/fuse_open_policy_base.hpp

@ -0,0 +1,39 @@
/*
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.h"
#include <memory>
namespace FUSE::OPEN::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
fuse_file_info_t *ffi) = 0;
};
}

39
src/fuse_open_policy_factory.cpp

@ -0,0 +1,39 @@
/*
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_open_policy_factory.hpp"
#include "fuse_open_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::OPEN::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","open","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_open_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_open_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::OPEN::POLICY
{
Base::Ptr
factory(const toml::value &);
}

57
src/fuse_open_policy_ff.cpp

@ -0,0 +1,57 @@
/*
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_open_policy_ff.hpp"
#include "fs_open.hpp"
#include "fileinfo.hpp"
FUSE::OPEN::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::OPEN::POLICY::FF::operator()(const gfs::path &fusepath_,
fuse_file_info_t *ffi_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::open(fullpath,ffi_->flags);
if(rv == -ENOENT)
continue;
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

42
src/fuse_open_policy_ff.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_open_policy.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::OPEN::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

52
src/fuse_readlink_policy.hpp

@ -0,0 +1,52 @@
/*
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 "fuse_readlink_policy_base.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::READLINK
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_readlink = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
char *buf_,
const size_t bufsiz_)
{
return (*_readlink)(fusepath_,buf_,bufsiz_);
}
private:
POLICY::Base::Ptr _readlink;
};
}

36
src/fuse_readlink_policy_base.hpp

@ -0,0 +1,36 @@
/*
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 <memory>
namespace FUSE::READLINK::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
char *buf,
const size_t bufsiz) = 0;
};
}

38
src/fuse_readlink_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_readlink_policy_factory.hpp"
#include "fuse_readlink_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::READLINK::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","readlink","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_readlink_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_readlink_func_base.hpp"
#include "toml.hpp"
namespace FUSE::READLINK::POLICY
{
Base::Ptr
factory(const toml::value &);
}

53
src/fuse_readlink_policy_ff.cpp

@ -0,0 +1,53 @@
/*
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_readlink_policy_ff.hpp"
#include "fs_readlink.hpp"
FUSE::READLINK::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::READLINK::POLICY::FF::operator()(const gfs::path &fusepath_,
char *buf_,
const size_t bufsiz_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::readlink(fullpath,buf_,bufsiz_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

43
src/fuse_readlink_policy_ff.hpp

@ -0,0 +1,43 @@
/*
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 "fuse_readlink_policy_base.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::READLINK::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,,
char *buf,
const size_t bufsiz) final;
private:
Branches2 _branches;
};
}

47
src/fuse_removexattr_policy.hpp

@ -0,0 +1,47 @@
/*
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 "fuse_removexattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::REMOVEXATTR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_removexattr = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
const char *attrname_)
{
return (*_removexattr)(fusepath_,attrname_);
}
private:
POLICY::Base::Ptr _removexattr;
};
}

49
src/fuse_removexattr_policy_all.cpp

@ -0,0 +1,49 @@
/*
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_removexattr_policy_all.hpp"
#include "fuse_removexattr_err.hpp"
#include "fs_lremovexattr.hpp"
FUSE::REMOVEXATTR::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::REMOVEXATTR::POLICY::ALL::operator()(const gfs::path &fusepath_,
const char *attrname_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lremovexattr(fullpath,attrname_);
}
}
return rv;
}

40
src/fuse_removexattr_policy_all.hpp

@ -0,0 +1,40 @@
/*
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 "fuse_removexattr_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::REMOVEXATTR::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname) final;
private:
Branches2 _branches;
};
}

35
src/fuse_removexattr_policy_base.hpp

@ -0,0 +1,35 @@
/*
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 <memory>
namespace FUSE::REMOVEXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const char *attrname) = 0;
};
}

38
src/fuse_removexattr_policy_factory.cpp

@ -0,0 +1,38 @@
/*
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_removexattr_policy_factory.hpp"
#include "fuse_removexattr_policy_all.hpp"
#include <stdexcept>
namespace FUSE::REMOVEXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","removexattr","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_removexattr_policy_factory.hpp

@ -0,0 +1,30 @@
/*
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 "fuse_removexattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::REMOVEXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

47
src/fuse_rename_policy.hpp

@ -0,0 +1,47 @@
/*
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 "fuse_rename_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::RENAME
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_rename = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
return (*_rename)(oldpath_,newpath_);
}
private:
POLICY::Base::Ptr _rename;
};
}

51
src/fuse_rename_policy_all.cpp

@ -0,0 +1,51 @@
/*
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_rename_policy_all.hpp"
#include "fuse_rename_err.hpp"
#include "fs_rename.hpp"
#include "fs_path.hpp"
FUSE::RENAME::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::RENAME::POLICY::ALL::operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / oldpath_;
rv = 0;
}
}
return rv;
}

42
src/fuse_rename_policy_all.hpp

@ -0,0 +1,42 @@
/*
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 "fuse_rename_policy_base.hpp"
#include "branches.hpp"
#include "fs_path.hpp"
namespace FUSE::RENAME::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &oldpath,
const gfs::path &newpath) final;
private:
Branches2 _branches;
};
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save