mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-21 08:13:40 +08:00
add category to policies so as to distinguish between creates and searches
This commit is contained in:
parent
a5bf48c8ae
commit
51b6d3f647
@ -42,14 +42,15 @@
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
using mergerfs::Category;
|
||||
|
||||
static
|
||||
int
|
||||
_access(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int mask)
|
||||
_access(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int mask)
|
||||
{
|
||||
int rv;
|
||||
Paths paths;
|
||||
@ -76,7 +77,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _access(*config.access,
|
||||
return _access(config.access,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -39,11 +39,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_chmod(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
_chmod(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -78,7 +78,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _chmod(*config.chmod,
|
||||
return _chmod(config.chmod,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -40,12 +40,12 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_chown(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
_chown(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -81,7 +81,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _chown(*config.chown,
|
||||
return _chown(config.chown,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -43,14 +43,14 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_create(const Policy::Func::Ptr searchFunc,
|
||||
const Policy::Func::Ptr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
_create(Policy::Func::Search searchFunc,
|
||||
Policy::Func::Create createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
@ -99,8 +99,8 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _create(*config.getattr,
|
||||
*config.create,
|
||||
return _create(config.getattr,
|
||||
config.create,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -66,11 +66,11 @@ _getattr_controlfile(struct stat &buf)
|
||||
|
||||
static
|
||||
int
|
||||
_getattr(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
struct stat &buf)
|
||||
_getattr(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
struct stat &buf)
|
||||
{
|
||||
int rv;
|
||||
Paths path;
|
||||
@ -101,7 +101,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _getattr(*config.getattr,
|
||||
return _getattr(config.getattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -190,13 +190,13 @@ _getxattr_user_mergerfs(const Path &path,
|
||||
|
||||
static
|
||||
int
|
||||
_getxattr(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
_getxattr(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
int rv;
|
||||
@ -239,7 +239,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _getxattr(*config.getxattr,
|
||||
return _getxattr(config.getxattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -82,14 +82,14 @@ _ioctl(const int fd,
|
||||
#ifdef FUSE_IOCTL_DIR
|
||||
static
|
||||
int
|
||||
_ioctl_dir_base(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int cmd,
|
||||
void *arg,
|
||||
const unsigned int flags,
|
||||
void *data)
|
||||
_ioctl_dir_base(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int cmd,
|
||||
void *arg,
|
||||
const unsigned int flags,
|
||||
void *data)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
@ -123,7 +123,7 @@ _ioctl_dir(const string &fusepath,
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _ioctl_dir_base(*config.getattr,
|
||||
return _ioctl_dir_base(config.getattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
28
src/link.cpp
28
src/link.cpp
@ -41,12 +41,12 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_single_link(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &base,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
_single_link(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &base,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
{
|
||||
int rv;
|
||||
const string fulloldpath = fs::make_path(base,oldpath);
|
||||
@ -76,12 +76,12 @@ _single_link(const Policy::Func::Ptr searchFunc,
|
||||
|
||||
static
|
||||
int
|
||||
_link(const Policy::Func::Ptr searchFunc,
|
||||
const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
_link(Policy::Func::Search searchFunc,
|
||||
Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -116,8 +116,8 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _link(*config.getattr,
|
||||
*config.link,
|
||||
return _link(config.getattr,
|
||||
config.link,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
from,
|
||||
|
@ -69,12 +69,12 @@ _listxattr_controlfile(char *list,
|
||||
|
||||
static
|
||||
int
|
||||
_listxattr(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
char *list,
|
||||
const size_t size)
|
||||
_listxattr(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
char *list,
|
||||
const size_t size)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
int rv;
|
||||
@ -110,7 +110,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _listxattr(*config.listxattr,
|
||||
return _listxattr(config.listxattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -42,12 +42,12 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_mkdir(const Policy::Func::Ptr searchFunc,
|
||||
const Policy::Func::Ptr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
_mkdir(Policy::Func::Search searchFunc,
|
||||
Policy::Func::Create createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -98,8 +98,8 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _mkdir(*config.getattr,
|
||||
*config.mkdir,
|
||||
return _mkdir(config.getattr,
|
||||
config.mkdir,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -44,13 +44,13 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_mknod(const Policy::Func::Ptr searchFunc,
|
||||
const Policy::Func::Ptr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const dev_t dev)
|
||||
_mknod(Policy::Func::Search searchFunc,
|
||||
Policy::Func::Create createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const dev_t dev)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -102,8 +102,8 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _mknod(*config.getattr,
|
||||
*config.mknod,
|
||||
return _mknod(config.getattr,
|
||||
config.mknod,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
14
src/open.cpp
14
src/open.cpp
@ -42,12 +42,12 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_open(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
_open(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
@ -79,7 +79,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _open(*config.open,
|
||||
return _open(config.open,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "path.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "category.hpp"
|
||||
|
||||
namespace mergerfs
|
||||
{
|
||||
@ -61,19 +62,74 @@ namespace mergerfs
|
||||
typedef std::string string;
|
||||
typedef std::size_t size_t;
|
||||
typedef std::vector<string> strvec;
|
||||
typedef const string cstring;
|
||||
typedef const size_t csize_t;
|
||||
typedef const strvec cstrvec;
|
||||
typedef const Category::Enum::Type CType;
|
||||
|
||||
typedef int (*Ptr)(const strvec&,const string&,const size_t,Paths&);
|
||||
typedef int (*Ptr)(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
|
||||
static int invalid(const strvec&,const string&,const size_t,Paths&);
|
||||
static int all(const strvec&,const string&,const size_t,Paths&);
|
||||
static int epmfs(const strvec&,const string&,const size_t,Paths&);
|
||||
static int ff(const strvec&,const string&,const size_t,Paths&);
|
||||
static int ffwp(const strvec&,const string&,const size_t,Paths&);
|
||||
static int fwfs(const strvec&,const string&,const size_t,Paths&);
|
||||
static int lfs(const strvec&,const string&,const size_t,Paths&);
|
||||
static int mfs(const strvec&,const string&,const size_t,Paths&);
|
||||
static int newest(const strvec&,const string&,const size_t,Paths&);
|
||||
static int rand(const strvec&,const string&,const size_t,Paths&);
|
||||
class Action
|
||||
{
|
||||
public:
|
||||
Action(const Policy *p)
|
||||
: func(p->_func)
|
||||
{}
|
||||
|
||||
int
|
||||
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
|
||||
{
|
||||
return func(Category::Enum::action,b,c,d,e);
|
||||
}
|
||||
|
||||
private:
|
||||
const Ptr func;
|
||||
};
|
||||
|
||||
class Create
|
||||
{
|
||||
public:
|
||||
Create(const Policy *p)
|
||||
: func(p->_func)
|
||||
{}
|
||||
|
||||
int
|
||||
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
|
||||
{
|
||||
return func(Category::Enum::create,b,c,d,e);
|
||||
}
|
||||
|
||||
private:
|
||||
const Ptr func;
|
||||
};
|
||||
|
||||
class Search
|
||||
{
|
||||
public:
|
||||
Search(const Policy *p)
|
||||
: func(p->_func)
|
||||
{}
|
||||
|
||||
int
|
||||
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
|
||||
{
|
||||
return func(Category::Enum::search,b,c,d,e);
|
||||
}
|
||||
|
||||
private:
|
||||
const Ptr func;
|
||||
};
|
||||
|
||||
static int invalid(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int all(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int epmfs(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int ff(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int ffwp(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int fwfs(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int lfs(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int mfs(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int newest(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
static int rand(CType,cstrvec&,cstring&,csize_t,Paths&);
|
||||
};
|
||||
|
||||
private:
|
||||
@ -124,16 +180,17 @@ namespace mergerfs
|
||||
public:
|
||||
static const std::vector<Policy> _policies_;
|
||||
static const Policy * const policies;
|
||||
static const Policy &invalid;
|
||||
static const Policy &all;
|
||||
static const Policy &epmfs;
|
||||
static const Policy &ff;
|
||||
static const Policy &ffwp;
|
||||
static const Policy &fwfs;
|
||||
static const Policy &lfs;
|
||||
static const Policy &mfs;
|
||||
static const Policy &newest;
|
||||
static const Policy &rand;
|
||||
|
||||
static const Policy &invalid;
|
||||
static const Policy &all;
|
||||
static const Policy &epmfs;
|
||||
static const Policy &ff;
|
||||
static const Policy &ffwp;
|
||||
static const Policy &fwfs;
|
||||
static const Policy &lfs;
|
||||
static const Policy &mfs;
|
||||
static const Policy &newest;
|
||||
static const Policy &rand;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::all(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::all(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
int rv;
|
||||
struct stat st;
|
||||
|
@ -40,10 +40,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::epmfs(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::epmfs(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
fsblkcnt_t existingmfs;
|
||||
fsblkcnt_t generalmfs;
|
||||
|
@ -40,10 +40,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::ff(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::ff(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
errno = ENOENT;
|
||||
for(vector<string>::const_iterator
|
||||
|
@ -39,10 +39,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::ffwp(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::ffwp(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
Path fallback;
|
||||
|
||||
|
@ -37,10 +37,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::fwfs(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::fwfs(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
for(size_t i = 0, size = basepaths.size(); i != size; i++)
|
||||
{
|
||||
@ -64,6 +65,6 @@ namespace mergerfs
|
||||
}
|
||||
}
|
||||
|
||||
return mfs(basepaths,fusepath,minfreespace,paths);
|
||||
return mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::invalid(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &rv)
|
||||
Policy::Func::invalid(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &rv)
|
||||
{
|
||||
return (errno = EINVAL,-1);
|
||||
}
|
||||
|
@ -40,10 +40,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::lfs(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::lfs(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
fsblkcnt_t lfs;
|
||||
const char *lfsstr;
|
||||
@ -73,7 +74,7 @@ namespace mergerfs
|
||||
}
|
||||
|
||||
if(lfsstr == NULL)
|
||||
return Policy::Func::mfs(basepaths,fusepath,minfreespace,paths);
|
||||
return mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
paths.push_back(Path(lfsstr,
|
||||
fs::make_path(lfsstr,fusepath)));
|
||||
|
@ -37,10 +37,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::mfs(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::mfs(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
fsblkcnt_t mfs;
|
||||
size_t mfsidx;
|
||||
|
@ -39,10 +39,11 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::newest(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::newest(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
time_t newest;
|
||||
string npath;
|
||||
|
@ -37,14 +37,15 @@ using std::size_t;
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
Policy::Func::rand(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
Policy::Func::rand(const Category::Enum::Type type,
|
||||
const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &paths)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = Policy::Func::all(basepaths,fusepath,minfreespace,paths);
|
||||
rv = Policy::Func::all(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
|
@ -41,12 +41,12 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_readlink(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
char *buf,
|
||||
const size_t size)
|
||||
_readlink(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
char *buf,
|
||||
const size_t size)
|
||||
{
|
||||
int rv;
|
||||
Paths path;
|
||||
@ -78,7 +78,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _readlink(*config.readlink,
|
||||
return _readlink(config.readlink,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -42,11 +42,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_removexattr(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname)
|
||||
_removexattr(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
int rv;
|
||||
@ -89,7 +89,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _removexattr(*config.removexattr,
|
||||
return _removexattr(config.removexattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -42,11 +42,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_single_rename(const Policy::Func::Ptr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const Path &oldpath,
|
||||
const string &newpath)
|
||||
_single_rename(Policy::Func::Search searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const Path &oldpath,
|
||||
const string &newpath)
|
||||
{
|
||||
int rv;
|
||||
const string fullnewpath = fs::make_path(oldpath.base,newpath);
|
||||
@ -75,12 +75,12 @@ _single_rename(const Policy::Func::Ptr searchFunc,
|
||||
|
||||
static
|
||||
int
|
||||
_rename(const Policy::Func::Ptr searchFunc,
|
||||
const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
_rename(Policy::Func::Search searchFunc,
|
||||
Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -115,8 +115,8 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _rename(*config.getattr,
|
||||
*config.rename,
|
||||
return _rename(config.getattr,
|
||||
config.rename,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
oldpath,
|
||||
|
@ -40,10 +40,10 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_rmdir(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
_rmdir(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -77,7 +77,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readguard(&config.srcmountslock);
|
||||
|
||||
return _rmdir(*config.rmdir,
|
||||
return _rmdir(config.rmdir,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath);
|
||||
|
@ -240,14 +240,14 @@ _setxattr_controlfile(config::Config &config,
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
const char *attrval,
|
||||
const size_t attrvalsize,
|
||||
const int flags)
|
||||
_setxattr(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
const char *attrval,
|
||||
const size_t attrvalsize,
|
||||
const int flags)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
int rv;
|
||||
@ -301,7 +301,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _setxattr(*config.setxattr,
|
||||
return _setxattr(config.setxattr,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -40,11 +40,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_symlink(const Policy::Func::Ptr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
_symlink(Policy::Func::Create createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
const string &newpath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -83,7 +83,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _symlink(*config.symlink,
|
||||
return _symlink(config.symlink,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
oldpath,
|
||||
|
@ -42,11 +42,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_truncate(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const off_t size)
|
||||
_truncate(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const off_t size)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -81,7 +81,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _truncate(*config.truncate,
|
||||
return _truncate(config.truncate,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
@ -41,10 +41,10 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_unlink(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
_unlink(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -78,7 +78,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _unlink(*config.unlink,
|
||||
return _unlink(config.unlink,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath);
|
||||
|
@ -42,11 +42,11 @@ using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_utimens(const Policy::Func::Ptr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const struct timespec ts[2])
|
||||
_utimens(Policy::Func::Action actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
const struct timespec ts[2])
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -81,7 +81,7 @@ namespace mergerfs
|
||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||
|
||||
return _utimens(*config.utimens,
|
||||
return _utimens(config.utimens,
|
||||
config.srcmounts,
|
||||
config.minfreespace,
|
||||
fusepath,
|
||||
|
Loading…
x
Reference in New Issue
Block a user