checkpoint

This commit is contained in:
Antonio SJ Musumeci 2022-05-15 16:05:40 -04:00
parent cba7433166
commit dc8baee8a6
18 changed files with 54 additions and 93 deletions

View file

@ -27,12 +27,6 @@ FUSE::GETATTR::Func::Func(const toml::value &toml_)
_getattr = FuncFactory(toml_); _getattr = FuncFactory(toml_);
} }
void
FUSE::GETATTR::Func::operator=(const toml::value &toml_)
{
_getattr = FuncFactory(toml_);
}
int int
FUSE::GETATTR::Func::operator()(const gfs::path &fusepath_, FUSE::GETATTR::Func::operator()(const gfs::path &fusepath_,
struct stat *st_, struct stat *st_,

View file

@ -39,9 +39,6 @@ namespace FUSE::GETATTR
struct stat *st, struct stat *st,
fuse_timeouts_t *timeout); fuse_timeouts_t *timeout);
void operator=(const toml::value&);
private: private:
FuncBase::Ptr _getattr; FuncBase::Ptr _getattr;
}; };

View file

@ -93,9 +93,11 @@ namespace FUSE::LISTXATTR
size_t size_) size_t size_)
{ {
State s; State s;
gfs::path fusepath;
const fuse_context *fc = fuse_get_context(); const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid); const ugid::Set ugid(fc->uid,fc->gid);
return s->listxattr(fusepath_,list_,size_); fusepath = &fusepath_[1];
return s->listxattr(fusepath,list_,size_);
} }
} }

View file

@ -25,16 +25,10 @@ FUSE::LISTXATTR::Func::Func(const toml::value &toml_)
_listxattr = FuncFactory(toml_); _listxattr = FuncFactory(toml_);
} }
void
FUSE::LISTXATTR::Func::operator=(const toml::value &toml_)
{
_listxattr = FuncFactory(toml_);
}
int int
FUSE::LISTXATTR::Func::operator()(const char *fusepath_, FUSE::LISTXATTR::Func::operator()(const gfs::path &fusepath_,
char *list_, char *list_,
const size_t size_) const size_t size_)
{ {
return (*_listxattr)(fusepath_,list_,size_); return (*_listxattr)(fusepath_,list_,size_);
} }

View file

@ -33,12 +33,9 @@ namespace FUSE::LISTXATTR
Func(const toml::value &); Func(const toml::value &);
public: public:
int operator()(const char *fusepath, int operator()(const gfs::path &fusepath,
char *buf, char *buf,
size_t count); size_t count);
void operator=(const toml::value&);
private: private:
FuncBase::Ptr _listxattr; FuncBase::Ptr _listxattr;

View file

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "fs_path.hpp"
#include <memory> #include <memory>
@ -29,9 +31,8 @@ namespace FUSE::LISTXATTR
typedef std::shared_ptr<FuncBase> Ptr; typedef std::shared_ptr<FuncBase> Ptr;
public: public:
virtual int operator()(const char *fusepath, virtual int operator()(const gfs::path &fusepath,
char *list, char *list,
const size_t size) = 0; const size_t size) = 0;
}; };
} }

View file

@ -21,9 +21,6 @@
#include "fs_llistxattr.hpp" #include "fs_llistxattr.hpp"
namespace gfs = ghc::filesystem;
FUSE::LISTXATTR::FuncFF::FuncFF(const toml::value &toml_) FUSE::LISTXATTR::FuncFF::FuncFF(const toml::value &toml_)
: _branches(toml_) : _branches(toml_)
{ {
@ -31,20 +28,18 @@ FUSE::LISTXATTR::FuncFF::FuncFF(const toml::value &toml_)
} }
int int
FUSE::LISTXATTR::FuncFF::operator()(const char *fusepath_, FUSE::LISTXATTR::FuncFF::operator()(const gfs::path &fusepath_,
char *list_, char *list_,
const size_t size_) const size_t size_)
{ {
int rv; int rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath; fullpath = branch.path / fusepath_;
rv = fs::llistxattr(fullpath,list_,size_); rv = fs::llistxattr(fullpath,list_,size_);
if(rv == -ENOENT) if(rv == -ENOENT)

View file

@ -32,9 +32,9 @@ namespace FUSE::LISTXATTR
FuncFF(const toml::value&); FuncFF(const toml::value&);
public: public:
int operator()(const char *fusepath, int operator()(const gfs::path &fusepath,
char *list, char *list,
const size_t size) final; const size_t size) final;
private: private:
Branches2 _branches; Branches2 _branches;

View file

@ -148,30 +148,16 @@ namespace l
namespace FUSE::MKDIR namespace FUSE::MKDIR
{ {
int
mkdir_old(const char *fusepath_,
mode_t mode_)
{
Config::Read cfg;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
return l::mkdir(cfg->func.getattr.policy,
cfg->func.mkdir.policy,
cfg->branches,
fusepath_,
mode_,
fc->umask);
}
int int
mkdir(const char *fusepath_, mkdir(const char *fusepath_,
mode_t mode_) mode_t mode_)
{ {
State s; State s;
gfs::path fusepath;
const fuse_context *fc = fuse_get_context(); const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid); const ugid::Set ugid(fc->uid,fc->gid);
return s->mkdir(fusepath_,mode_,fc->umask); fusepath = &fusepath_[1];
return s->mkdir(fusepath,mode_,fc->umask);
} }
} }

View file

@ -28,9 +28,9 @@ FUSE::MKDIR::Func::Func(const toml::value &toml_)
} }
int int
FUSE::MKDIR::Func::operator()(const char *fusepath_, FUSE::MKDIR::Func::operator()(const gfs::path &fusepath_,
const mode_t mode_, const mode_t mode_,
const mode_t umask_) const mode_t umask_)
{ {
return (*_mkdir)(fusepath_,mode_,umask_); return (*_mkdir)(fusepath_,mode_,umask_);
} }

