move policy function type from fs to policy

This commit is contained in:
Antonio SJ Musumeci 2015-06-22 23:35:46 -04:00
parent 2bd44568a1
commit 3c8f12281f
23 changed files with 58 additions and 46 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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
@ -55,9 +59,9 @@ namespace mergerfs
};
private:
Enum::Type _enum;
std::string _str;
fs::find::Func _func;
Enum::Type _enum;
std::string _str;
FuncPtr _func;
public:
Policy()
@ -67,9 +71,9 @@ namespace mergerfs
{
}
Policy(const Enum::Type enum_,
const std::string &str_,
const fs::find::Func func_)
Policy(const Enum::Type enum_,
const std::string &str_,
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

View File

@ -41,12 +41,12 @@ using mergerfs::Policy;
static
int
_readlink(const fs::find::Func searchFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
char *buf,
const size_t size)
_readlink(const Policy::FuncPtr searchFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
char *buf,
const size_t size)
{
int rv;
Paths path;

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -38,13 +38,14 @@
using std::string;
using std::vector;
using mergerfs::Policy;
static
int
_utimens(const fs::find::Func actionFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
_utimens(const Policy::FuncPtr actionFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
const struct timespec ts[2])
{
int rv;