mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-01-22 12:05:15 +08:00
Merge pull request #34 from trapexit/byref
pass const strings by reference. closes #33
This commit is contained in:
commit
66563aa142
|
@ -47,7 +47,7 @@ static
|
|||
int
|
||||
_access(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const int mask)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -38,16 +38,16 @@ namespace mergerfs
|
|||
(CATEGORY(action))
|
||||
(CATEGORY(create))
|
||||
(CATEGORY(search));
|
||||
|
||||
|
||||
const Category * const Category::categories = &_categories_[1];
|
||||
|
||||
const Category &Category::invalid = Category::categories[Category::Enum::invalid];
|
||||
const Category &Category::action = Category::categories[Category::Enum::action];
|
||||
const Category &Category::create = Category::categories[Category::Enum::create];
|
||||
const Category &Category::search = Category::categories[Category::Enum::search];
|
||||
|
||||
const Category &Category::search = Category::categories[Category::Enum::search];
|
||||
|
||||
const Category&
|
||||
Category::find(const std::string str)
|
||||
Category::find(const std::string &str)
|
||||
{
|
||||
for(int i = Enum::BEGIN; i != Enum::END; ++i)
|
||||
{
|
||||
|
@ -66,5 +66,5 @@ namespace mergerfs
|
|||
return categories[i];
|
||||
|
||||
return invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace mergerfs
|
|||
{
|
||||
}
|
||||
|
||||
Category(const Enum::Type enum_,
|
||||
const std::string str_)
|
||||
Category(const Enum::Type enum_,
|
||||
const std::string &str_)
|
||||
: _enum(enum_),
|
||||
_str(str_)
|
||||
{
|
||||
|
@ -66,15 +66,15 @@ namespace mergerfs
|
|||
|
||||
public:
|
||||
operator const Enum::Type() const { return _enum; }
|
||||
operator const std::string() const { return _str; }
|
||||
operator const std::string&() const { return _str; }
|
||||
operator const Category*() const { return this; }
|
||||
|
||||
bool operator==(const std::string str_) const
|
||||
bool operator==(const std::string &str_) const
|
||||
{ return _str == str_; }
|
||||
|
||||
bool operator==(const Enum::Type enum_) const
|
||||
{ return _enum == enum_; }
|
||||
|
||||
{ return _enum == enum_; }
|
||||
|
||||
bool operator!=(const Category &r) const
|
||||
{ return _enum != r._enum; }
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace mergerfs
|
|||
{ return _enum < r._enum; }
|
||||
|
||||
public:
|
||||
static const Category &find(const std::string);
|
||||
static const Category &find(const std::string&);
|
||||
static const Category &find(const Enum::Type);
|
||||
|
||||
public:
|
||||
|
|
|
@ -41,7 +41,7 @@ static
|
|||
int
|
||||
_chmod(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -42,7 +42,7 @@ static
|
|||
int
|
||||
_chown(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ int
|
|||
_create(const fs::SearchFunc searchFunc,
|
||||
const fs::SearchFunc createPathFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
|
|
92
src/fs.cpp
92
src/fs.cpp
|
@ -65,7 +65,7 @@ random_element(Iter begin,
|
|||
namespace fs
|
||||
{
|
||||
string
|
||||
dirname(const string path)
|
||||
dirname(const string &path)
|
||||
{
|
||||
string parent = path;
|
||||
string::reverse_iterator i;
|
||||
|
@ -88,13 +88,13 @@ namespace fs
|
|||
}
|
||||
|
||||
string
|
||||
basename(const string path)
|
||||
basename(const string &path)
|
||||
{
|
||||
return path.substr(path.find_last_of('/')+1);
|
||||
}
|
||||
|
||||
bool
|
||||
dir_is_empty(const string path)
|
||||
dir_is_empty(const string &path)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
|
@ -123,8 +123,8 @@ namespace fs
|
|||
}
|
||||
|
||||
string
|
||||
make_path(const string base,
|
||||
const string suffix)
|
||||
make_path(const string &base,
|
||||
const string &suffix)
|
||||
{
|
||||
if(suffix[0] == '/' ||
|
||||
*base.rbegin() == '/')
|
||||
|
@ -133,9 +133,9 @@ namespace fs
|
|||
}
|
||||
|
||||
bool
|
||||
path_exists(vector<string>::const_iterator begin,
|
||||
vector<string>::const_iterator end,
|
||||
const string fusepath)
|
||||
path_exists(vector<string>::const_iterator begin,
|
||||
vector<string>::const_iterator end,
|
||||
const string &fusepath)
|
||||
{
|
||||
for(vector<string>::const_iterator
|
||||
iter = begin; iter != end; ++iter)
|
||||
|
@ -155,7 +155,7 @@ namespace fs
|
|||
|
||||
bool
|
||||
path_exists(const vector<string> &srcmounts,
|
||||
const string fusepath)
|
||||
const string &fusepath)
|
||||
{
|
||||
return path_exists(srcmounts.begin(),
|
||||
srcmounts.end(),
|
||||
|
@ -163,7 +163,7 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
listxattr(const string path,
|
||||
listxattr(const string &path,
|
||||
vector<char> &attrs)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
|
@ -187,7 +187,7 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
listxattr(const string path,
|
||||
listxattr(const string &path,
|
||||
vector<string> &attrvector)
|
||||
{
|
||||
int rv;
|
||||
|
@ -204,8 +204,8 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
listxattr(const string path,
|
||||
string &attrstr)
|
||||
listxattr(const string &path,
|
||||
string &attrstr)
|
||||
{
|
||||
int rv;
|
||||
vector<char> attrs;
|
||||
|
@ -218,8 +218,8 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
getxattr(const string path,
|
||||
const string attr,
|
||||
getxattr(const string &path,
|
||||
const string &attr,
|
||||
vector<char> &value)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
|
@ -243,8 +243,8 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
getxattr(const string path,
|
||||
const string attr,
|
||||
getxattr(const string &path,
|
||||
const string &attr,
|
||||
string &value)
|
||||
{
|
||||
int rv;
|
||||
|
@ -259,7 +259,7 @@ namespace fs
|
|||
|
||||
|
||||
int
|
||||
getxattrs(const string path,
|
||||
getxattrs(const string &path,
|
||||
map<string,string> &attrs)
|
||||
{
|
||||
int rv;
|
||||
|
@ -287,10 +287,10 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
setxattr(const string path,
|
||||
const string key,
|
||||
const string value,
|
||||
const int flags)
|
||||
setxattr(const string &path,
|
||||
const string &key,
|
||||
const string &value,
|
||||
const int flags)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
return ::setxattr(path.c_str(),
|
||||
|
@ -305,10 +305,10 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
setxattr(const int fd,
|
||||
const string key,
|
||||
const string value,
|
||||
const int flags)
|
||||
setxattr(const int fd,
|
||||
const string &key,
|
||||
const string &value,
|
||||
const int flags)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
return ::fsetxattr(fd,
|
||||
|
@ -323,7 +323,7 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
setxattrs(const string path,
|
||||
setxattrs(const string &path,
|
||||
const map<string,string> &attrs)
|
||||
{
|
||||
int fd;
|
||||
|
@ -342,8 +342,8 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
copyxattrs(const string from,
|
||||
const string to)
|
||||
copyxattrs(const string &from,
|
||||
const string &to)
|
||||
{
|
||||
int rv;
|
||||
map<string,string> attrs;
|
||||
|
@ -356,8 +356,8 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
copyattr(const string from,
|
||||
const string to)
|
||||
copyattr(const string &from,
|
||||
const string &to)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
|
@ -395,9 +395,9 @@ namespace fs
|
|||
}
|
||||
|
||||
int
|
||||
clonepath(const string fromsrc,
|
||||
const string tosrc,
|
||||
const string relative)
|
||||
clonepath(const string &fromsrc,
|
||||
const string &tosrc,
|
||||
const string &relative)
|
||||
{
|
||||
int rv;
|
||||
struct stat st;
|
||||
|
@ -492,7 +492,7 @@ namespace fs
|
|||
{
|
||||
int
|
||||
invalid(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
return (errno = EINVAL,-1);
|
||||
|
@ -500,7 +500,7 @@ namespace fs
|
|||
|
||||
int
|
||||
ff(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
errno = ENOENT;
|
||||
|
@ -524,7 +524,7 @@ namespace fs
|
|||
|
||||
int
|
||||
ffwp(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
Path fallback;
|
||||
|
@ -560,7 +560,7 @@ namespace fs
|
|||
|
||||
int
|
||||
newest(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
time_t newest;
|
||||
|
@ -595,7 +595,7 @@ namespace fs
|
|||
|
||||
int
|
||||
all(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
errno = ENOENT;
|
||||
|
@ -619,7 +619,7 @@ namespace fs
|
|||
|
||||
int
|
||||
mfs(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
fsblkcnt_t mfs;
|
||||
|
@ -634,8 +634,8 @@ namespace fs
|
|||
++iter)
|
||||
{
|
||||
int rv;
|
||||
struct statvfs fsstats;
|
||||
const string mountpoint = *iter;
|
||||
struct statvfs fsstats;
|
||||
const string &mountpoint = *iter;
|
||||
|
||||
rv = ::statvfs(mountpoint.c_str(),&fsstats);
|
||||
if(rv == 0)
|
||||
|
@ -663,7 +663,7 @@ namespace fs
|
|||
|
||||
int
|
||||
epmfs(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
fsblkcnt_t existingmfs = 0;
|
||||
|
@ -680,8 +680,8 @@ namespace fs
|
|||
do
|
||||
{
|
||||
int rv;
|
||||
struct statvfs fsstats;
|
||||
const string mountpoint = *iter;
|
||||
struct statvfs fsstats;
|
||||
const string &mountpoint = *iter;
|
||||
|
||||
rv = ::statvfs(mountpoint.c_str(),&fsstats);
|
||||
if(rv == 0)
|
||||
|
@ -722,7 +722,7 @@ namespace fs
|
|||
|
||||
int
|
||||
rand(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths)
|
||||
{
|
||||
string randombasepath;
|
||||
|
|
84
src/fs.hpp
84
src/fs.hpp
|
@ -38,8 +38,8 @@ namespace fs
|
|||
struct Path
|
||||
{
|
||||
Path() {}
|
||||
Path(const string b,
|
||||
const string f)
|
||||
Path(const string &b,
|
||||
const string &f)
|
||||
: base(b),
|
||||
full(f)
|
||||
{}
|
||||
|
@ -49,60 +49,60 @@ namespace fs
|
|||
};
|
||||
|
||||
typedef vector<Path> PathVector;
|
||||
typedef int (*SearchFunc)(const vector<string>&,const string,PathVector&);
|
||||
typedef int (*SearchFunc)(const vector<string>&,const string&,PathVector&);
|
||||
|
||||
string dirname(const string path);
|
||||
string basename(const string path);
|
||||
string dirname(const string &path);
|
||||
string basename(const string &path);
|
||||
|
||||
bool dir_is_empty(const string path);
|
||||
bool dir_is_empty(const string &path);
|
||||
|
||||
string make_path(const string base,
|
||||
const string suffix);
|
||||
string make_path(const string &base,
|
||||
const string &suffix);
|
||||
|
||||
bool path_exists(vector<string>::const_iterator begin,
|
||||
vector<string>::const_iterator end,
|
||||
const string fusepath);
|
||||
const string &fusepath);
|
||||
bool path_exists(const vector<string> &srcmounts,
|
||||
const string fusepath);
|
||||
const string &fusepath);
|
||||
|
||||
int clonepath(const string srcfrom,
|
||||
const string srcto,
|
||||
const string relative);
|
||||
int clonepath(const string &srcfrom,
|
||||
const string &srcto,
|
||||
const string &relative);
|
||||
|
||||
int listxattr(const string path,
|
||||
int listxattr(const string &path,
|
||||
vector<char> &attrs);
|
||||
int listxattr(const string path,
|
||||
int listxattr(const string &path,
|
||||
string &attrs);
|
||||
int listxattr(const string path,
|
||||
int listxattr(const string &path,
|
||||
vector<string> &attrs);
|
||||
|
||||
int getxattr(const string path,
|
||||
const string attr,
|
||||
int getxattr(const string &path,
|
||||
const string &attr,
|
||||
vector<char> &value);
|
||||
int getxattr(const string path,
|
||||
const string attr,
|
||||
int getxattr(const string &path,
|
||||
const string &attr,
|
||||
string &value);
|
||||
|
||||
int getxattrs(const string path,
|
||||
int getxattrs(const string &path,
|
||||
map<string,string> &attrs);
|
||||
|
||||
int setxattr(const string path,
|
||||
const string key,
|
||||
const string value,
|
||||
const int flags);
|
||||
int setxattr(const int fd,
|
||||
const string key,
|
||||
const string value,
|
||||
const int flags);
|
||||
int setxattr(const string &path,
|
||||
const string &key,
|
||||
const string &value,
|
||||
const int flags);
|
||||
int setxattr(const int fd,
|
||||
const string &key,
|
||||
const string &value,
|
||||
const int flags);
|
||||
|
||||
int setxattrs(const string path,
|
||||
int setxattrs(const string &path,
|
||||
const map<string,string> &attrs);
|
||||
|
||||
int copyxattrs(const string from,
|
||||
const string to);
|
||||
int copyxattrs(const string &from,
|
||||
const string &to);
|
||||
|
||||
int copyattr(const string from,
|
||||
const string to);
|
||||
int copyattr(const string &from,
|
||||
const string &to);
|
||||
|
||||
void glob(const vector<string> &patterns,
|
||||
vector<string> &strs);
|
||||
|
@ -113,28 +113,28 @@ namespace fs
|
|||
namespace find
|
||||
{
|
||||
int invalid(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths);
|
||||
int ff(const vector<string> &basepaths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &paths);
|
||||
int ffwp(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
int newest(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
int all(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
int mfs(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
int epmfs(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
int rand(const vector<string> &paths,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
PathVector &rv);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ static
|
|||
int
|
||||
_getattr(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
struct stat &buf)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -45,7 +45,7 @@ using namespace mergerfs::config;
|
|||
static
|
||||
int
|
||||
_getxattr_controlfile(const Config &config,
|
||||
const string attrname,
|
||||
const string &attrname,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ static
|
|||
int
|
||||
_getxattr(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
|
|
|
@ -85,7 +85,7 @@ static
|
|||
int
|
||||
_ioctl_dir_base(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const int cmd,
|
||||
void *arg,
|
||||
const unsigned int flags,
|
||||
|
@ -112,7 +112,7 @@ _ioctl_dir_base(const fs::SearchFunc searchFunc,
|
|||
|
||||
static
|
||||
int
|
||||
_ioctl_dir(const string fusepath,
|
||||
_ioctl_dir(const string &fusepath,
|
||||
const int cmd,
|
||||
void *arg,
|
||||
const unsigned int flags,
|
||||
|
|
|
@ -43,8 +43,8 @@ static
|
|||
int
|
||||
_link(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string from,
|
||||
const string to)
|
||||
const string &from,
|
||||
const string &to)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
|
|
|
@ -69,7 +69,7 @@ static
|
|||
int
|
||||
_listxattr(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
char *list,
|
||||
const size_t size)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "option_parser.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "test.hpp"
|
||||
|
||||
#include "access.hpp"
|
||||
#include "chmod.hpp"
|
||||
|
|
|
@ -45,7 +45,7 @@ int
|
|||
_mkdir(const fs::SearchFunc searchFunc,
|
||||
const fs::SearchFunc createPathFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const mode_t mode)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -46,7 +46,7 @@ int
|
|||
_mknod(const fs::SearchFunc searchFunc,
|
||||
const fs::SearchFunc createPathFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const mode_t mode,
|
||||
const dev_t dev)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ static
|
|||
int
|
||||
_open(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const int flags,
|
||||
uint64_t &fh)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace mergerfs
|
|||
{
|
||||
namespace opendir
|
||||
{
|
||||
int opendir(const char *fusepath, struct fuse_file_info *ffi);
|
||||
int
|
||||
opendir(const char *fusepath,
|
||||
struct fuse_file_info *ffi);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ using namespace mergerfs;
|
|||
static
|
||||
int
|
||||
process_opt(config::Config &config,
|
||||
const std::string arg)
|
||||
const std::string &arg)
|
||||
{
|
||||
int rv = 0;
|
||||
std::vector<std::string> argvalue;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace mergerfs
|
|||
const Policy &Policy::rand = Policy::policies[Policy::Enum::rand];
|
||||
|
||||
const Policy&
|
||||
Policy::find(const std::string str)
|
||||
Policy::find(const std::string &str)
|
||||
{
|
||||
for(int i = Enum::BEGIN; i != Enum::END; ++i)
|
||||
{
|
||||
|
|
|
@ -65,9 +65,9 @@ namespace mergerfs
|
|||
{
|
||||
}
|
||||
|
||||
Policy(const Enum::Type enum_,
|
||||
const std::string str_,
|
||||
const fs::SearchFunc func_)
|
||||
Policy(const Enum::Type enum_,
|
||||
const std::string &str_,
|
||||
const fs::SearchFunc func_)
|
||||
: _enum(enum_),
|
||||
_str(str_),
|
||||
_func(func_)
|
||||
|
@ -76,17 +76,17 @@ namespace mergerfs
|
|||
|
||||
public:
|
||||
operator const Enum::Type() const { return _enum; }
|
||||
operator const std::string() const { return _str; }
|
||||
operator const std::string&() const { return _str; }
|
||||
operator const fs::SearchFunc() 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
|
||||
bool operator==(const std::string &str_) const
|
||||
{ return _str == str_; }
|
||||
bool operator==(const fs::SearchFunc func_) const
|
||||
{ return _func == func_; }
|
||||
|
||||
|
||||
bool operator!=(const Policy &r) const
|
||||
{ return _enum != r._enum; }
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace mergerfs
|
|||
{ return _enum < r._enum; }
|
||||
|
||||
public:
|
||||
static const Policy &find(const std::string);
|
||||
static const Policy &find(const std::string&);
|
||||
static const Policy &find(const Enum::Type);
|
||||
|
||||
public:
|
||||
|
|
|
@ -48,7 +48,7 @@ using mergerfs::readdir::FileData;
|
|||
static
|
||||
int
|
||||
_readdir(const vector<string> &srcmounts,
|
||||
const string dirname,
|
||||
const string &dirname,
|
||||
void *buf,
|
||||
const fuse_fill_dir_t filler)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ namespace mergerfs
|
|||
{
|
||||
int
|
||||
readdir(const vector<string> &srcmounts,
|
||||
const string dirname,
|
||||
const string &dirname,
|
||||
vector<FileData> &stats)
|
||||
{
|
||||
return _readdir(srcmounts,
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace mergerfs
|
|||
{
|
||||
struct FileData
|
||||
{
|
||||
FileData(std::string filename_,
|
||||
struct stat stats_)
|
||||
FileData(const std::string &filename_,
|
||||
const struct stat &stats_)
|
||||
: filename(filename_),
|
||||
stats(stats_)
|
||||
{}
|
||||
|
@ -59,7 +59,7 @@ namespace mergerfs
|
|||
|
||||
int
|
||||
readdir(const std::vector<std::string> &srcmounts,
|
||||
const std::string dirname,
|
||||
const std::string &dirname,
|
||||
std::vector<FileData> &stats);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ using mergerfs::Policy;
|
|||
static
|
||||
int
|
||||
_readlink(const fs::SearchFunc searchFunc,
|
||||
const vector<string>& srcmounts,
|
||||
const string fusepath,
|
||||
const vector<string> &srcmounts,
|
||||
const string &fusepath,
|
||||
char *buf,
|
||||
const size_t size)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace mergerfs
|
|||
{
|
||||
namespace releasedir
|
||||
{
|
||||
int releasedir(const char *fusepath, struct fuse_file_info *ffi);
|
||||
int
|
||||
releasedir(const char *fusepath,
|
||||
struct fuse_file_info *ffi);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ static
|
|||
int
|
||||
_removexattr(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const char *attrname)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
|
|
|
@ -43,8 +43,8 @@ static
|
|||
int
|
||||
_rename(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string from,
|
||||
const string to)
|
||||
const string &from,
|
||||
const string &to)
|
||||
{
|
||||
int rv;
|
||||
string pathto;
|
||||
|
|
|
@ -42,7 +42,7 @@ static
|
|||
int
|
||||
_rmdir(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath)
|
||||
const string &fusepath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
|
|
|
@ -42,10 +42,11 @@ namespace mergerfs
|
|||
pthread_rwlock_unlock(_lock);
|
||||
}
|
||||
|
||||
pthread_rwlock_t *_lock;
|
||||
|
||||
private:
|
||||
ReadGuard();
|
||||
|
||||
private:
|
||||
pthread_rwlock_t *_lock;
|
||||
};
|
||||
|
||||
class WriteGuard
|
||||
|
@ -62,10 +63,11 @@ namespace mergerfs
|
|||
pthread_rwlock_unlock(_lock);
|
||||
}
|
||||
|
||||
pthread_rwlock_t *_lock;
|
||||
|
||||
private:
|
||||
WriteGuard();
|
||||
|
||||
private:
|
||||
pthread_rwlock_t *_lock;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ static
|
|||
int
|
||||
_add_srcmounts(vector<string> &srcmounts,
|
||||
pthread_rwlock_t &srcmountslock,
|
||||
const string destmount,
|
||||
const string values,
|
||||
const string &destmount,
|
||||
const string &values,
|
||||
vector<string>::iterator pos)
|
||||
{
|
||||
vector<string> patterns;
|
||||
|
@ -73,7 +73,7 @@ _add_srcmounts(vector<string> &srcmounts,
|
|||
static
|
||||
int
|
||||
_erase_srcmounts(vector<string> &srcmounts,
|
||||
pthread_rwlock_t srcmountslock,
|
||||
pthread_rwlock_t &srcmountslock,
|
||||
const string &values)
|
||||
{
|
||||
if(srcmounts.empty())
|
||||
|
@ -83,9 +83,11 @@ _erase_srcmounts(vector<string> &srcmounts,
|
|||
|
||||
str::split(patterns,values,':');
|
||||
|
||||
const rwlock::WriteGuard wrg(&srcmountslock);
|
||||
{
|
||||
const rwlock::WriteGuard wrg(&srcmountslock);
|
||||
|
||||
fs::erase_fnmatches(patterns,srcmounts);
|
||||
fs::erase_fnmatches(patterns,srcmounts);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -93,9 +95,9 @@ _erase_srcmounts(vector<string> &srcmounts,
|
|||
static
|
||||
int
|
||||
_replace_srcmounts(vector<string> &srcmounts,
|
||||
pthread_rwlock_t srcmountslock,
|
||||
const string destmount,
|
||||
const string values)
|
||||
pthread_rwlock_t &srcmountslock,
|
||||
const string &destmount,
|
||||
const string &values)
|
||||
{
|
||||
vector<string> patterns;
|
||||
vector<string> newmounts;
|
||||
|
@ -114,7 +116,7 @@ _replace_srcmounts(vector<string> &srcmounts,
|
|||
|
||||
static
|
||||
void
|
||||
_split_attrval(const string attrval,
|
||||
_split_attrval(const string &attrval,
|
||||
string &instruction,
|
||||
string &values)
|
||||
{
|
||||
|
@ -130,8 +132,8 @@ static
|
|||
int
|
||||
_setxattr_srcmounts(vector<string> &srcmounts,
|
||||
pthread_rwlock_t &srcmountslock,
|
||||
const string destmount,
|
||||
const string attrval,
|
||||
const string &destmount,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
{
|
||||
string instruction;
|
||||
|
@ -165,8 +167,8 @@ _setxattr_srcmounts(vector<string> &srcmounts,
|
|||
static
|
||||
int
|
||||
_setxattr_policy(const Policy *policies[],
|
||||
const string attrname,
|
||||
const string attrval,
|
||||
const string &attrname,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
{
|
||||
const Category *cat;
|
||||
|
@ -191,8 +193,8 @@ _setxattr_policy(const Policy *policies[],
|
|||
static
|
||||
int
|
||||
_setxattr_controlfile(config::Config &config,
|
||||
const string attrname,
|
||||
const string attrval,
|
||||
const string &attrname,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
{
|
||||
vector<string> nameparts;
|
||||
|
@ -224,7 +226,7 @@ static
|
|||
int
|
||||
_setxattr(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
const char *attrval,
|
||||
const size_t attrvalsize,
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace str
|
|||
{
|
||||
void
|
||||
split(vector<string> &result,
|
||||
const string str,
|
||||
const string &str,
|
||||
const char delimiter)
|
||||
{
|
||||
string part;
|
||||
|
|
12
src/str.hpp
12
src/str.hpp
|
@ -27,10 +27,12 @@
|
|||
|
||||
namespace str
|
||||
{
|
||||
void split(std::vector<std::string> &result,
|
||||
const std::string str,
|
||||
const char delimiter);
|
||||
void
|
||||
split(std::vector<std::string> &result,
|
||||
const std::string &str,
|
||||
const char delimiter);
|
||||
|
||||
std::string join(const std::vector<std::string> &vec,
|
||||
const char sep);
|
||||
std::string
|
||||
join(const std::vector<std::string> &vec,
|
||||
const char sep);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ using std::vector;
|
|||
static
|
||||
int
|
||||
_symlink(const vector<string> &srcmounts,
|
||||
const string from,
|
||||
const string to)
|
||||
const string &from,
|
||||
const string &to)
|
||||
{
|
||||
int rv;
|
||||
fs::PathVector paths;
|
||||
|
|
55
src/test.cpp
55
src/test.cpp
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "readdir.hpp"
|
||||
#include "fs.hpp"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
test(const struct fuse_args &args,
|
||||
const mergerfs::config::Config &config)
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
30
src/test.hpp
30
src/test.hpp
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace mergerfs
|
||||
{
|
||||
int
|
||||
test(const struct fuse_args &args,
|
||||
const mergerfs::config::Config &config);
|
||||
}
|
|
@ -43,7 +43,7 @@ static
|
|||
int
|
||||
_truncate(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const string &fusepath,
|
||||
const off_t size)
|
||||
{
|
||||
int rv;
|
||||
|
|
|
@ -42,7 +42,7 @@ static
|
|||
int
|
||||
_unlink(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath)
|
||||
const string &fusepath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
|
|
|
@ -41,10 +41,10 @@ using std::vector;
|
|||
|
||||
static
|
||||
int
|
||||
_utimens(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const struct timespec ts[2])
|
||||
_utimens(const fs::SearchFunc searchFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string &fusepath,
|
||||
const struct timespec ts[2])
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
|
|
Loading…
Reference in New Issue
Block a user