View file

@ -31,9 +31,9 @@ namespace FUSE::MKDIR
Func(const toml::value &); Func(const toml::value &);
public: public:
int operator()(const char *fusepath, int operator()(const gfs::path &fusepath,
const mode_t mode, const mode_t mode,
const mode_t umask); const mode_t umask);
private: private:
FuncBase::Ptr _mkdir; FuncBase::Ptr _mkdir;

View file

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "fs_path.hpp"
#include "fuse.h" #include "fuse.h"
#include <memory> #include <memory>
@ -31,8 +33,8 @@ namespace FUSE::MKDIR
typedef std::shared_ptr<FuncBase> Ptr; typedef std::shared_ptr<FuncBase> Ptr;
public: public:
virtual int operator()(const char *fusepath, virtual int operator()(const gfs::path &fusepath,
const mode_t mode, const mode_t mode,
const mode_t umask) = 0; const mode_t umask) = 0;
}; };
} }

View file

@ -30,20 +30,18 @@ FUSE::MKDIR::FuncEPFF::FuncEPFF(const toml::value &toml_)
} }
int int
FUSE::MKDIR::FuncEPFF::operator()(const char *fusepath_, FUSE::MKDIR::FuncEPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_, const mode_t mode_,
const mode_t umask_) const mode_t umask_)
{ {
int rv; int rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath; fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_); rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT) if(rv == -ENOENT)

View file

@ -31,9 +31,9 @@ namespace FUSE::MKDIR
FuncEPFF(const toml::value&); FuncEPFF(const toml::value&);
public: public:
int operator()(const char *fusepath, int operator()(const gfs::path &fusepath,
const mode_t mode, const mode_t mode,
const mode_t umask) final; const mode_t umask) final;
private: private:
Branches2 _branches; Branches2 _branches;

View file

@ -32,25 +32,23 @@ FUSE::MKDIR::FuncFF::FuncFF(const toml::value &toml_)
} }
int int
FUSE::MKDIR::FuncFF::operator()(const char *fusepath_, FUSE::MKDIR::FuncFF::operator()(const gfs::path &fusepath_,
const mode_t mode_, const mode_t mode_,
const mode_t umask_) const mode_t umask_)
{ {
int rv; int rv;
gfs::path fusepath;
gfs::path fullpath; gfs::path fullpath;
fusepath = &fusepath_[1];
for(const auto &branch_group : _branches) for(const auto &branch_group : _branches)
{ {
for(const auto &branch : branch_group) for(const auto &branch : branch_group)
{ {
fullpath = branch.path / fusepath; fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_); rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT) if(rv == -ENOENT)
{ {
rv = fs::clonepath_as_root(_branches,branch.path,fusepath); rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0) if(rv >= 0)
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_); rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
} }

View file

@ -31,9 +31,9 @@ namespace FUSE::MKDIR
FuncFF(const toml::value&); FuncFF(const toml::value&);
public: public:
int operator()(const char *fusepath, int operator()(const gfs::path &fusepath,
const mode_t mode, const mode_t mode,
const mode_t umask) final; const mode_t umask) final;
private: private:
Branches2 _branches; Branches2 _branches;

View file

@ -22,9 +22,6 @@
#include "fs_mkdir.hpp" #include "fs_mkdir.hpp"
namespace gfs = ghc::filesystem;
int int
FUSE::MKDIR::mkdir(const gfs::path &fullpath_, FUSE::MKDIR::mkdir(const gfs::path &fullpath_,
const mode_t mode_, const mode_t mode_,

View file

@ -18,7 +18,7 @@
#pragma once #pragma once
#include "ghc/filesystem.hpp" #include "fs_path.hpp"
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
@ -27,7 +27,7 @@
namespace FUSE::MKDIR namespace FUSE::MKDIR
{ {
int int
mkdir(const ghc::filesystem::path &fullpath, mkdir(const gfs::path &fullpath,
const mode_t mode, const mode_t mode,
const mode_t umask); const mode_t umask);
} }