mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
4 years ago
361 changed files with 20996 additions and 1605 deletions
-
2LICENSE
-
89config.toml
-
22src/branch.cpp
-
56src/branch.hpp
-
94src/branch_group.cpp
-
31src/branch_group.hpp
-
21src/branches.cpp
-
10src/branches.hpp
-
38src/config.cpp
-
10src/config.hpp
-
23src/config_inodecalc.cpp
-
5src/config_inodecalc.hpp
-
58src/config_link_exdev.cpp
-
27src/from_toml.hpp
-
13src/fs_acl.cpp
-
5src/fs_acl.hpp
-
6src/fs_attr.hpp
-
85src/fs_attr_linux.icpp
-
237src/fs_clonepath.cpp
-
9src/fs_clonepath.hpp
-
49src/fs_clonepath_branches.cpp
-
30src/fs_clonepath_branches.hpp
-
6src/fs_close.hpp
-
12src/fs_exists.hpp
-
8src/fs_flistxattr.hpp
-
43src/fs_glob.cpp
-
6src/fs_glob.hpp
-
18src/fs_ioctl.hpp
-
21src/fs_lchmod.hpp
-
43src/fs_lgetxattr.hpp
-
30src/fs_link.hpp
-
21src/fs_llistxattr.hpp
-
30src/fs_lsetxattr.hpp
-
17src/fs_lstat.hpp
-
10src/fs_lutimens.hpp
-
6src/fs_mkdir.hpp
-
29src/fs_open.hpp
-
5src/fs_path.hpp
-
24src/fs_readlink.hpp
-
21src/fs_symlink.hpp
-
17src/fs_truncate.hpp
-
16src/fs_unlink.hpp
-
19src/fs_utimensat_freebsd.hpp
-
8src/fs_utimensat_generic.hpp
-
19src/fs_utimensat_linux.hpp
-
114src/fs_xattr.cpp
-
59src/fs_xattr.hpp
-
3src/func.hpp
-
47src/fuse_access.cpp
-
3src/fuse_access.hpp
-
35src/fuse_access_func.cpp
-
40src/fuse_access_func.hpp
-
37src/fuse_access_func_base.hpp
-
37src/fuse_access_func_factory.cpp
-
30src/fuse_access_func_factory.hpp
-
52src/fuse_access_func_ff.cpp
-
40src/fuse_access_func_ff.hpp
-
10src/fuse_bmap.cpp
-
7src/fuse_bmap.hpp
-
105src/fuse_chmod.cpp
-
8src/fuse_chmod.hpp
-
54src/fuse_chmod_err.hpp
-
35src/fuse_chmod_func.cpp
-
42src/fuse_chmod_func.hpp
-
50src/fuse_chmod_func_all.cpp
-
40src/fuse_chmod_func_all.hpp
-
37src/fuse_chmod_func_base.hpp
-
38src/fuse_chmod_func_factory.cpp
-
30src/fuse_chmod_func_factory.hpp
-
111src/fuse_chown.cpp
-
6src/fuse_chown.hpp
-
51src/fuse_chown_err.hpp
-
36src/fuse_chown_func.cpp
-
43src/fuse_chown_func.hpp
-
51src/fuse_chown_func_all.cpp
-
41src/fuse_chown_func_all.hpp
-
40src/fuse_chown_func_base.hpp
-
38src/fuse_chown_func_factory.cpp
-
30src/fuse_chown_func_factory.hpp
-
10src/fuse_copy_file_range.cpp
-
7src/fuse_copy_file_range.hpp
-
22src/fuse_create.cpp
-
4src/fuse_create.hpp
-
37src/fuse_create_func.cpp
-
42src/fuse_create_func.hpp
-
39src/fuse_create_func_base.hpp
-
73src/fuse_create_func_epff.cpp
-
42src/fuse_create_func_epff.hpp
-
40src/fuse_create_func_factory.cpp
-
30src/fuse_create_func_factory.hpp
-
91src/fuse_create_func_ff.cpp
-
42src/fuse_create_func_ff.hpp
-
2src/fuse_destroy.cpp
-
2src/fuse_destroy.hpp
-
10src/fuse_fallocate.cpp
-
7src/fuse_fallocate.hpp
-
10src/fuse_fchmod.cpp
-
7src/fuse_fchmod.hpp
-
10src/fuse_fchown.cpp
-
7src/fuse_fchown.hpp
@ -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' |
@ -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); |
|||
} |
|||
} |
@ -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); |
|||
}; |
@ -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; |
|||
} |
@ -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; |
|||
}; |
@ -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; |
|||
} |
@ -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_); |
|||
} |
@ -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_); |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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(""); |
|||
} |
|||
} |
@ -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 &); |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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_); |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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(""); |
|||
} |
|||
} |
@ -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 &); |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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_); |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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(""); |
|||
} |
|||
} |
@ -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 &); |
|||
} |
@ -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_); |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
}; |
|||
} |
@ -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(""); |
|||
} |
|||
} |
@ -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 &); |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
}; |
|||
} |
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue