mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-01-20 16:32:02 +08:00
move policy function type from fs to policy
This commit is contained in:
parent
2bd44568a1
commit
3c8f12281f
|
@ -45,7 +45,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_access(const fs::find::Func searchFunc,
|
||||
_access(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -39,7 +39,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_chmod(const fs::find::Func actionFunc,
|
||||
_chmod(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -40,7 +40,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_chown(const fs::find::Func actionFunc,
|
||||
_chown(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -43,8 +43,8 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_create(const fs::find::Func searchFunc,
|
||||
const fs::find::Func createFunc,
|
||||
_create(const Policy::FuncPtr searchFunc,
|
||||
const Policy::FuncPtr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -100,8 +100,6 @@ namespace fs
|
|||
|
||||
namespace find
|
||||
{
|
||||
typedef int (*Func)(const vector<string>&,const string&,const size_t,Paths&);
|
||||
|
||||
int invalid(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
|
@ -65,7 +66,7 @@ _getattr_controlfile(struct stat &buf)
|
|||
|
||||
static
|
||||
int
|
||||
_getattr(const fs::find::Func searchFunc,
|
||||
_getattr(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -190,7 +190,7 @@ _getxattr_user_mergerfs(const Path &path,
|
|||
|
||||
static
|
||||
int
|
||||
_getxattr(const fs::find::Func searchFunc,
|
||||
_getxattr(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -82,7 +82,7 @@ _ioctl(const int fd,
|
|||
#ifdef FUSE_IOCTL_DIR
|
||||
static
|
||||
int
|
||||
_ioctl_dir_base(const fs::find::Func searchFunc,
|
||||
_ioctl_dir_base(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -41,7 +41,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_single_link(const fs::find::Func searchFunc,
|
||||
_single_link(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &base,
|
||||
|
@ -76,8 +76,8 @@ _single_link(const fs::find::Func searchFunc,
|
|||
|
||||
static
|
||||
int
|
||||
_link(const fs::find::Func searchFunc,
|
||||
const fs::find::Func actionFunc,
|
||||
_link(const Policy::FuncPtr searchFunc,
|
||||
const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
|
|
|
@ -69,7 +69,7 @@ _listxattr_controlfile(char *list,
|
|||
|
||||
static
|
||||
int
|
||||
_listxattr(const fs::find::Func searchFunc,
|
||||
_listxattr(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -38,11 +38,12 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_mkdir(const fs::find::Func searchFunc,
|
||||
const fs::find::Func createFunc,
|
||||
_mkdir(const Policy::FuncPtr searchFunc,
|
||||
const Policy::FuncPtr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -40,11 +40,12 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_mknod(const fs::find::Func searchFunc,
|
||||
const fs::find::Func createFunc,
|
||||
_mknod(const Policy::FuncPtr searchFunc,
|
||||
const Policy::FuncPtr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_open(const fs::find::Func searchFunc,
|
||||
_open(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
#define __POLICY_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "path.hpp"
|
||||
#include "fs.hpp"
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -35,6 +37,8 @@ namespace mergerfs
|
|||
class Policy
|
||||
{
|
||||
public:
|
||||
typedef int (*FuncPtr)(const std::vector<std::string>&,const std::string&,const std::size_t,Paths&);
|
||||
|
||||
struct Enum
|
||||
{
|
||||
enum Type
|
||||
|
@ -57,7 +61,7 @@ namespace mergerfs
|
|||
private:
|
||||
Enum::Type _enum;
|
||||
std::string _str;
|
||||
fs::find::Func _func;
|
||||
FuncPtr _func;
|
||||
|
||||
public:
|
||||
Policy()
|
||||
|
@ -69,7 +73,7 @@ namespace mergerfs
|
|||
|
||||
Policy(const Enum::Type enum_,
|
||||
const std::string &str_,
|
||||
const fs::find::Func func_)
|
||||
const FuncPtr func_)
|
||||
: _enum(enum_),
|
||||
_str(str_),
|
||||
_func(func_)
|
||||
|
@ -79,14 +83,14 @@ namespace mergerfs
|
|||
public:
|
||||
operator const Enum::Type() const { return _enum; }
|
||||
operator const std::string&() const { return _str; }
|
||||
operator const fs::find::Func() const { return _func; }
|
||||
operator const FuncPtr() const { return _func; }
|
||||
operator const Policy*() const { return this; }
|
||||
|
||||
bool operator==(const Enum::Type enum_) const
|
||||
{ return _enum == enum_; }
|
||||
bool operator==(const std::string &str_) const
|
||||
{ return _str == str_; }
|
||||
bool operator==(const fs::find::Func func_) const
|
||||
bool operator==(const FuncPtr func_) const
|
||||
{ return _func == func_; }
|
||||
|
||||
bool operator!=(const Policy &r) const
|
||||
|
|
|
@ -41,7 +41,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_readlink(const fs::find::Func searchFunc,
|
||||
_readlink(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_removexattr(const fs::find::Func actionFunc,
|
||||
_removexattr(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_single_rename(const fs::find::Func searchFunc,
|
||||
_single_rename(const Policy::FuncPtr searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const Path &oldpath,
|
||||
|
@ -74,8 +75,8 @@ _single_rename(const fs::find::Func searchFunc,
|
|||
|
||||
static
|
||||
int
|
||||
_rename(const fs::find::Func searchFunc,
|
||||
const fs::find::Func actionFunc,
|
||||
_rename(const Policy::FuncPtr searchFunc,
|
||||
const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
|
|
|
@ -40,7 +40,7 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_rmdir(const fs::find::Func actionFunc,
|
||||
_rmdir(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
|
|
|
@ -240,7 +240,7 @@ _setxattr_controlfile(config::Config &config,
|
|||
|
||||
static
|
||||
int
|
||||
_setxattr(const fs::find::Func actionFunc,
|
||||
_setxattr(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -36,10 +36,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_symlink(const fs::find::Func createFunc,
|
||||
_symlink(const Policy::FuncPtr createFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &oldpath,
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_truncate(const fs::find::Func actionFunc,
|
||||
_truncate(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_unlink(const fs::find::Func actionFunc,
|
||||
_unlink(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath)
|
||||
|
|
|
@ -38,10 +38,11 @@
|
|||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_utimens(const fs::find::Func actionFunc,
|
||||
_utimens(const Policy::FuncPtr actionFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const size_t minfreespace,
|
||||
const string &fusepath,
|
||||
|
|
Loading…
Reference in New Issue
Block a user