mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-25 09:41:43 +08:00
checkpoint
This commit is contained in:
parent
c8e8865495
commit
a675e14508
|
@ -28,10 +28,9 @@ namespace FUSE::ACCESS
|
|||
int mode_)
|
||||
{
|
||||
State s;
|
||||
gfs::path fusepath(&fusepath_[1]);
|
||||
const fuse_context *fc = fuse_get_context();
|
||||
const ugid::Set ugid(fc->uid,fc->gid);
|
||||
|
||||
return s->access(fusepath,mode_);
|
||||
return s->access(&fusepath_[1],mode_);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_access_policy_base.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
#include "fuse_access_policy_factory.hpp"
|
||||
|
||||
|
||||
namespace FUSE::ACCESS
|
||||
|
@ -28,11 +27,18 @@ namespace FUSE::ACCESS
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_access = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const int mask);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
const int mask_)
|
||||
{
|
||||
return (*_access)(fusepath_,mask_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _access;
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_chmod_policy_base.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
#include "fuse_chmod_policy_factory.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -30,11 +29,18 @@ namespace FUSE::CHMOD
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_chmod = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const mode_t mode);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
const mode_t mode_)
|
||||
{
|
||||
return (*_chmod)(fusepath_,mode_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _chmod;
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_chown_policy_base.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
#include "fuse_chown_policy_factory.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -30,12 +29,19 @@ namespace FUSE::CHOWN
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_chown = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const uid_t uid,
|
||||
const gid_t gid);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
{
|
||||
return (*_chown)(fusepath_,uid_,gid_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _chown;
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#include "fs_lchown.hpp"
|
||||
|
||||
|
||||
FUSE::CHOWN::POLICY::all::all(const toml::value &toml_)
|
||||
FUSE::CHOWN::POLICY::ALL::ALL(const toml::value &toml_)
|
||||
: _branches(toml_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::CHOWN::POLICY::all::operator()(const gfs::path &fusepath_,
|
||||
FUSE::CHOWN::POLICY::ALL::operator()(const gfs::path &fusepath_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_create_policy_base.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
#include "fuse_create_policy_factory.hpp"
|
||||
|
||||
|
||||
namespace FUSE::CREATE
|
||||
|
@ -28,13 +27,20 @@ namespace FUSE::CREATE
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_create = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const mode_t mode,
|
||||
const mode_t umask,
|
||||
fuse_file_info_t *ffi);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
const mode_t mode_,
|
||||
const mode_t umask_,
|
||||
fuse_file_info_t *ffi_)
|
||||
{
|
||||
return (*_create)(fusepath_,mode_,umask_,ffi_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _create;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_getattr_policy_base.hpp"
|
||||
#include "fuse_getattr_policy_factory.hpp"
|
||||
|
||||
#include "fuse_timeouts.h"
|
||||
|
||||
|
@ -32,12 +33,19 @@ namespace FUSE::GETATTR
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_getattr = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
struct stat *st,
|
||||
fuse_timeouts_t *timeout);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
struct stat *st_,
|
||||
fuse_timeouts_t *timeout_)
|
||||
{
|
||||
return (*_getattr)(fusepath_,st_,timeout_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _getattr;
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_getxattr_policy_base.hpp"
|
||||
#include "fuse_getxattr_policy_factory.hpp"
|
||||
|
||||
#include "fuse_timeouts.h"
|
||||
|
||||
#include "toml.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
@ -34,13 +33,20 @@ namespace FUSE::GETXATTR
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_getxattr = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const char *attrname,
|
||||
char *buf,
|
||||
size_t count);
|
||||
int
|
||||
operator()(const gfs::path &fusepath_,
|
||||
const char *attrname_,
|
||||
char *buf_,
|
||||
size_t count_)
|
||||
{
|
||||
return (*_getxattr)(fusepath_,attrname_,buf_,count_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _getxattr;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "fuse_getxattr_func_base.hpp"
|
||||
#include "fuse_getxattr_policy_base.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fuse_ioctl_policy_base.hpp"
|
||||
#include "fuse_ioctl_policy_factory.hpp"
|
||||
|
||||
#include "toml.hpp"
|
||||
|
||||
|
@ -28,14 +29,21 @@ namespace FUSE::IOCTL
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
Policy(const toml::value &);
|
||||
Policy(const toml::value &toml_)
|
||||
{
|
||||
_ioctl = POLICY::factory(toml_);
|
||||
}
|
||||
|
||||
public:
|
||||
int operator()(const fuse_file_info_t *ffi_,
|
||||
const unsigned long cmd,
|
||||
const unsigned int flags,
|
||||
void *data,
|
||||
uint32_t *out_bufsz);
|
||||
int
|
||||
operator()(const fuse_file_info_t *ffi_,
|
||||
const unsigned long cmd_,
|
||||
const unsigned int flags_,
|
||||
void *data_,
|
||||
uint32_t *out_bufsz_)
|
||||
{
|
||||
return (*_ioctl)(ffi_,cmd_,flags_,data_,out_bufsz_);
|
||||
}
|
||||
|
||||
private:
|
||||
POLICY::Base::Ptr _ioctl;
|
||||
|
|
|
@ -16,38 +16,33 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fuse_setxattr_func_all.hpp"
|
||||
#include "fuse_setxattr_err.hpp"
|
||||
#include "fuse_setxattr_policy_all.hpp"
|
||||
|
||||
#include "fs_lsetxattr.hpp"
|
||||
|
||||
|
||||
namespace gfs = ghc::filesystem;
|
||||
|
||||
|
||||
FUSE::SETXATTR::FuncALL::FuncALL(const toml::value &toml_)
|
||||
FUSE::SETXATTR::POLICY::ALL::ALL(const toml::value &toml_)
|
||||
: _branches(toml_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::SETXATTR::FuncALL::operator()(const char *fusepath_,
|
||||
const char *attrname_,
|
||||
const char *attrval_,
|
||||
const size_t attrvalsize_,
|
||||
const int flags_)
|
||||
FUSE::SETXATTR::POLICY::ALL::operator()(const gfs::path &fusepath_,
|
||||
const char *attrname_,
|
||||
const char *attrval_,
|
||||
const size_t attrvalsize_,
|
||||
const int flags_)
|
||||
{
|
||||
Err rv;
|
||||
gfs::path fusepath;
|
||||
gfs::path fullpath;
|
||||
|
||||
fusepath = &fusepath_[1];
|
||||
for(const auto &branch_group : _branches)
|
||||
{
|
||||
for(const auto &branch : branch_group)
|
||||
{
|
||||
fullpath = branch.path / fusepath;
|
||||
fullpath = branch.path / fusepath_;
|
||||
|
||||
rv = fs::lsetxattr(fullpath,
|
||||
attrname_,
|
||||
|
|
|
@ -18,24 +18,24 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "fuse_setxattr_func_base.hpp"
|
||||
#include "fuse_setxattr_policy_base.hpp"
|
||||
|
||||
#include "branches.hpp"
|
||||
|
||||
|
||||
namespace FUSE::SETXATTR
|
||||
namespace FUSE::SETXATTR::POLICY
|
||||
{
|
||||
class FuncALL : public FuncBase
|
||||
class ALL : public Base
|
||||
{
|
||||
public:
|
||||
FuncALL(const toml::value &);
|
||||
ALL(const toml::value &);
|
||||
|
||||
public:
|
||||
int operator()(const char *fusepath,
|
||||
const char *attrname,
|
||||
const char *attrval,
|
||||
const size_t attrvalsize,
|
||||
const int flags) final;
|
||||
int operator()(const gfs::path &fusepath,
|
||||
const char *attrname,
|
||||
const char *attrval,
|
||||
const size_t attrvalsize,
|
||||
const int flags) final;
|
||||
|
||||
private:
|
||||
Branches2 _branches;
|
||||
|
|
|
@ -16,15 +16,16 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fuse_setxattr_func_factory.hpp"
|
||||
#include "fuse_setxattr_func_all.hpp"
|
||||
#include "fuse_setxattr_policy_factory.hpp"
|
||||
|
||||
#include "fuse_setxattr_policy_all.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
namespace FUSE::SETXATTR
|
||||
namespace FUSE::SETXATTR::POLICY
|
||||
{
|
||||
FuncBase::Ptr
|
||||
Base::Ptr
|
||||
factory(const toml::value &toml_)
|
||||
{
|
||||
std::string str;
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace FUSE::SYMLINK
|
|||
|
||||
public:
|
||||
int
|
||||
operator()(const gfs::path &target_,
|
||||
const char *linkpath_)
|
||||
operator()(const char *target_,
|
||||
const gfs::path &linkpath_)
|
||||
{
|
||||
return (*_symlink)(target_,linkpath_);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace FUSE::SYMLINK::POLICY
|
|||
typedef std::shared_ptr<Base> Ptr;
|
||||
|
||||
public:
|
||||
virtual int operator()(const gfs::path &target,
|
||||
const char *linkpath) = 0;
|
||||
virtual int operator()(const char *target,
|
||||
const gfs::path &linkpath) = 0;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,34 +16,29 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fuse_symlink_func_epff.hpp"
|
||||
#include "fuse_symlink_policy_epff.hpp"
|
||||
|
||||
#include "fs_symlink.hpp"
|
||||
|
||||
|
||||
namespace gfs = ghc::filesystem;
|
||||
|
||||
|
||||
FUSE::SYMLINK::FuncEPFF::FuncEPFF(const toml::value &toml_)
|
||||
FUSE::SYMLINK::POLICY::EPFF::EPFF(const toml::value &toml_)
|
||||
: _branches(toml_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::SYMLINK::FuncEPFF::operator()(const char *target_,
|
||||
const char *linkpath_)
|
||||
FUSE::SYMLINK::POLICY::EPFF::operator()(const char *target_,
|
||||
const gfs::path &linkpath_)
|
||||
{
|
||||
int rv;
|
||||
gfs::path linkpath;
|
||||
gfs::path fullpath;
|
||||
|
||||
linkpath = &linkpath_[1];
|
||||
for(const auto &branch_group : _branches)
|
||||
{
|
||||
for(const auto &branch : branch_group)
|
||||
{
|
||||
fullpath = branch.path / linkpath;
|
||||
fullpath = branch.path / linkpath_;
|
||||
|
||||
rv = fs::symlink(target_,fullpath);
|
||||
if(rv == -ENOENT)
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY
|
|||
EPFF(const toml::value &);
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &target,
|
||||
const char *linkpath) final;
|
||||
int operator()(const char *target,
|
||||
const gfs::path &linkpath) final;
|
||||
|
||||
private:
|
||||
Branches2 _branches;
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace FUSE::SYMLINK::POLICY
|
|||
FF(const toml::value &);
|
||||
|
||||
public:
|
||||
int operator()(const gfs::path &target,
|
||||
const char *linkpath) final;
|
||||
int operator()(const char *target,
|
||||
const gfs::path &linkpath) final;
|
||||
|
||||
private:
|
||||
Branches2 _branches;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "errno.hpp"
|
||||
|
||||
|
||||
namespace FUSE::UNLINK
|
||||
{
|
||||
class Err
|
||||
|
|
|
@ -16,34 +16,29 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fuse_unlink_func_all.hpp"
|
||||
#include "fuse_unlink_err.hpp"
|
||||
#include "fuse_unlink_policy_all.hpp"
|
||||
|
||||
#include "fs_unlink.hpp"
|
||||
|
||||
|
||||
namespace gfs = ghc::filesystem;
|
||||
|
||||
|
||||
FUSE::UNLINK::FuncALL::FuncALL(const toml::value &toml_)
|
||||
FUSE::UNLINK::POLICY::ALL::ALL(const toml::value &toml_)
|
||||
: _branches(toml_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::UNLINK::FuncALL::operator()(const char *fusepath_)
|
||||
FUSE::UNLINK::POLICY::ALL::operator()(const gfs::path &fusepath_)
|
||||
{
|
||||
Err rv;
|
||||
gfs::path fusepath;
|
||||
gfs::path fullpath;
|
||||
|
||||
fusepath = &fusepath_[1];
|
||||
for(const auto &branch_group : _branches)
|
||||
{
|
||||
for(const auto &branch : branch_group)
|
||||
{
|
||||
fullpath = branch.path / fusepath;
|
||||
fullpath = branch.path / fusepath_;
|
||||
|
||||
rv = fs::unlink(fullpath);
|
||||
}
|
||||
|
|
|
@ -18,20 +18,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "fuse_unlink_func_base.hpp"
|
||||
#include "fuse_unlink_policy_base.hpp"
|
||||
|
||||
#include "branches.hpp"
|
||||
|
||||
|
||||
namespace FUSE::UNLINK
|
||||
namespace FUSE::UNLINK::POLICY
|
||||
{
|
||||
class FuncALL : public FuncBase
|
||||
class ALL : public Base
|
||||
{
|
||||
public:
|
||||
FuncALL(const toml::value &);
|
||||
ALL(const toml::value &);
|
||||
|
||||
public:
|
||||
int operator()(const char *fusepath) final;
|
||||
int operator()(const gfs::path &fusepath) final;
|
||||
|
||||
private:
|
||||
Branches2 _branches;
|
||||
|
|
|
@ -16,35 +16,30 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fuse_utimens_func_all.hpp"
|
||||
#include "fuse_utimens_policy_all.hpp"
|
||||
#include "fuse_utimens_err.hpp"
|
||||
|
||||
#include "fs_lutimens.hpp"
|
||||
|
||||
|
||||
namespace gfs = ghc::filesystem;
|
||||
|
||||
|
||||
FUSE::UTIMENS::FuncALL::FuncALL(const toml::value &toml_)
|
||||
FUSE::UTIMENS::POLICY::ALL::ALL(const toml::value &toml_)
|
||||
: _branches(toml_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::UTIMENS::FuncALL::operator()(const char *fusepath_,
|
||||
const timespec ts_[2])
|
||||
FUSE::UTIMENS::POLICY::ALL::operator()(const gfs::path &fusepath_,
|
||||
const timespec ts_[2])
|
||||
{
|
||||
Err rv;
|
||||
gfs::path fusepath;
|
||||
gfs::path fullpath;
|
||||
|
||||
fusepath = &fusepath_[1];
|
||||
for(const auto &branch_group : _branches)
|
||||
{
|
||||
for(const auto &branch : branch_group)
|
||||
{
|
||||
fullpath = branch.path / fusepath;
|
||||
fullpath = branch.path / fusepath_;
|
||||
|
||||
rv = fs::lutimens(fullpath,ts_);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user