Browse Source

checkpoint

toml
Antonio SJ Musumeci 4 years ago
parent
commit
0bb55624a4
  1. 2
      LICENSE
  2. 89
      config.toml
  3. 22
      src/branch.cpp
  4. 56
      src/branch.hpp
  5. 94
      src/branch_group.cpp
  6. 31
      src/branch_group.hpp
  7. 21
      src/branches.cpp
  8. 10
      src/branches.hpp
  9. 38
      src/config.cpp
  10. 10
      src/config.hpp
  11. 23
      src/config_inodecalc.cpp
  12. 5
      src/config_inodecalc.hpp
  13. 58
      src/config_link_exdev.cpp
  14. 27
      src/from_toml.hpp
  15. 13
      src/fs_acl.cpp
  16. 5
      src/fs_acl.hpp
  17. 6
      src/fs_attr.hpp
  18. 85
      src/fs_attr_linux.icpp
  19. 97
      src/fs_clonepath.cpp
  20. 9
      src/fs_clonepath.hpp
  21. 49
      src/fs_clonepath_branches.cpp
  22. 30
      src/fs_clonepath_branches.hpp
  23. 6
      src/fs_close.hpp
  24. 12
      src/fs_exists.hpp
  25. 8
      src/fs_flistxattr.hpp
  26. 29
      src/fs_glob.cpp
  27. 6
      src/fs_glob.hpp
  28. 18
      src/fs_ioctl.hpp
  29. 21
      src/fs_lchmod.hpp
  30. 37
      src/fs_lgetxattr.hpp
  31. 28
      src/fs_link.hpp
  32. 17
      src/fs_llistxattr.hpp
  33. 16
      src/fs_lsetxattr.hpp
  34. 17
      src/fs_lstat.hpp
  35. 6
      src/fs_lutimens.hpp
  36. 6
      src/fs_mkdir.hpp
  37. 29
      src/fs_open.hpp
  38. 5
      src/fs_path.hpp
  39. 20
      src/fs_readlink.hpp
  40. 21
      src/fs_symlink.hpp
  41. 17
      src/fs_truncate.hpp
  42. 16
      src/fs_unlink.hpp
  43. 19
      src/fs_utimensat_freebsd.hpp
  44. 8
      src/fs_utimensat_generic.hpp
  45. 19
      src/fs_utimensat_linux.hpp
  46. 94
      src/fs_xattr.cpp
  47. 53
      src/fs_xattr.hpp
  48. 3
      src/func.hpp
  49. 47
      src/fuse_access.cpp
  50. 3
      src/fuse_access.hpp
  51. 35
      src/fuse_access_func.cpp
  52. 40
      src/fuse_access_func.hpp
  53. 37
      src/fuse_access_func_base.hpp
  54. 37
      src/fuse_access_func_factory.cpp
  55. 30
      src/fuse_access_func_factory.hpp
  56. 52
      src/fuse_access_func_ff.cpp
  57. 40
      src/fuse_access_func_ff.hpp
  58. 10
      src/fuse_bmap.cpp
  59. 7
      src/fuse_bmap.hpp
  60. 105
      src/fuse_chmod.cpp
  61. 8
      src/fuse_chmod.hpp
  62. 54
      src/fuse_chmod_err.hpp
  63. 35
      src/fuse_chmod_func.cpp
  64. 42
      src/fuse_chmod_func.hpp
  65. 50
      src/fuse_chmod_func_all.cpp
  66. 40
      src/fuse_chmod_func_all.hpp
  67. 37
      src/fuse_chmod_func_base.hpp
  68. 38
      src/fuse_chmod_func_factory.cpp
  69. 30
      src/fuse_chmod_func_factory.hpp
  70. 111
      src/fuse_chown.cpp
  71. 6
      src/fuse_chown.hpp
  72. 51
      src/fuse_chown_err.hpp
  73. 36
      src/fuse_chown_func.cpp
  74. 43
      src/fuse_chown_func.hpp
  75. 51
      src/fuse_chown_func_all.cpp
  76. 41
      src/fuse_chown_func_all.hpp
  77. 40
      src/fuse_chown_func_base.hpp
  78. 38
      src/fuse_chown_func_factory.cpp
  79. 30
      src/fuse_chown_func_factory.hpp
  80. 10
      src/fuse_copy_file_range.cpp
  81. 7
      src/fuse_copy_file_range.hpp
  82. 22
      src/fuse_create.cpp
  83. 4
      src/fuse_create.hpp
  84. 37
      src/fuse_create_func.cpp
  85. 42
      src/fuse_create_func.hpp
  86. 39
      src/fuse_create_func_base.hpp
  87. 73
      src/fuse_create_func_epff.cpp
  88. 42
      src/fuse_create_func_epff.hpp
  89. 40
      src/fuse_create_func_factory.cpp
  90. 30
      src/fuse_create_func_factory.hpp
  91. 91
      src/fuse_create_func_ff.cpp
  92. 42
      src/fuse_create_func_ff.hpp
  93. 2
      src/fuse_destroy.cpp
  94. 2
      src/fuse_destroy.hpp
  95. 10
      src/fuse_fallocate.cpp
  96. 7
      src/fuse_fallocate.hpp
  97. 10
      src/fuse_fchmod.cpp
  98. 7
      src/fuse_fchmod.hpp
  99. 10
      src/fuse_fchown.cpp
  100. 7
      src/fuse_fchown.hpp

2
LICENSE

@ -1,7 +1,7 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
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

89
config.toml

@ -0,0 +1,89 @@
# test file
[filesystem]
name = 'foo'
mountpoint = '/tmp/test'
threads = 0
[fuse]
posix-acl = false
async-read = true
message-size = 256
[func]
inode-calc = 'hybrid-hash'
symlinkify = false
symlinkify-timeout = 0
xattr = 'passthrough'
[func.access]
policy = 'ff'
[func.create]
policy = 'ff'
[func.getattr]
policy = 'ff'
follow-symlinks = 'never'
[func.rmdir]
policy = 'all'
follow-symlinks = 'never'
[func.link]
policy = 'all' # 'preserve-paths' | 'create-paths' | 'per-branch'
exdev = 'passthrough'
[func.write]
policy = 'null'
move-on-enospc = 'mfs'
[func.release]
drop-cache = true
[func.read]
policy = 'null'
[func.getxattr]
security-capability = false
[func.setxattr]
security-capability = false
[func.open]
link-cow = true
nfs-hack = 'off'
[func.rename]
policy = ''
exdev = 'passthrough'
[func.statfs]
policy = 'base'
ignore = 'none'
[cache]
files = 'off'
statfs = 0
attr-timeout = 0
entry-timeout = 0
negative-entry-timeout = 0
writeback = false
symlinks = false
readdir = false
[branches]
min-free-space = 123
[[branches.group]]
[[branches.group.branch]]
active = false
path = '/tmp/mergerfs/a'
path-type = 'literal'
mode = 'RW'
if-not-mountpoint = 'fail' # 'fail' | 'deactivate' ?
[[branches.group.branch]]
path = '/tmp/mergerfs/*'
path-type = 'glob'

22
src/branch.cpp

@ -95,3 +95,25 @@ Branch::ro_or_nc(void) const
return ((mode == Branch::Mode::RO) ||
(mode == Branch::Mode::NC));
}
Branch2::Mode
Branch2::str2mode(const std::string &str_)
{
if(str_ == "RW")
return Branch2::Mode::RW;
if(str_ == "RO")
return Branch2::Mode::RO;
if(str_ == "NC")
return Branch2::Mode::NC;
return Branch2::Mode::RW;
}
Branch2::Branch2(const toml::value &toml_,
const Branch2::Mode default_mode_,
const uint64_t default_minfreespace_)
{
mode = toml::find_or(toml_,"mode",default_mode_);
minfreespace = toml::find_or(toml_,"min-free-space",default_minfreespace_);
path = toml::find<std::string>(toml_,"path");
}

56
src/branch.hpp

@ -18,6 +18,10 @@
#pragma once
#include "from_toml.hpp"
#include "ghc/filesystem.hpp"
#include "nonstd/optional.hpp"
#include "strvec.hpp"
#include "tofrom_string.hpp"
@ -65,3 +69,55 @@ private:
nonstd::optional<uint64_t> _minfreespace;
const uint64_t *_default_minfreespace;
};
class Branch2
{
public:
enum class Mode
{
INVALID,
RO,
RW,
NC
};
static Mode str2mode(const std::string &);
public:
Branch2(const toml::value &toml,
const Branch2::Mode default_mode,
const uint64_t default_minfreespace);
public:
bool ro(void) const;
bool nc(void) const;
bool ro_or_nc(void) const;
public:
ghc::filesystem::path path;
Mode mode;
uint64_t minfreespace;
};
namespace toml
{
template<>
struct from<Branch2::Mode>
{
static
Branch2::Mode
from_toml(const toml::value &v_)
{
std::string str = v_.as_string();
if(str == "RW")
return Branch2::Mode::RW;
if(str == "RO")
return Branch2::Mode::RO;
if(str == "NC")
return Branch2::Mode::NC;
return Branch2::Mode::RW;
}
};
}

94
src/branch_group.cpp

@ -0,0 +1,94 @@
/*
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 "branch_group.hpp"
#include "fs_glob.hpp"
#include <iostream>
#include <stdexcept>
namespace gfs = ghc::filesystem;
namespace l
{
static
void
add_literal(const toml::value &branch_,
const Branch2::Mode default_mode_,
const uint64_t default_minfreespace_,
BranchGroup *branch_group_)
{
branch_group_->emplace_back(branch_,default_mode_,default_minfreespace_);
}
static
void
add_glob(const toml::value &branch_,
const Branch2::Mode default_mode_,
const uint64_t default_minfreespace_,
BranchGroup *branch_group_)
{
std::string pattern;
std::vector<gfs::path> paths;
pattern = toml::find<std::string>(branch_,"path");
fs::glob(pattern,&paths);
for(const auto &path : paths)
{
toml::value v = branch_;
v["path"] = path.native();
v["path-type"] = "literal";
l::add_literal(v,default_mode_,default_minfreespace_,branch_group_);
}
}
}
BranchGroup::BranchGroup(const toml::value &toml_,
const Branch2::Mode default_mode_,
const uint64_t default_minfreespace_)
{
Branch2::Mode default_mode;
uint64_t default_minfreespace;
default_mode = toml::find_or(toml_,"mode",default_mode_);
default_minfreespace = toml::find_or(toml_,"min-free-space",default_minfreespace_);
for(const auto &branch : toml_.at("branch").as_array())
{
std::string path_type;
if(!toml::find_or(branch,"active",true))
continue;
path_type = toml::find_or(branch,"path-type","literal");
if(path_type == "literal")
l::add_literal(branch,default_mode,default_minfreespace_,this);
else if(path_type == "glob")
l::add_glob(branch,default_mode,default_minfreespace,this);
else
throw std::runtime_error("invalid path-type = " + path_type);
}
}

31
src/branch_group.hpp

@ -0,0 +1,31 @@
/*
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 "branch.hpp"
#include <vector>
class BranchGroup : public std::vector<Branch2>
{
public:
BranchGroup(const toml::value &,
const Branch2::Mode,
const uint64_t);
};

21
src/branches.cpp

@ -29,6 +29,7 @@
#include <string>
#include <fnmatch.h>
#include <iostream>
using std::string;
using std::vector;
@ -429,3 +430,23 @@ SrcMounts::to_string(void) const
return rv;
}
Branches2::Branches2(const toml::value &toml_)
{
toml::value branches;
Branch2::Mode default_mode;
uint64_t default_minfreespace;
default_mode = toml::find_or(toml_,"branches","mode",Branch2::Mode::RW);
default_minfreespace = toml::find_or(toml_,"branches","min-free-space",0);
branches = toml::find(toml_,"branches");
for(const auto &branch_group : branches.at("group").as_array())
{
if(!toml::find_or(branch_group,"active",true))
continue;
emplace_back(branch_group,default_mode,default_minfreespace);
}
}

10
src/branches.hpp

@ -18,7 +18,11 @@
#pragma once
#include "from_toml.hpp"
#include "branch.hpp"
#include "branch_group.hpp"
#include "nonstd/optional.hpp"
#include "strvec.hpp"
#include "tofrom_string.hpp"
@ -30,6 +34,12 @@
#include <vector>
class Branches2 : public std::vector<BranchGroup>
{
public:
Branches2(const toml::value &);
};
class Branches final : public ToFromString
{
public:

38
src/config.cpp

@ -14,6 +14,9 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fuse_access.hpp"
#include "fuse_getattr.hpp"
#include "config.hpp"
#include "ef.hpp"
#include "errno.hpp"
@ -23,6 +26,9 @@
#include "str.hpp"
#include "to_string.hpp"
#include "version.hpp"
#include "toml.hpp"
#include "toml_verify.hpp"
//#include "nonstd/span.hpp"
#include <algorithm>
#include <cstdint>
@ -41,7 +47,6 @@ using std::string;
#define IFERT(S) if(S == s_) return true
const std::string CONTROLFILE = "/.mergerfs";
Config Config::_singleton;
@ -90,7 +95,6 @@ Config::Config()
ignorepponrename(false),
inodecalc("hybrid-hash"),
link_cow(false),
link_exdev(LinkEXDEV::ENUM::PASSTHROUGH),
log_metrics(false),
mount(),
moveonenospc(false),
@ -155,7 +159,6 @@ Config::Config()
_map["inodecalc"] = &inodecalc;
_map["kernel_cache"] = &kernel_cache;
_map["link_cow"] = &link_cow;
_map["link-exdev"] = &link_exdev;
_map["log.metrics"] = &log_metrics;
_map["minfreespace"] = &minfreespace;
_map["mount"] = &mount;
@ -345,6 +348,35 @@ Config::from_file(const std::string &filepath_,
return rv;
}
int
Config::from_toml(const toml::value &toml_,
ErrVec *errs_)
{
// toml::verify_bool(toml_,"cache","readdir",true);
// toml::verify_bool(toml_,"drop-cache-on-close",true);
// toml::verify_bool(toml_,"link-cow",false);
// toml::verify_bool(toml_,"null-rw",false);
// toml::verify_bool(toml_,"posix-acl",false);
// toml::verify_bool(toml_,"security-capability",false);
// toml::verify_bool(toml_,"symlinkify",false);
// toml::verify_enum(toml_,"follow-symlinks",true,{"never","directory","regular","all"});
// toml::verify_enum(toml_,"inode-calc",true,{"foo","bar","baz"});
// toml::verify_enum(toml_,"link-exdev",false,{"passthrough","rel-symlinks","abs-base-symlink","abs-pool-symlink"});
// toml::verify_enum(toml_,"move-on-enospc",true,{"mfs","lfs"});
// toml::verify_enum(toml_,"nfs-open-hack",false,{"off","git","all"});
// toml::verify_enum(toml_,"rename-exdev",false,{"passthrough","rel-symlink","abs-symlink"});
// toml::verify_enum(toml_,"statfs",true,{"base","full"});
// toml::verify_enum(toml_,"statfs-ignore",true,{"none","ro","nc"});
// toml::verify_enum(toml_,"xattr",false,{"passthrough","noattr","nosys"});
// toml::verify_human_size(toml_,"min-free-space",false);
// toml::verify_integer(toml_,"fuse-msg-size",false,1,256);
// toml::verify_min_integer(toml_,"symlinkify-timeout",false,0);
// toml::verify_bool(toml_,"allow-other",false);
// toml::verify_string(toml_,"filesystem-name",true);
return 0;
}
std::ostream&
operator<<(std::ostream &os_,
const Config &c_)

10
src/config.hpp

@ -21,12 +21,10 @@
#include "config_cachefiles.hpp"
#include "config_follow_symlinks.hpp"
#include "config_inodecalc.hpp"
#include "config_link_exdev.hpp"
#include "config_log_metrics.hpp"
#include "config_moveonenospc.hpp"
#include "config_nfsopenhack.hpp"
#include "config_readdir.hpp"
#include "config_rename_exdev.hpp"
#include "config_statfs.hpp"
#include "config_statfsignore.hpp"
#include "config_xattr.hpp"
@ -39,6 +37,8 @@
#include "fuse.h"
#include "toml.hpp"
#include <cstdint>
#include <map>
#include <memory>
@ -53,7 +53,6 @@ typedef ToFromWrapper<int> ConfigINT;
typedef ToFromWrapper<std::string> ConfigSTR;
typedef std::map<std::string,ToFromString*> Str2TFStrMap;
extern const std::string CONTROLFILE;
class Config
{
@ -121,7 +120,6 @@ public:
InodeCalc inodecalc;
ConfigBOOL kernel_cache;
ConfigBOOL link_cow;
LinkEXDEV link_exdev;
LogMetrics log_metrics;
ConfigSTR mount;
MoveOnENOSPC moveonenospc;
@ -131,7 +129,6 @@ public:
ConfigBOOL posix_acl;
ReadDir readdir;
ConfigBOOL readdirplus;
RenameEXDEV rename_exdev;
ConfigBOOL security_capability;
SrcMounts srcmounts;
StatFS statfs;
@ -161,6 +158,7 @@ public:
public:
int from_stream(std::istream &istrm, ErrVec *errs);
int from_file(const std::string &filepath, ErrVec *errs);
int from_toml(const toml::value &value, ErrVec *errs);
private:
Str2TFStrMap _map;
@ -203,3 +201,5 @@ Config::Write::operator->()
{
return &_cfg;
}
int process_toml_config(const std::string &filepath_);

23
src/config_inodecalc.cpp

@ -18,7 +18,7 @@
#include "config_inodecalc.hpp"
#include "fs_inode.hpp"
#include "toml.hpp"
InodeCalc::InodeCalc(const std::string &s_)
{
@ -36,3 +36,24 @@ InodeCalc::from_string(const std::string &s_)
{
return fs::inode::set_algo(s_);
}
void
InodeCalc::from_toml(const toml::value &v_)
{
int rv;
rv = fs::inode::set_algo(v_.as_string());
if(rv < 0)
throw toml::type_error("must be: "
"passthrough|"
"path-hash|"
"path-hash32|"
"devino-hash|"
"devino-hash32|"
"hybrid-hash|"
"hybrid-hash32"
,
v_.location());
return;
}

5
src/config_inodecalc.hpp

@ -19,13 +19,16 @@
#pragma once
#include "tofrom_string.hpp"
#include "toml.hpp"
class InodeCalc : public ToFromString
{
public:
InodeCalc(const std::string &);
public:
void from_toml(const toml::value &);
public:
std::string to_string(void) const final;
int from_string(const std::string &) final;

58
src/config_link_exdev.cpp

@ -1,58 +0,0 @@
/*
ISC License
Copyright (c) 2021, 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 "config_link_exdev.hpp"
#include "ef.hpp"
#include "errno.hpp"
template<>
std::string
LinkEXDEV::to_string(void) const
{
switch(_data)
{
case LinkEXDEV::ENUM::PASSTHROUGH:
return "passthrough";
case LinkEXDEV::ENUM::REL_SYMLINK:
return "rel-symlink";
case LinkEXDEV::ENUM::ABS_BASE_SYMLINK:
return "abs-base-symlink";
case LinkEXDEV::ENUM::ABS_POOL_SYMLINK:
return "abs-pool-symlink";
}
return "invalid";
}
template<>
int
LinkEXDEV::from_string(const std::string &s_)
{
if(s_ == "passthrough")
_data = LinkEXDEV::ENUM::PASSTHROUGH;
ef(s_ == "rel-symlink")
_data = LinkEXDEV::ENUM::REL_SYMLINK;
ef(s_ == "abs-base-symlink")
_data = LinkEXDEV::ENUM::ABS_BASE_SYMLINK;
ef(s_ == "abs-pool-symlink")
_data = LinkEXDEV::ENUM::ABS_POOL_SYMLINK;
else
return -EINVAL;
return 0;
}

27
src/from_toml.hpp

@ -0,0 +1,27 @@
/*
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 "toml.hpp"
class FromTOML
{
public:
virtual void operator=(const toml::value &) = 0;
};

13
src/fs_acl.cpp

@ -18,9 +18,12 @@
#include "fs_lgetxattr.hpp"
#include "fs_path.hpp"
#include "ghc/filesystem.hpp"
#include <string>
namespace gfs = ghc::filesystem;
const char POSIX_ACL_DEFAULT_XATTR[] = "system.posix_acl_default";
@ -40,5 +43,15 @@ namespace fs
return (rv != -1);
}
int
dir_has_defaults(const gfs::path &fullpath_)
{
int rv;
rv = fs::lgetxattr(fullpath_.parent_path(),POSIX_ACL_DEFAULT_XATTR,NULL,0);
return rv;
}
}
}

5
src/fs_acl.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
@ -27,5 +29,8 @@ namespace fs
{
bool
dir_has_defaults(const std::string &fullpath);
int
dir_has_defaults(const ghc::filesystem::path &fullpath);
}
}

6
src/fs_attr.hpp

@ -16,7 +16,7 @@
#pragma once
#include <string>
#include "ghc/filesystem.hpp"
namespace fs
@ -25,7 +25,7 @@ namespace fs
{
int copy(const int fdin,
const int fdout);
int copy(const std::string &from,
const std::string &to);
int copy(const ghc::filesystem::path &from,
const ghc::filesystem::path &to);
}
}

85
src/fs_attr_linux.icpp

@ -18,14 +18,13 @@
#include "fs_close.hpp"
#include "fs_open.hpp"
#include "fs_ioctl.hpp"
#include <string>
#include "ghc/filesystem.hpp"
#include <fcntl.h>
#include <linux/fs.h>
using std::string;
namespace gfs = ghc::filesystem;
namespace fs
{
@ -33,38 +32,36 @@ namespace fs
{
static
int
get_fs_ioc_flags(const int fd,
int &flags)
get_fs_ioc_flags(const int fd_,
int *flags_)
{
int rv;
rv = fs::ioctl(fd,FS_IOC_GETFLAGS,(void*)&flags);
if((rv == -1) && (errno == EINVAL))
errno = ENOTSUP;
rv = fs::ioctl(fd_,FS_IOC_GETFLAGS,(void*)flags_);
if(rv == -EINVAL)
rv = -ENOTSUP;
return rv;
}
static
int
get_fs_ioc_flags(const string &file,
int &flags)
get_fs_ioc_flags(const gfs::path &file_,
int *flags_)
{
int fd;
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
fd = fs::open(file_,openflags);
if(fd < 0)
return fd;
rv = get_fs_ioc_flags(fd,flags);
if(rv == -1)
rv = get_fs_ioc_flags(fd,flags_);
if(rv < 0)
{
int error = errno;
fs::close(fd);
errno = error;
return -1;
return rv;
}
return fs::close(fd);
@ -72,69 +69,67 @@ namespace fs
static
int
set_fs_ioc_flags(const int fd,
const int flags)
set_fs_ioc_flags(const int fd_,
const int flags_)
{
int rv;
rv = fs::ioctl(fd,FS_IOC_SETFLAGS,(void*)&flags);
if((rv == -1) && (errno == EINVAL))
errno = ENOTSUP;
rv = fs::ioctl(fd_,FS_IOC_SETFLAGS,(void*)&flags_);
if(rv == -EINVAL)
rv = -ENOTSUP;
return rv;
}
static
int
set_fs_ioc_flags(const string &file,
const int flags)
set_fs_ioc_flags(const gfs::path &file_,
const int flags_)
{
int fd;
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
fd = fs::open(file_,openflags);
if(fd < 0)
return fd;
rv = set_fs_ioc_flags(fd,flags);
if(rv == -1)
rv = set_fs_ioc_flags(fd,flags_);
if(rv < 0)
{
int error = errno;
fs::close(fd);
errno = error;
return -1;
return rv;
}
return fs::close(fd);
}
int
copy(const int fdin,
const int fdout)
copy(const int fdin_,
const int fdout_)
{
int rv;
int flags;
rv = get_fs_ioc_flags(fdin,flags);
if(rv == -1)
return -1;
rv = get_fs_ioc_flags(fdin_,&flags);
if(rv < 0)
return rv;
return set_fs_ioc_flags(fdout,flags);
return set_fs_ioc_flags(fdout_,flags);
}
int
copy(const string &from,
const string &to)
copy(const gfs::path &from_,
const gfs::path &to_)
{
int rv;
int flags;
rv = get_fs_ioc_flags(from,flags);
if(rv == -1)
return -1;
rv = get_fs_ioc_flags(from_,&flags);
if(rv < 0)
return rv;
return set_fs_ioc_flags(to,flags);
return set_fs_ioc_flags(to_,flags);
}
}
}

97
src/fs_clonepath.cpp

@ -25,10 +25,13 @@
#include "fs_xattr.hpp"
#include "ugid.hpp"
#include "ghc/filesystem.hpp"
#include <string>
using std::string;
namespace gfs = ghc::filesystem;
namespace l
{
@ -38,10 +41,10 @@ namespace l
{
switch(err_)
{
case ENOTTY:
case ENOTSUP:
case -ENOTTY:
case -ENOTSUP:
#if ENOTSUP != EOPNOTSUPP
case EOPNOTSUPP:
case -EOPNOTSUPP:
#endif
return true;
}
@ -50,20 +53,18 @@ namespace l
}
}
namespace fs
{
/*
/*
Attempts to clone a path.
The directories which already exist are left alone.
The new directories have metadata set to match the original if
possible. Optionally ignore errors on metadata copies.
*/
int
clonepath(const string &fromsrc_,
*/
int
fs::clonepath(const string &fromsrc_,
const string &tosrc_,
const char *relative_,
const bool return_metadata_errors_)
{
{
int rv;
struct stat st;
string topath;
@ -117,26 +118,69 @@ namespace fs
return -1;
return 0;
}
int
fs::clonepath(const gfs::path &fromsrc_,
const gfs::path &tosrc_,
const gfs::path &relative_)
{
int rv;
struct stat st;
gfs::path topath;
gfs::path frompath;
if(relative_.empty())
return 0;
if(!relative_.parent_path().empty())
{
rv = fs::clonepath(fromsrc_,tosrc_,relative_.parent_path());
if(rv < 0)
return rv;
}
int
clonepath(const string &from_,
frompath = fromsrc_ / relative_;
rv = fs::lstat(frompath,&st);
if(rv < 0)
return rv;
else if(!S_ISDIR(st.st_mode))
return -ENOTDIR;
topath = tosrc_ / relative_;
rv = fs::mkdir(topath,st.st_mode);
if(rv == -EEXIST)
return 0;
else if(rv < 0)
return rv;
// it may not support it... it's fine...
fs::attr::copy(frompath,topath);
fs::xattr::copy(frompath,topath);
fs::lchown_check_on_error(topath,st);
fs::lutimens(topath,st);
return 0;
}
int
fs::clonepath(const string &from_,
const string &to_,
const string &relative_,
const bool return_metadata_errors_)
{
{
return fs::clonepath(from_,
to_,
relative_.c_str(),
return_metadata_errors_);
}
}
int
clonepath_as_root(const string &from_,
int
fs::clonepath_as_root(const string &from_,
const string &to_,
const char *relative_,
const bool return_metadata_errors_)
{
{
if((relative_ == NULL) || (relative_[0] == '\0'))
return 0;
if(from_ == to_)
@ -147,14 +191,23 @@ namespace fs
return fs::clonepath(from_,to_,relative_,return_metadata_errors_);
}
}
}
int
clonepath_as_root(const string &from_,
int
fs::clonepath_as_root(const string &from_,
const string &to_,
const string &relative_,
const bool return_metadata_errors_)
{
{
return fs::clonepath_as_root(from_,to_,relative_.c_str(),return_metadata_errors_);
}
}
int
fs::clonepath_as_root(const gfs::path &from_,
const gfs::path &to_,
const gfs::path &relative_)
{
const ugid::SetRootGuard ugidGuard;
return fs::clonepath(from_,to_,relative_);
}

9
src/fs_clonepath.hpp

@ -16,6 +16,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
@ -30,6 +32,10 @@ namespace fs
const std::string &relative,
const bool return_metadata_errors = false);
int clonepath(const ghc::filesystem::path &fromsrc,
const ghc::filesystem::path &tosrc,
const ghc::filesystem::path &relative);
int clonepath_as_root(const std::string &from,
const std::string &to,
const char *relative,
@ -38,4 +44,7 @@ namespace fs
const std::string &to,
const std::string &relative,
const bool return_metadata_errors = false);
int clonepath_as_root(const ghc::filesystem::path &from,
const ghc::filesystem::path &to,
const ghc::filesystem::path &relative);
}

49
src/fs_clonepath_branches.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 "fs_clonepath_branches.hpp"
#include "ugid.hpp"
#include "fs_clonepath.hpp"
namespace gfs = ghc::filesystem;
int
fs::clonepath_as_root(const Branches2 &branches_,
const gfs::path &to_,
const gfs::path &relative_)
{
int rv;
const ugid::SetRootGuard ugidGuard;
for(const auto &branch_group : branches_)
{
for(const auto &branch : branch_group)
{
rv = fs::clonepath(branch.path,to_,relative_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

30
src/fs_clonepath_branches.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 "branches.hpp"
#include "ghc/filesystem.hpp"
namespace fs
{
int
clonepath_as_root(const Branches2 &branches_,
const ghc::filesystem::path &to_,
const ghc::filesystem::path &relative_);
}

6
src/fs_close.hpp

@ -28,6 +28,10 @@ namespace fs
int
close(const int fd_)
{
return ::close(fd_);
int rv;
rv = ::close(fd_);
return ((rv == -1) ? -errno : 0);
}
}

12
src/fs_exists.hpp

@ -21,6 +21,8 @@
#include "fs_lstat.hpp"
#include "fs_path.hpp"
#include "ghc/filesystem.hpp"
#include <string>
@ -49,6 +51,16 @@ namespace fs
return fs::exists(path_,&st);
}
static
inline
bool
exists(const ghc::filesystem::path &path_)
{
struct stat st;
return fs::exists(path_.c_str(),&st);
}
static
inline
bool

8
src/fs_flistxattr.hpp

@ -34,9 +34,13 @@ namespace fs
const size_t size_)
{
#ifdef USE_XATTR
return ::flistxattr(fd_,list_,size_);
int rv;
rv = ::flistxattr(fd_,list_,size_);
return ((rv == -1) ? -errno : rv);
#else
return (errno=ENOTSUP,-1);
return -ENOTSUP;
#endif
}
}

29
src/fs_glob.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fs_glob.hpp"
#include <glob.h>
#include <cstdint>
@ -23,13 +25,13 @@
using std::string;
using std::vector;
namespace gfs = ghc::filesystem;
namespace fs
{
void
glob(const string &pattern_,
void
fs::glob(const string &pattern_,
vector<string> *strs_)
{
{
int flags;
glob_t gbuf = {0};
@ -40,5 +42,20 @@ namespace fs
strs_->push_back(gbuf.gl_pathv[i]);
::globfree(&gbuf);
}
}
void
fs::glob(const string &pattern_,
vector<gfs::path> *paths_)
{
int flags;
glob_t gbuf = {0};
flags = GLOB_NOCHECK;
::glob(pattern_.c_str(),flags,NULL,&gbuf);
for(size_t i = 0; i < gbuf.gl_pathc; i++)
paths_->push_back(gbuf.gl_pathv[i]);
::globfree(&gbuf);
}

6
src/fs_glob.hpp

@ -16,6 +16,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <vector>
@ -25,4 +27,8 @@ namespace fs
void
glob(const std::string &pattern,
std::vector<std::string> *strs);
void
glob(const std::string &pattern,
std::vector<ghc::filesystem::path> *paths);
}

18
src/fs_ioctl.hpp

@ -29,7 +29,11 @@ namespace fs
ioctl(const int fd_,
const unsigned long request_)
{
return ::ioctl(fd_,request_);
int rv;
rv = ::ioctl(fd_,request_);
return ((rv == -1) ? -errno : rv);
}
static
@ -39,7 +43,11 @@ namespace fs
const unsigned long request_,
void *data_)
{
return ::ioctl(fd_,request_,data_);
int rv;
rv = ::ioctl(fd_,request_,data_);
return ((rv == -1) ? -errno : rv);
}
static
@ -49,6 +57,10 @@ namespace fs
const unsigned long request_,
const int int_)
{
return ::ioctl(fd_,request_,int_);
int rv;
rv = ::ioctl(fd_,request_,int_);
return ((rv == -1) ? -errno : rv);
}
}

21
src/fs_lchmod.hpp

@ -20,10 +20,14 @@
#include "fs_lstat.hpp"
#include "ghc/filesystem.hpp"
#include <string>
#include <errno.h>
#include <sys/stat.h>
#define MODE_BITS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
@ -35,11 +39,15 @@ namespace fs
lchmod(const char *pathname_,
const mode_t mode_)
{
int rv;
#if defined __linux__
return ::chmod(pathname_,mode_);
rv = ::chmod(pathname_,mode_);
#else
return ::lchmod(pathname_,mode_);
rv = ::lchmod(pathname_,mode_);
#endif
return ((rv == -1) ? -errno : 0);
}
static
@ -51,6 +59,15 @@ namespace fs
return fs::lchmod(pathname_.c_str(),mode_);
}
static
inline
int
lchmod(const ghc::filesystem::path &pathname_,
const mode_t mode_)
{
return fs::lchmod(pathname_.native(),mode_);
}
static
inline
int

37
src/fs_lgetxattr.hpp

@ -19,6 +19,7 @@
#pragma once
#include "errno.hpp"
#include "ghc/filesystem.hpp"
#include "xattr.hpp"
#include <string>
@ -37,12 +38,16 @@ namespace fs
const size_t size_)
{
#ifdef USE_XATTR
return ::lgetxattr(path_,
int rv;
rv = ::lgetxattr(path_,
attrname_,
value_,
size_);
return ((rv == -1) ? -errno : rv);
#else
return (errno=ENOTSUP,-1);
return -ENOTSUP;
#endif
}
@ -60,6 +65,34 @@ namespace fs
size_);
}
static
inline
int
lgetxattr(const ghc::filesystem::path &path_,
const char *attrname_,
void *value_,
const size_t size_)
{
return fs::lgetxattr(path_.c_str(),
attrname_,
value_,
size_);
}
static
inline
int
lgetxattr(const ghc::filesystem::path &path_,
const std::string &attrname_,
void *value_,
const size_t size_)
{
return fs::lgetxattr(path_.c_str(),
attrname_.c_str(),
value_,
size_);
}
static
inline
int

28
src/fs_link.hpp

@ -18,20 +18,46 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <errno.h>
#include <unistd.h>
namespace fs
{
static
inline
int
link(const char *oldpath_,
const char *newpath_)
{
int rv;
rv = ::link(oldpath_,newpath_);
return ((rv == -1) ? -errno : rv);
}
static
inline
int
link(const std::string &oldpath_,
const std::string &newpath_)
{
return ::link(oldpath_.c_str(),
return fs::link(oldpath_.c_str(),
newpath_.c_str());
}
static
inline
int
link(const ghc::filesystem::path &oldpath_,
const ghc::filesystem::path &newpath_)
{
return fs::link(oldpath_.c_str(),
newpath_.c_str());
}
}

17
src/fs_llistxattr.hpp

@ -19,6 +19,7 @@
#pragma once
#include "errno.hpp"
#include "ghc/filesystem.hpp"
#include "xattr.hpp"
#include <string>
@ -36,19 +37,27 @@ namespace fs
const size_t size_)
{
#ifdef USE_XATTR
return ::llistxattr(path_,list_,size_);
int rv;
rv = ::llistxattr(path_,list_,size_);
return ((rv == -1) ? -errno : rv);
#else
return (errno=ENOTSUP,-1);
return -ENOTSUP;
#endif
}
static
inline
int
llistxattr(const std::string &path_,
llistxattr(const ghc::filesystem::path &path_,
char *list_,
const size_t size_)
{
return fs::llistxattr(path_.c_str(),list_,size_);
return fs::llistxattr(path_.c_str(),
list_,
size_);
}
}

16
src/fs_lsetxattr.hpp

@ -21,6 +21,8 @@
#include "errno.hpp"
#include "xattr.hpp"
#include "ghc/filesystem.hpp"
#include <string>
#include <sys/types.h>
@ -38,27 +40,31 @@ namespace fs
const int flags_)
{
#ifdef USE_XATTR
return ::lsetxattr(path_,
int rv;
rv = ::lsetxattr(path_,
name_,
value_,
size_,
flags_);
return ((rv == -1) ? -errno : rv);
#else
return (errno=ENOTSUP,-1);
return -ENOTSUP;
#endif
}
static
inline
int
lsetxattr(const std::string &path_,
const std::string &name_,
lsetxattr(const ghc::filesystem::path &path_,
const char *name_,
const void *value_,
const size_t size_,
const int flags_)
{
return fs::lsetxattr(path_.c_str(),
name_.c_str(),
name_,
value_,
size_,
flags_);

17
src/fs_lstat.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <sys/stat.h>
@ -33,7 +35,11 @@ namespace fs
lstat(const char *path_,
struct stat *st_)
{
return ::lstat(path_,st_);
int rv;
rv = ::lstat(path_,st_);
return ((rv == -1) ? -errno : 0);
}
static
@ -44,4 +50,13 @@ namespace fs
{
return fs::lstat(path_.c_str(),st_);
}
static
inline
int
lstat(const ghc::filesystem::path &path_,
struct stat *st_)
{
return fs::lstat(path_.c_str(),st_);
}
}

6
src/fs_lutimens.hpp

@ -21,13 +21,15 @@
#include "fs_utimensat.hpp"
#include "fs_stat_utils.hpp"
#include "ghc/filesystem.hpp"
namespace fs
{
static
inline
int
lutimens(const std::string &path_,
lutimens(const ghc::filesystem::path &path_,
const struct timespec ts_[2])
{
return fs::utimensat(AT_FDCWD,path_,ts_,AT_SYMLINK_NOFOLLOW);
@ -36,7 +38,7 @@ namespace fs
static
inline
int
lutimens(const std::string &path_,
lutimens(const ghc::filesystem::path &path_,
const struct stat &st_)
{
struct timespec ts[2];

6
src/fs_mkdir.hpp

@ -34,7 +34,11 @@ namespace fs
mkdir(const char *path_,
const mode_t mode_)
{
return ::mkdir(path_,mode_);
int rv;
rv = ::mkdir(path_,mode_);
return ((rv == -1) ? -errno : 0);
}
static

29
src/fs_open.hpp

@ -18,8 +18,11 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -33,7 +36,13 @@ namespace fs
open(const char *path_,
const int flags_)
{
return ::open(path_,flags_);
int rv;
rv = ::open(path_,flags_);
if(rv == -1)
return -errno;
return rv;
}
static
@ -43,7 +52,23 @@ namespace fs
const int flags_,
const mode_t mode_)
{
return ::open(path_,flags_,mode_);
int rv;
rv = ::open(path_,flags_,mode_);
if(rv == -1)
return -errno;
return rv;
}
static
inline
int
open(const ghc::filesystem::path &path_,
const int flags_,
const mode_t mode_)
{
return fs::open(path_.c_str(),flags_,mode_);
}
static

5
src/fs_path.hpp

@ -1,5 +1,5 @@
/*
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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
@ -19,6 +19,9 @@
#include <string>
#include <vector>
#include "ghc/filesystem.hpp"
namespace gfs = ghc::filesystem;
namespace fs
{

20
src/fs_readlink.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <unistd.h>
@ -28,10 +30,24 @@ namespace fs
static
inline
int
readlink(const std::string &path_,
readlink(const char *pathname_,
char *buf_,
const size_t bufsiz_)
{
int rv;
rv = ::readlink(pathname_,buf_,bufsiz_);
return ((rv == -1) ? -errno : rv);
}
static
inline
int
readlink(const ghc::filesystem::path &pathname_,
char *buf_,
const size_t bufsiz_)
{
return ::readlink(path_.c_str(),buf_,bufsiz_);
return fs::readlink(pathname_.c_str(),buf_,bufsiz_);
}
}

21
src/fs_symlink.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <unistd.h>
@ -31,7 +33,11 @@ namespace fs
symlink(const char *target_,
const char *linkpath_)
{
return ::symlink(target_,linkpath_);
int rv;
rv = ::symlink(target_,linkpath_);
return ((rv == -1) ? -errno : rv);
}
static
@ -40,7 +46,7 @@ namespace fs
symlink(const std::string &target_,
const std::string &linkpath_)
{
return ::symlink(target_.c_str(),linkpath_.c_str());
return fs::symlink(target_.c_str(),linkpath_.c_str());
}
static
@ -49,6 +55,15 @@ namespace fs
symlink(const char *target_,
const std::string &linkpath_)
{
return ::symlink(target_,linkpath_.c_str());
return fs::symlink(target_,linkpath_.c_str());
}
static
inline
int
symlink(const char *target_,
const ghc::filesystem::path &linkpath_)
{
return fs::symlink(target_,linkpath_.c_str());
}
}

17
src/fs_truncate.hpp

@ -18,6 +18,8 @@
#pragma once
#include "errno.hpp"
#include <string>
#include <sys/types.h>
@ -32,7 +34,11 @@ namespace fs
truncate(const char *path_,
const off_t length_)
{
return ::truncate(path_,length_);
int rv;
rv = ::truncate(path_,length_);
return ((rv == -1) ? -errno : rv);
}
static
@ -43,4 +49,13 @@ namespace fs
{
return fs::truncate(path_.c_str(),length_);
}
static
inline
int
truncate(const ghc::filesystem::path &path_,
const off_t length_)
{
return fs::truncate(path_.c_str(),length_);
}
}

16
src/fs_unlink.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <unistd.h>
@ -30,7 +32,11 @@ namespace fs
int
unlink(const char *path_)
{
return ::unlink(path_);
int rv;
rv = ::unlink(path_);
return ((rv == -1) ? -errno : rv);
}
static
@ -40,4 +46,12 @@ namespace fs
{
return fs::unlink(path_.c_str());
}
static
inline
int
unlink(const ghc::filesystem::path &path_)
{
return fs::unlink(path_.c_str());
}
}

19
src/fs_utimensat_freebsd.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <fcntl.h>
@ -34,7 +36,11 @@ namespace fs
const struct timespec times_[2],
const int flags_)
{
return ::utimensat(dirfd_,pathname_,times_,flags_);
int rv;
rv = ::utimensat(dirfd_,pathname_,times_,flags_);
return ((rv == -1) ? -errno : rv);
}
static
@ -47,4 +53,15 @@ namespace fs
{
return fs::utimensat(dirfd_,pathname_.c_str(),times_,flags_);
}
static
inline
int
utimensat(const int dirfd_,
const ghc::filesystem::path &pathname_,
const struct timespec times_[2],
const int flags_)
{
return fs::utimensat(dirfd_,pathname_.c_str(),times_,flags_);
}
}

8
src/fs_utimensat_generic.hpp

@ -276,21 +276,21 @@ namespace fs
struct timeval *tvp;
if(l::flags_invalid(flags))
return (errno=EINVAL,-1);
return -EINVAL;
if(l::timespec_invalid(ts_))
return (errno=EINVAL,-1);
return -EINVAL;
if(l::should_ignore(ts_))
return 0;
rv = l::convert_timespec_to_timeval(dirfd_,path_,ts_,tv,&tvp,flags_);
if(rv == -1)
return -1;
return -errno;
if((flags_ & AT_SYMLINK_NOFOLLOW) == 0)
return fs::futimesat(dirfd_,path_,tvp);
if(l::can_call_lutimes(dirfd_,path_,flags))
return fs::lutimes(path_,tvp);
return (errno=ENOTSUP,-1);
return -ENOTSUP;
}
}

19
src/fs_utimensat_linux.hpp

@ -18,6 +18,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <fcntl.h>
@ -34,7 +36,11 @@ namespace fs
const struct timespec times_[2],
const int flags_)
{
return ::utimensat(dirfd_,pathname_,times_,flags_);
int rv;
rv = ::utimensat(dirfd_,pathname_,times_,flags_);
return ((rv == -1) ? -errno : rv);
}
static
@ -47,4 +53,15 @@ namespace fs
{
return fs::utimensat(dirfd_,pathname_.c_str(),times_,flags_);
}
static
inline
int
utimensat(const int dirfd_,
const ghc::filesystem::path &pathname_,
const struct timespec times_[2],
const int flags_)
{
return fs::utimensat(dirfd_,pathname_.c_str(),times_,flags_);
}
}

94
src/fs_xattr.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "fs_xattr.hpp"
#include "errno.hpp"
#include "fs_close.hpp"
#include "fs_fgetxattr.hpp"
@ -24,6 +26,7 @@
#include "fs_lremovexattr.hpp"
#include "fs_lsetxattr.hpp"
#include "fs_open.hpp"
#include "ghc/filesystem.hpp"
#include "str.hpp"
#include <map>
@ -37,6 +40,8 @@ using std::map;
using std::istringstream;
namespace gfs = ghc::filesystem;
namespace fs
{
namespace xattr
@ -47,9 +52,8 @@ namespace fs
{
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
rv = -ERANGE;
while(rv == -ERANGE)
{
rv = fs::flistxattr(fd_,NULL,0);
if(rv <= 0)
@ -64,14 +68,13 @@ namespace fs
}
int
list(const string &path_,
list(const gfs::path &path_,
vector<char> *attrs_)
{
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
rv = -ERANGE;
while(rv == -ERANGE)
{
rv = fs::llistxattr(path_,NULL,0);
if(rv <= 0)
@ -93,7 +96,7 @@ namespace fs
vector<char> attrs;
rv = fs::xattr::list(fd_,&attrs);
if(rv != -1)
if(rv > 0)
{
string tmp(attrs.begin(),attrs.end());
str::split(tmp,'\0',attrvector_);
@ -103,14 +106,14 @@ namespace fs
}
int
list(const string &path_,
list(const gfs::path &path_,
vector<string> *attrvector_)
{
int rv;
vector<char> attrs;
rv = fs::xattr::list(path_,&attrs);
if(rv != -1)
if(rv > 0)
{
string tmp(attrs.begin(),attrs.end());
str::split(tmp,'\0',attrvector_);
@ -127,21 +130,21 @@ namespace fs
vector<char> attrs;
rv = fs::xattr::list(fd_,&attrs);
if(rv != -1)
if(rv > 0)
*attrstr_ = string(attrs.begin(),attrs.end());
return rv;
}
int
list(const string &path_,
list(const gfs::path &path_,
string *attrstr_)
{
int rv;
vector<char> attrs;
rv = fs::xattr::list(path_,&attrs);
if(rv != -1)
if(rv > 0)
*attrstr_ = string(attrs.begin(),attrs.end());
return rv;
@ -154,9 +157,8 @@ namespace fs
{
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
rv = -ERANGE;
while(rv == -ERANGE)
{
rv = fs::fgetxattr(fd_,attr_,NULL,0);
if(rv <= 0)
@ -171,15 +173,14 @@ namespace fs
}
int
get(const string &path_,
get(const gfs::path &path_,
const string &attr_,
vector<char> *value_)
{
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
rv = -ERANGE;
while(rv == -ERANGE)
{
rv = fs::lgetxattr(path_,attr_,NULL,0);
if(rv <= 0)
@ -201,15 +202,15 @@ namespace fs
int rv;
vector<char> tmpvalue;
rv = get(fd_,attr_,&tmpvalue);
if(rv != -1)
rv = fs::xattr::get(fd_,attr_,&tmpvalue);
if(rv > 0)
*value_ = string(tmpvalue.begin(),tmpvalue.end());
return rv;
}
int
get(const string &path_,
get(const gfs::path &path_,
const string &attr_,
string *value_)
{
@ -217,7 +218,7 @@ namespace fs
vector<char> tmpvalue;
rv = fs::xattr::get(path_,attr_,&tmpvalue);
if(rv != -1)
if(rv > 0)
*value_ = string(tmpvalue.begin(),tmpvalue.end());
return rv;
@ -231,8 +232,8 @@ namespace fs
string attrstr;
rv = fs::xattr::list(fd_,&attrstr);
if(rv == -1)
return -1;
if(rv <= 0)
return rv;
{
string key;
@ -243,7 +244,7 @@ namespace fs
string value;
rv = fs::xattr::get(fd_,key,&value);
if(rv != -1)
if(rv > 0)
(*attrs_)[key] = value;
}
}
@ -252,15 +253,15 @@ namespace fs
}
int
get(const string &path_,
get(const gfs::path &path_,
map<string,string> *attrs_)
{
int rv;
string attrstr;
rv = fs::xattr::list(path_,&attrstr);
if(rv == -1)
return -1;
if(rv <= 0)
return rv;
{
string key;
@ -271,7 +272,7 @@ namespace fs
string value;
rv = fs::xattr::get(path_,key,&value);
if(rv != -1)
if(rv > 0)
(*attrs_)[key] = value;
}
}
@ -293,13 +294,13 @@ namespace fs
}
int
set(const string &path_,
set(const gfs::path &path_,
const string &key_,
const string &value_,
const int flags_)
{
return fs::lsetxattr(path_,
key_,
key_.c_str(),
value_.data(),
value_.size(),
flags_);
@ -309,28 +310,23 @@ namespace fs
set(const int fd_,
const map<string,string> &attrs_)
{
int rv;
for(map<string,string>::const_iterator
i = attrs_.begin(), ei = attrs_.end(); i != ei; ++i)
for(const auto &kv : attrs_)
{
rv = fs::xattr::set(fd_,i->first,i->second,0);
if(rv == -1)
return -1;
fs::xattr::set(fd_,kv.first,kv.second,0);
}
return 0;
}
int
set(const string &path_,
set(const gfs::path &path_,
const map<string,string> &attrs_)
{
int fd;
fd = fs::open(path_,O_RDONLY|O_NONBLOCK);
if(fd == -1)
return -1;
if(fd < 0)
return fd;
fs::xattr::set(fd,attrs_);
@ -345,22 +341,22 @@ namespace fs
map<string,string> attrs;
rv = fs::xattr::get(fdin_,&attrs);
if(rv == -1)
return -1;
if(rv < 0)
return rv;
return fs::xattr::set(fdout_,attrs);
}
int
copy(const string &from_,
const string &to_)
copy(const gfs::path &from_,
const gfs::path &to_)
{
int rv;
map<string,string> attrs;
rv = fs::xattr::get(from_,&attrs);
if(rv == -1)
return -1;
if(rv < 0)
return rv;
return fs::xattr::set(to_,attrs);
}

53
src/fs_xattr.hpp

@ -16,6 +16,8 @@
#pragma once
#include "ghc/filesystem.hpp"
#include <string>
#include <vector>
#include <map>
@ -25,43 +27,38 @@ namespace fs
{
namespace xattr
{
using std::string;
using std::vector;
using std::map;
int list(const string &path,
vector<char> *attrs);
int list(const string &path,
string *attrs);
int list(const string &path,
vector<string> *attrs);
int list(const ghc::filesystem::path &path,
std::vector<char> *attrs);
int list(const ghc::filesystem::path &path,
std::string *attrs);
int list(const ghc::filesystem::path &path,
std::vector<std::string> *attrs);
int get(const string &path,
const string &attr,
vector<char> *value);
int get(const string &path,
const string &attr,
string *value);
int get(const ghc::filesystem::path &path,
const std::string &attr,
std::vector<char> *value);
int get(const ghc::filesystem::path &path,
const std::string &attr,
std::string *value);
int get(const string &path,
map<string,string> *attrs);
int get(const ghc::filesystem::path &path,
std::map<std::string,std::string> *attrs);
int set(const string &path,
const string &key,
const string &value,
int set(const ghc::filesystem::path &path,
const std::string &key,
const std::string &value,
const int flags);
int set(const int fd,
const string &key,
const string &value,
const std::string &key,
const std::string &value,
const int flags);
int set(const string &path,
const map<string,string> &attrs);
int set(const ghc::filesystem::path &path,
const std::map<std::string,std::string> &attrs);
int copy(const int fdin,
const int fdout);
int copy(const string &from,
const string &to);
int copy(const ghc::filesystem::path &from,
const ghc::filesystem::path &to);
}
}

3
src/func.hpp

@ -18,8 +18,9 @@
#pragma once
#include "policy.hpp"
#include "from_toml.hpp"
#include "policies.hpp"
#include "policy.hpp"
#include "tofrom_string.hpp"
#include <string>

47
src/fuse_access.cpp

@ -14,57 +14,24 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.hpp"
#include "errno.hpp"
#include "fs_eaccess.hpp"
#include "fs_path.hpp"
#include "state.hpp"
#include "ugid.hpp"
#include <string>
#include <vector>
#include "fuse.h"
using std::string;
using std::vector;
namespace l
{
static
int
access(const Policy::Search &searchFunc_,
const Branches &branches_,
const char *fusepath_,
const int mask_)
{
int rv;
string fullpath;
StrVec basepaths;
rv = searchFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
fullpath = fs::path::make(basepaths[0],fusepath_);
rv = fs::eaccess(fullpath,mask_);
return ((rv == -1) ? -errno : 0);
}
}
namespace FUSE
namespace FUSE::ACCESS
{
int
access(const char *fusepath_,
int mask_)
int mode_)
{
Config::Read cfg;
State s;
gfs::path fusepath(&fusepath_[1]);
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
return l::access(cfg->func.access.policy,
cfg->branches,
fusepath_,
mask_);
return s->access(fusepath,mode_);
}
}

3
src/fuse_access.hpp

@ -16,8 +16,7 @@
#pragma once
namespace FUSE
namespace FUSE::ACCESS
{
int
access(const char *fusepath,

35
src/fuse_access_func.cpp

@ -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.
*/
#include "fuse_access_func.hpp"
#include "fuse_access_func_factory.hpp"
#include "toml.hpp"
FUSE::ACCESS::Func::Func(const toml::value &toml_)
{
_access = FuncFactory(toml_);
}
int
FUSE::ACCESS::Func::operator()(const gfs::path &fusepath_,
const int mask_)
{
return (*_access)(fusepath_,mask_);
}

40
src/fuse_access_func.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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS
{
class Func
{
public:
Func(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const int mask);
private:
FuncBase::Ptr _access;
};
}

37
src/fuse_access_func_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
{
class FuncBase
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const int mask) = 0;
};
}

37
src/fuse_access_func_factory.cpp

@ -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.
*/
#include "fuse_access_func_factory.hpp"
#include "fuse_access_func_ff.hpp"
#include <stdexcept>
namespace FUSE::ACCESS
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","access","policy","ff");
if(str == "ff")
return std::make_shared<FuncFF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_access_func_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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS
{
FuncBase::Ptr
FuncFactory(const toml::value &);
}

52
src/fuse_access_func_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_func_ff.hpp"
#include "fs_eaccess.hpp"
FUSE::ACCESS::FuncFF::FuncFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::ACCESS::FuncFF::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_func_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_func_base.hpp"
#include "branches.hpp"
namespace FUSE::ACCESS
{
class FuncFF : public FuncBase
{
public:
FuncFF(const toml::value&);
public:
int operator()(const gfs::path &fusepath,
const int mode) final;
private:
Branches2 _branches;
};
}

10
src/fuse_bmap.cpp

@ -16,6 +16,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "errno.hpp"
#include <cstdint>
@ -23,8 +25,14 @@
#include <stddef.h>
namespace FUSE
namespace FUSE::BMAP
{
int
config(const toml::value &cfg_)
{
return 0;
}
int
bmap(const char *fusepath_,
size_t blocksize_,

7
src/fuse_bmap.hpp

@ -18,10 +18,15 @@
#pragma once
#include "toml.hpp"
#include "fuse.h"
namespace FUSE
namespace FUSE::BMAP
{
int
config(const toml::value &cfg);
int
bmap(const char *fusepath,
size_t blocksize,

105
src/fuse_chmod.cpp

@ -14,119 +14,24 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.hpp"
#include "errno.hpp"
#include "fs_lchmod.hpp"
#include "fs_path.hpp"
#include "policy_rv.hpp"
#include "state.hpp"
#include "ugid.hpp"
#include "fuse.h"
#include <string>
#include <string.h>
using std::string;
namespace l
{
static
int
get_error(const PolicyRV &prv_,
const string &basepath_)
{
for(int i = 0, ei = prv_.success.size(); i < ei; i++)
{
if(prv_.success[i].basepath == basepath_)
return prv_.success[i].rv;
}
for(int i = 0, ei = prv_.error.size(); i < ei; i++)
{
if(prv_.error[i].basepath == basepath_)
return prv_.error[i].rv;
}
return 0;
}
static
void
chmod_loop_core(const string &basepath_,
const char *fusepath_,
const mode_t mode_,
PolicyRV *prv_)
{
string fullpath;
fullpath = fs::path::make(basepath_,fusepath_);
errno = 0;
fs::lchmod(fullpath,mode_);
prv_->insert(errno,basepath_);
}
static
void
chmod_loop(const StrVec &basepaths_,
const char *fusepath_,
const mode_t mode_,
PolicyRV *prv_)
{
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++)
{
l::chmod_loop_core(basepaths_[i],fusepath_,mode_,prv_);
}
}
static
int
chmod(const Policy::Action &actionFunc_,
const Policy::Search &searchFunc_,
const Branches &branches_,
const char *fusepath_,
const mode_t mode_)
{
int rv;
PolicyRV prv;
StrVec basepaths;
rv = actionFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
l::chmod_loop(basepaths,fusepath_,mode_,&prv);
if(prv.error.empty())
return 0;
if(prv.success.empty())
return prv.error[0].rv;
basepaths.clear();
rv = searchFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
return l::get_error(prv,basepaths[0]);
}
}
namespace FUSE
namespace FUSE::CHMOD
{
int
chmod(const char *fusepath_,
mode_t mode_)
{
Config::Read cfg;
State s;
gfs::path fusepath(&fusepath_[1]);
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
return l::chmod(cfg->func.chmod.policy,
cfg->func.getattr.policy,
cfg->branches,
fusepath_,
mode_);
return s->chmod(fusepath,mode_);
}
}

8
src/fuse_chmod.hpp

@ -16,9 +16,15 @@
#pragma once
#include "toml.hpp"
namespace FUSE
#include <sys/stat.h>
namespace FUSE::CHMOD
{
int
config(const toml::value &cfg);
int
chmod(const char *fusepath,
mode_t mode);

54
src/fuse_chmod_err.hpp

@ -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.
*/
#pragma once
namespace FUSE::CHMOD
{
class Err
{
public:
Err()
: _err(0)
{
}
public:
inline
Err&
operator=(const int err_)
{
if(_err != 0)
{
if(_err == -ENOENT)
_err = err_;
}
return *this;
}
public:
inline
operator int()
{
return _err;
}
private:
int _err;
};
}

35
src/fuse_chmod_func.cpp

@ -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.
*/
#include "fuse_chmod_func.hpp"
#include "fuse_chmod_func_factory.hpp"
#include "toml.hpp"
FUSE::CHMOD::Func::Func(const toml::value &toml_)
{
_chmod = FuncFactory(toml_);
}
int
FUSE::CHMOD::Func::operator()(const gfs::path &fusepath_,
const mode_t mode_)
{
return (*_chmod)(fusepath_,mode_);
}

42
src/fuse_chmod_func.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_func_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHMOD
{
class Func
{
public:
Func(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode);
private:
FuncBase::Ptr _chmod;
};
}

50
src/fuse_chmod_func_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_chmod_func_all.hpp"
#include "fuse_chmod_err.hpp"
#include "fs_lchmod.hpp"
FUSE::CHMOD::FuncALL::FuncALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHMOD::FuncALL::operator()(const gfs::path &fusepath_,
const mode_t mode_)
{
Err rv;
gfs::path fusepath;
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_func_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_func_base.hpp"
#include "branches.hpp"
namespace FUSE::CHMOD
{
class FuncALL : public FuncBase
{
public:
FuncALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode) final;
private:
Branches2 _branches;
};
}

37
src/fuse_chmod_func_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
{
class FuncBase
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode) = 0;
};
}

38
src/fuse_chmod_func_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_func_factory.hpp"
#include "fuse_chmod_func_all.hpp"
#include <stdexcept>
namespace FUSE::CHMOD
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chmod","policy","all");
if(str == "all")
return std::make_shared<FuncALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_chmod_func_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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::CHMOD
{
FuncBase::Ptr
FuncFactory(const toml::value &);
}

111
src/fuse_chown.cpp

@ -1,5 +1,5 @@
/*
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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
@ -14,124 +14,25 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.hpp"
#include "errno.hpp"
#include "fs_lchown.hpp"
#include "fs_path.hpp"
#include "policy_rv.hpp"
#include "state.hpp"
#include "ugid.hpp"
#include "fuse.h"
#include <string>
#include <vector>
using std::string;
using std::vector;
namespace l
{
static
int
get_error(const PolicyRV &prv_,
const string &basepath_)
{
for(int i = 0, ei = prv_.success.size(); i < ei; i++)
{
if(prv_.success[i].basepath == basepath_)
return prv_.success[i].rv;
}
for(int i = 0, ei = prv_.error.size(); i < ei; i++)
{
if(prv_.error[i].basepath == basepath_)
return prv_.error[i].rv;
}
return 0;
}
static
void
chown_loop_core(const string &basepath_,
const char *fusepath_,
const uid_t uid_,
const gid_t gid_,
PolicyRV *prv_)
{
string fullpath;
fullpath = fs::path::make(basepath_,fusepath_);
errno = 0;
fs::lchown(fullpath,uid_,gid_);
prv_->insert(errno,basepath_);
}
static
void
chown_loop(const vector<string> &basepaths_,
const char *fusepath_,
const uid_t uid_,
const gid_t gid_,
PolicyRV *prv_)
{
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++)
{
l::chown_loop_core(basepaths_[i],fusepath_,uid_,gid_,prv_);
}
}
static
int
chown(const Policy::Action &actionFunc_,
const Policy::Search &searchFunc_,
const Branches &branches_,
const char *fusepath_,
const uid_t uid_,
const gid_t gid_)
{
int rv;
PolicyRV prv;
vector<string> basepaths;
rv = actionFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
l::chown_loop(basepaths,fusepath_,uid_,gid_,&prv);
if(prv.error.empty())
return 0;
if(prv.success.empty())
return prv.error[0].rv;
basepaths.clear();
rv = searchFunc_(branches_,fusepath_,&basepaths);
if(rv == -1)
return -errno;
return l::get_error(prv,basepaths[0]);
}
}
namespace FUSE
namespace FUSE::CHOWN
{
int
chown(const char *fusepath_,
uid_t uid_,
gid_t gid_)
{
Config::Read cfg;
State s;
gfs::path fusepath(&fusepath_[1]);
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
return l::chown(cfg->func.chown.policy,
cfg->func.getattr.policy,
cfg->branches,
fusepath_,
uid_,
gid_);
return s->chown(fusepath,uid_,gid_);
}
}

6
src/fuse_chown.hpp

@ -16,8 +16,12 @@
#pragma once
#include "toml.hpp"
namespace FUSE
#include <unistd.h>
namespace FUSE::CHOWN
{
int
chown(const char *fusepath,

51
src/fuse_chown_err.hpp

@ -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.
*/
#pragma once
namespace FUSE::CHOWN
{
class Err
{
public:
Err()
: _err(-ENOENT)
{
}
public:
inline
Err&
operator=(const int err_)
{
if(_err == -ENOENT)
_err = err_;
return *this;
}
public:
inline
operator int()
{
return _err;
}
private:
int _err;
};
}

36
src/fuse_chown_func.cpp

@ -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.
*/
#include "fuse_chown_func.hpp"
#include "fuse_chown_func_factory.hpp"
#include "toml.hpp"
FUSE::CHOWN::Func::Func(const toml::value &toml_)
{
_chown = FuncFactory(toml_);
}
int
FUSE::CHOWN::Func::operator()(const gfs::path &fusepath_,
const uid_t uid_,
const gid_t gid_)
{
return (*_chown)(fusepath_,uid_,gid_);
}

43
src/fuse_chown_func.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_func_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHOWN
{
class Func
{
public:
Func(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid);
private:
FuncBase::Ptr _chown;
};
}

51
src/fuse_chown_func_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_chown_func_all.hpp"
#include "fuse_chown_err.hpp"
#include "fs_lchown.hpp"
FUSE::CHOWN::FuncALL::FuncALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHOWN::FuncALL::operator()(const gfs::path &fusepath_,
const uid_t uid_,
const gid_t gid_)
{
Err rv;
gfs::path fusepath;
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_func_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_func_base.hpp"
#include "branches.hpp"
namespace FUSE::CHOWN
{
class FuncALL : public FuncBase
{
public:
FuncALL(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_func_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
{
class FuncBase
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid) = 0;
};
}

38
src/fuse_chown_func_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_func_factory.hpp"
#include "fuse_chown_func_all.hpp"
#include <stdexcept>
namespace FUSE::CHOWN
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chown","policy","all");
if(str == "all")
return std::make_shared<FuncALL>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_chown_func_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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::CHOWN
{
FuncBase::Ptr
FuncFactory(const toml::value &);
}

10
src/fuse_copy_file_range.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_copy_file_range.hpp"
@ -47,8 +49,14 @@ namespace l
}
}
namespace FUSE
namespace FUSE::COPY_FILE_RANGE
{
int
config(const toml::value &cfg_)
{
return 0;
}
ssize_t
copy_file_range(const fuse_file_info_t *ffi_in_,
off_t offset_in_,

7
src/fuse_copy_file_range.hpp

@ -16,9 +16,14 @@
#pragma once
#include "toml.hpp"
namespace FUSE
namespace FUSE::COPY_FILE_RANGE
{
int
config(const toml::value &cfg);
ssize_t
copy_file_range(const fuse_file_info_t *ffi_in,
off_t offset_in,

22
src/fuse_create.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
@ -21,6 +23,7 @@
#include "fs_clonepath.hpp"
#include "fs_open.hpp"
#include "fs_path.hpp"
#include "state.hpp"
#include "ugid.hpp"
#include "fuse.h"
@ -164,10 +167,10 @@ namespace l
}
}
namespace FUSE
namespace FUSE::CREATE
{
int
create(const char *fusepath_,
create2(const char *fusepath_,
mode_t mode_,
fuse_file_info_t *ffi_)
{
@ -189,4 +192,19 @@ namespace FUSE
ffi_->flags,
&ffi_->fh);
}
int
create(const char *fusepath_,
mode_t mode_,
fuse_file_info_t *ffi_)
{
State s;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
if(s->writeback_cache)
l::tweak_flags_writeback_cache(&ffi_->flags);
return s->create(fusepath_,mode_,fc->umask,ffi_);
}
}

4
src/fuse_create.hpp

@ -16,12 +16,14 @@
#pragma once
#include "toml.hpp"
#include "fuse.h"
#include <sys/types.h>
namespace FUSE
namespace FUSE::CREATE
{
int
create(const char *fusepath,

37
src/fuse_create_func.cpp

@ -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.
*/
#include "fuse_create_func.hpp"
#include "fuse_create_func_factory.hpp"
#include "toml.hpp"
FUSE::CREATE::Func::Func(const toml::value &toml_)
{
_create = FuncFactory(toml_);
}
int
FUSE::CREATE::Func::operator()(const char *fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
return (*_create)(fusepath_,mode_,umask_,ffi_);
}

42
src/fuse_create_func.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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE
{
class Func
{
public:
Func(const toml::value &);
public:
int operator()(const char *fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi);
private:
FuncBase::Ptr _create;
};
}

39
src/fuse_create_func_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 "fuse.h"
#include <memory>
namespace FUSE::CREATE
{
class FuncBase
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const char *fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) = 0;
};
}

73
src/fuse_create_func_epff.cpp

@ -0,0 +1,73 @@
/*
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_func_epff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_open.hpp"
namespace gfs = ghc::filesystem;
FUSE::CREATE::FuncEPFF::FuncEPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::FuncEPFF::operator()(const char *fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fusepath;
gfs::path fullpath;
mode = mode_;
fusepath = &fusepath_[1];
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;
}

42
src/fuse_create_func_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_create_func_base.hpp"
#include "branches.hpp"
namespace FUSE::CREATE
{
class FuncEPFF : public FuncBase
{
public:
FuncEPFF(const toml::value&);
public:
int operator()(const char *fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

40
src/fuse_create_func_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_func_factory.hpp"
#include "fuse_create_func_ff.hpp"
#include "fuse_create_func_epff.hpp"
#include <stdexcept>
namespace FUSE::CREATE
{
FuncBase::Ptr
FuncFactory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","create","policy","ff");
if(str == "ff")
return std::make_shared<FuncFF>(toml_);
if(str == "epff")
return std::make_shared<FuncEPFF>(toml_);
throw std::runtime_error("");
}
}

30
src/fuse_create_func_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_func_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE
{
FuncBase::Ptr
FuncFactory(const toml::value &);
}

91
src/fuse_create_func_ff.cpp

@ -0,0 +1,91 @@
/*
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_func_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"
namespace gfs = ghc::filesystem;
FUSE::CREATE::FuncFF::FuncFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::FuncFF::operator()(const char *fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fusepath;
gfs::path fullpath;
mode = mode_;
fusepath = &fusepath_[1];
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_func_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_func_base.hpp"
#include "branches.hpp"
namespace FUSE::CREATE
{
class FuncFF : public FuncBase
{
public:
FuncFF(const toml::value&);
public:
int operator()(const char *fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

2
src/fuse_destroy.cpp

@ -14,7 +14,7 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
namespace FUSE
namespace FUSE::DESTROY
{
void
destroy(void)

2
src/fuse_destroy.hpp

@ -17,7 +17,7 @@
#pragma once
namespace FUSE
namespace FUSE::DESTROY
{
void
destroy(void);

10
src/fuse_fallocate.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_fallocate.hpp"
@ -38,8 +40,14 @@ namespace l
}
}
namespace FUSE
namespace FUSE::FALLOCATE
{
int
config(const toml::value &cfg_)
{
return 0;
}
int
fallocate(const fuse_file_info_t *ffi_,
int mode_,

7
src/fuse_fallocate.hpp

@ -16,11 +16,16 @@
#pragma once
#include "toml.hpp"
#include "fuse.h"
namespace FUSE
namespace FUSE::FALLOCATE
{
int
config(const toml::value &cfg);
int
fallocate(const fuse_file_info_t *ffi,
int mode,

10
src/fuse_fchmod.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_fchmod.hpp"
@ -38,8 +40,14 @@ namespace l
}
}
namespace FUSE
namespace FUSE::FCHMOD
{
int
config(const toml::value &cfg_)
{
return 0;
}
int
fchmod(const fuse_file_info_t *ffi_,
const mode_t mode_)

7
src/fuse_fchmod.hpp

@ -16,13 +16,18 @@
#pragma once
#include "toml.hpp"
#include "fuse.h"
#include <sys/stat.h>
namespace FUSE
namespace FUSE::FCHMOD
{
int
config(const toml::value &cfg);
int
fchmod(const fuse_file_info_t *ffi,
const mode_t mode);

10
src/fuse_fchown.cpp

@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "toml.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_fchown.hpp"
@ -41,8 +43,14 @@ namespace l
}
}
namespace FUSE
namespace FUSE::FCHOWN
{
int
config(const toml::value &cfg_)
{
return 0;
}
int
fchown(const fuse_file_info_t *ffi_,
const uid_t uid_,

7
src/fuse_fchown.hpp

@ -16,11 +16,16 @@
#pragma once
#include "toml.hpp"
#include "fuse.h"
namespace FUSE
namespace FUSE::FCHOWN
{
int
config(const toml::value &cfg);
int
fchown(const fuse_file_info_t *ffi,
uid_t uid,

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

Loading…
Cancel
Save