mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-25 17:36:25 -05:00
checkpoint
This commit is contained in:
parent
2ae212ae81
commit
cba7433166
35 changed files with 115 additions and 108 deletions
14
src/fh.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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue