Browse Source

checkpoint

toml
Antonio SJ Musumeci 3 years ago
parent
commit
cba7433166
  1. 14
      src/fh.hpp
  2. 16
      src/fileinfo.hpp
  3. 1
      src/fuse_chmod_func_all.cpp
  4. 3
      src/fuse_create.cpp
  5. 2
      src/fuse_create_func.cpp
  6. 2
      src/fuse_create_func.hpp
  7. 4
      src/fuse_create_func_base.hpp
  8. 9
      src/fuse_create_func_epff.cpp
  9. 4
      src/fuse_create_func_epff.hpp
  10. 10
      src/fuse_create_func_ff.cpp
  11. 2
      src/fuse_create_func_ff.hpp
  12. 5
      src/fuse_getattr.cpp
  13. 2
      src/fuse_getattr_func.cpp
  14. 2
      src/fuse_getattr_func.hpp
  15. 5
      src/fuse_getattr_func_aggregate.cpp
  16. 2
      src/fuse_getattr_func_aggregate.hpp
  17. 4
      src/fuse_getattr_func_base.hpp
  18. 8
      src/fuse_getattr_func_check_ff.cpp
  19. 2
      src/fuse_getattr_func_check_ff.hpp
  20. 6
      src/fuse_getattr_func_ff.cpp
  21. 2
      src/fuse_getattr_func_ff.hpp
  22. 5
      src/fuse_getattr_func_newest.cpp
  23. 2
      src/fuse_getattr_func_newest.hpp
  24. 4
      src/fuse_getxattr.cpp
  25. 14
      src/fuse_getxattr_func.cpp
  26. 13
      src/fuse_getxattr_func.hpp
  27. 10
      src/fuse_getxattr_func_base.hpp
  28. 12
      src/fuse_getxattr_func_ff.cpp
  29. 8
      src/fuse_getxattr_func_ff.hpp
  30. 8
      src/fuse_ioctl.cpp
  31. 12
      src/fuse_link.cpp
  32. 4
      src/fuse_link_func.hpp
  33. 14
      src/fuse_link_func_all.cpp
  34. 6
      src/fuse_link_func_all.hpp
  35. 6
      src/fuse_link_func_base.hpp

14
src/fh.hpp

@ -16,6 +16,8 @@
#pragma once
#include "fs_path.hpp"
#include <string>
@ -27,6 +29,16 @@ public:
{
}
FH(const gfs::path &fusepath_)
: fusepath(fusepath_)
{
}
FH(const std::string &fusepath_)
: fusepath(fusepath_)
{
}
public:
std::string fusepath;
gfs::path fusepath;
};

16
src/fileinfo.hpp

@ -18,8 +18,6 @@
#include "fh.hpp"
#include <string>
class FileInfo : public FH
{
@ -31,6 +29,20 @@ public:
{
}
FileInfo(const int fd_,
const std::string &fusepath_)
: FH(fusepath_),
fd(fd_)
{
}
FileInfo(const int fd_,
const gfs::path &fusepath_)
: FH(fusepath_),
fd(fd_)
{
}
public:
int fd;
};

1
src/fuse_chmod_func_all.cpp

@ -33,7 +33,6 @@ 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)

3
src/fuse_create.cpp

@ -199,12 +199,13 @@ namespace FUSE::CREATE
fuse_file_info_t *ffi_)
{
State s;
gfs::path fusepath(fusepath_);
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_);
return s->create(fusepath,mode_,fc->umask,ffi_);
}
}

2
src/fuse_create_func.cpp

@ -28,7 +28,7 @@ FUSE::CREATE::Func::Func(const toml::value &toml_)
}
int
FUSE::CREATE::Func::operator()(const char *fusepath_,
FUSE::CREATE::Func::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)

2
src/fuse_create_func.hpp

@ -31,7 +31,7 @@ namespace FUSE::CREATE
Func(const toml::value &);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi);

4
src/fuse_create_func_base.hpp

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

9
src/fuse_create_func_epff.cpp

@ -23,9 +23,6 @@
#include "fs_open.hpp"
namespace gfs = ghc::filesystem;
FUSE::CREATE::FuncEPFF::FuncEPFF(const toml::value &toml_)
: _branches(toml_)
{
@ -33,23 +30,21 @@ FUSE::CREATE::FuncEPFF::FuncEPFF(const toml::value &toml_)
}
int
FUSE::CREATE::FuncEPFF::operator()(const char *fusepath_,
FUSE::CREATE::FuncEPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path 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;
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)

4
src/fuse_create_func_epff.hpp

@ -22,6 +22,8 @@
#include "branches.hpp"
#include "fs_path.hpp"
namespace FUSE::CREATE
{
@ -31,7 +33,7 @@ namespace FUSE::CREATE
FuncEPFF(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;

10
src/fuse_create_func_ff.cpp

@ -36,28 +36,26 @@ FUSE::CREATE::FuncFF::FuncFF(const toml::value &toml_)
}
int
FUSE::CREATE::FuncFF::operator()(const char *fusepath_,
FUSE::CREATE::FuncFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path 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;
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath);
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = fs::acl::dir_has_defaults(fullpath);
}
@ -68,7 +66,7 @@ FUSE::CREATE::FuncFF::operator()(const char *fusepath_,
rv = fs::open(fullpath,ffi_->flags,mode);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath);
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
{
rv = fs::acl::dir_has_defaults(fullpath);

2
src/fuse_create_func_ff.hpp

@ -31,7 +31,7 @@ namespace FUSE::CREATE
FuncFF(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;

5
src/fuse_getattr.cpp

@ -30,12 +30,13 @@ namespace FUSE::GETATTR
struct stat *st_,
fuse_timeouts_t *timeout_)
{
State s;
int rv;
State s;
gfs::path fusepath(fusepath_);
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
rv = s->getattr(fusepath_,st_,timeout_);
rv = s->getattr(fusepath,st_,timeout_);
if(rv < 0)
return rv;

2
src/fuse_getattr_func.cpp

@ -34,7 +34,7 @@ FUSE::GETATTR::Func::operator=(const toml::value &toml_)
}
int
FUSE::GETATTR::Func::operator()(const char *fusepath_,
FUSE::GETATTR::Func::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{

2
src/fuse_getattr_func.hpp

@ -35,7 +35,7 @@ namespace FUSE::GETATTR
Func(const toml::value &);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout);

5
src/fuse_getattr_func_aggregate.cpp

@ -35,7 +35,7 @@ FUSE::GETATTR::FuncAggregate::FuncAggregate(const toml::value &toml_)
}
int
FUSE::GETATTR::FuncAggregate::operator()(const char *fusepath_,
FUSE::GETATTR::FuncAggregate::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
@ -48,8 +48,7 @@ FUSE::GETATTR::FuncAggregate::operator()(const char *fusepath_,
{
for(const auto &branch : branch_group)
{
fullpath = branch.path;
fullpath /= &fusepath_[1];
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)

2
src/fuse_getattr_func_aggregate.hpp

@ -33,7 +33,7 @@ namespace FUSE::GETATTR
FuncAggregate(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;

4
src/fuse_getattr_func_base.hpp

@ -18,7 +18,7 @@
#pragma once
#include "from_toml.hpp"
#include "fs_path.hpp"
#include "fuse_timeouts.h"
@ -34,7 +34,7 @@ namespace FUSE::GETATTR
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const char *fusepath,
virtual int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) = 0;
};

8
src/fuse_getattr_func_check_ff.cpp

@ -51,7 +51,7 @@ FUSE::GETATTR::FuncCheckFF::FuncCheckFF(const toml::value &toml_)
}
int
FUSE::GETATTR::FuncCheckFF::operator()(const char *fusepath_,
FUSE::GETATTR::FuncCheckFF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
@ -65,8 +65,7 @@ FUSE::GETATTR::FuncCheckFF::operator()(const char *fusepath_,
{
for(j = 0, ej = _branches[i].size(); j < ej; j++)
{
fullpath = _branches[i][j].path;
fullpath /= &fusepath_[1];
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
@ -83,8 +82,7 @@ FUSE::GETATTR::FuncCheckFF::operator()(const char *fusepath_,
{
for(; j < ej; j++)
{
fullpath = _branches[i][j].path;
fullpath /= &fusepath_[1];
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)

2
src/fuse_getattr_func_check_ff.hpp

@ -33,7 +33,7 @@ namespace FUSE::GETATTR
FuncCheckFF(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;

6
src/fuse_getattr_func_ff.cpp

@ -31,20 +31,18 @@ FUSE::GETATTR::FuncFF::FuncFF(const toml::value &toml_)
}
int
FUSE::GETATTR::FuncFF::operator()(const char *fusepath_,
FUSE::GETATTR::FuncFF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int 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 = _statfunc(fullpath,st_);
if(rv == -ENOENT)

2
src/fuse_getattr_func_ff.hpp

@ -33,7 +33,7 @@ namespace FUSE::GETATTR
FuncFF(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;

5
src/fuse_getattr_func_newest.cpp

@ -33,7 +33,7 @@ FUSE::GETATTR::FuncNewest::FuncNewest(const toml::value &toml_)
}
int
FUSE::GETATTR::FuncNewest::operator()(const char *fusepath_,
FUSE::GETATTR::FuncNewest::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
@ -46,8 +46,7 @@ FUSE::GETATTR::FuncNewest::operator()(const char *fusepath_,
{
for(const auto &branch : branch_group)
{
fullpath = branch.path;
fullpath /= &fusepath_[1];
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)

2
src/fuse_getattr_func_newest.hpp

@ -33,7 +33,7 @@ namespace FUSE::GETATTR
FuncNewest(const toml::value&);
public:
int operator()(const char *fusepath,
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;

4
src/fuse_getxattr.cpp

@ -194,13 +194,15 @@ namespace FUSE::GETXATTR
size_t count_)
{
State s;
gfs::path fusepath;
fusepath = &fusepath_[1];
if((s->security_capability == false) && l::is_attrname_security_capability(attrname_))
return -ENOATTR;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
return s->getxattr(fusepath_,attrname_,buf_,count_);
return s->getxattr(fusepath,attrname_,buf_,count_);
}
}

14
src/fuse_getxattr_func.cpp

@ -27,17 +27,11 @@ FUSE::GETXATTR::Func::Func(const toml::value &toml_)
_getxattr = FuncFactory(toml_);
}
void
FUSE::GETXATTR::Func::operator=(const toml::value &toml_)
{
_getxattr = FuncFactory(toml_);
}
int
FUSE::GETXATTR::Func::operator()(const char *fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
FUSE::GETXATTR::Func::operator()(const gfs::path &fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
{
return (*_getxattr)(fusepath_,attrname_,buf_,count_);
}

13
src/fuse_getxattr_func.hpp

@ -18,11 +18,12 @@
#pragma once
#include "from_toml.hpp"
#include "fuse_getxattr_func_base.hpp"
#include "fuse_timeouts.h"
#include "toml.hpp"
#include <memory>
#include <sys/stat.h>
@ -35,12 +36,10 @@ namespace FUSE::GETXATTR
Func(const toml::value &);
public:
int operator()(const char *fusepath,
const char *attrname,
char *buf,
size_t count);
void operator=(const toml::value&);
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count);
private:
FuncBase::Ptr _getxattr;

10
src/fuse_getxattr_func_base.hpp

@ -18,7 +18,7 @@
#pragma once
#include "from_toml.hpp"
#include "fs_path.hpp"
#include <memory>
@ -32,9 +32,9 @@ namespace FUSE::GETXATTR
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const char *fusepath,
const char *attrname,
char *buf,
size_t count) = 0;
virtual int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) = 0;
};
}

12
src/fuse_getxattr_func_ff.cpp

@ -31,21 +31,19 @@ FUSE::GETXATTR::FuncFF::FuncFF(const toml::value &toml_)
}
int
FUSE::GETXATTR::FuncFF::operator()(const char *fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
FUSE::GETXATTR::FuncFF::operator()(const gfs::path &fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
{
int 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::lgetxattr(fullpath,attrname_,buf_,count_);
if(rv == -ENOENT)

8
src/fuse_getxattr_func_ff.hpp

@ -33,10 +33,10 @@ namespace FUSE::GETXATTR
FuncFF(const toml::value&);
public:
int operator()(const char *fusepath,
const char *attrname,
char *buf,
size_t count) final;
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) final;
private:
Branches2 _branches;

8
src/fuse_ioctl.cpp

@ -217,7 +217,7 @@ namespace l
void *data_)
{
Config::Read cfg;
std::string &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
gfs::path &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
return l::file_basepath(cfg->func.open.policy,
cfg->branches,
@ -230,7 +230,7 @@ namespace l
file_relpath(const fuse_file_info_t *ffi_,
void *data_)
{
std::string &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
gfs::path &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
return l::strcpy(fusepath,data_);
}
@ -261,7 +261,7 @@ namespace l
void *data_)
{
Config::Read cfg;
std::string &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
gfs::path &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
return l::file_fullpath(cfg->func.open.policy,
cfg->branches,
@ -278,7 +278,7 @@ namespace l
string concated;
StrVec paths;
StrVec branches;
string &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
gfs::path &fusepath = reinterpret_cast<FH*>(ffi_->fh)->fusepath;
cfg->branches->to_paths(branches);

12
src/fuse_link.cpp

@ -22,16 +22,12 @@
#include "fs_path.hpp"
#include "fuse_getattr.hpp"
#include "fuse_symlink.hpp"
#include "ghc/filesystem.hpp"
#include "state.hpp"
#include "ugid.hpp"
#include "fuse.h"
namespace gfs = ghc::filesystem;
namespace l
{
static
@ -151,13 +147,17 @@ namespace FUSE::LINK
{
int rv;
State s;
gfs::path oldpath;
gfs::path newpath;
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
rv = s->link(oldpath_,newpath_);
oldpath = &oldpath_[1];
newpath = &newpath_[1];
rv = s->link(oldpath,newpath);
if(rv == -EXDEV)
return l::link_exdev(s,oldpath_,newpath_,st_,timeouts_);
return s->getattr(newpath_,st_,timeouts_);
return s->getattr(newpath,st_,timeouts_);
}
}

4
src/fuse_link_func.hpp

@ -34,8 +34,8 @@ namespace FUSE::LINK
public:
int
operator()(const char *oldpath_,
const char *newpath_)
operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
return (*_link)(oldpath_,newpath_);
}

14
src/fuse_link_func_all.cpp

@ -34,24 +34,20 @@ FUSE::LINK::FuncALL::FuncALL(const toml::value &toml_)
}
int
FUSE::LINK::FuncALL::operator()(const char *oldpath_,
const char *newpath_)
FUSE::LINK::FuncALL::operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
int rv;
Err err;
gfs::path oldpath;
gfs::path newpath;
gfs::path fulloldpath;
gfs::path fullnewpath;
oldpath = &oldpath_[1];
newpath = &newpath_[1];
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fulloldpath = branch.path / oldpath;
fullnewpath = branch.path / newpath;;
fulloldpath = branch.path / oldpath_;
fullnewpath = branch.path / newpath_;
rv = fs::link(fulloldpath,fullnewpath);
if(rv == -ENOENT)
@ -59,7 +55,7 @@ FUSE::LINK::FuncALL::operator()(const char *oldpath_,
if(!fs::exists(fulloldpath))
continue;
rv = fs::clonepath_as_root(_branches,branch.path,newpath.parent_path());
rv = fs::clonepath_as_root(_branches,branch.path,newpath_.parent_path());
if(rv < 0)
continue;

6
src/fuse_link_func_all.hpp

@ -28,11 +28,11 @@ namespace FUSE::LINK
class FuncALL : public FuncBase
{
public:
FuncALL(const toml::value &);
FuncALL(const toml::value&);
public:
int operator()(const char *oldpath,
const char *newpath) final;
int operator()(const gfs::path &oldpath,
const gfs::path &newpath) final;
private:
Branches2 _branches;

6
src/fuse_link_func_base.hpp

@ -18,6 +18,8 @@
#pragma once
#include "fs_path.hpp"
#include "fuse.h"
#include <memory>
@ -31,8 +33,8 @@ namespace FUSE::LINK
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const char *oldpath,
const char *newpath) = 0;
virtual int operator()(const gfs::path &oldpath,
const gfs::path &newpath) = 0;
};
}
Loading…
Cancel
Save