Merge pull request #34 from trapexit/byref

pass const strings by reference. closes #33
This commit is contained in:
Antonio SJ Musumeci 2014-11-10 21:10:31 -05:00
commit 66563aa142
38 changed files with 181 additions and 257 deletions

View File

@ -47,7 +47,7 @@ static
int int
_access(const fs::SearchFunc searchFunc, _access(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const int mask) const int mask)
{ {
int rv; int rv;

View File

@ -38,16 +38,16 @@ namespace mergerfs
(CATEGORY(action)) (CATEGORY(action))
(CATEGORY(create)) (CATEGORY(create))
(CATEGORY(search)); (CATEGORY(search));
const Category * const Category::categories = &_categories_[1]; const Category * const Category::categories = &_categories_[1];
const Category &Category::invalid = Category::categories[Category::Enum::invalid]; const Category &Category::invalid = Category::categories[Category::Enum::invalid];
const Category &Category::action = Category::categories[Category::Enum::action]; const Category &Category::action = Category::categories[Category::Enum::action];
const Category &Category::create = Category::categories[Category::Enum::create]; 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& const Category&
Category::find(const std::string str) Category::find(const std::string &str)
{ {
for(int i = Enum::BEGIN; i != Enum::END; ++i) for(int i = Enum::BEGIN; i != Enum::END; ++i)
{ {
@ -66,5 +66,5 @@ namespace mergerfs
return categories[i]; return categories[i];
return invalid; return invalid;
} }
} }

View File

@ -57,8 +57,8 @@ namespace mergerfs
{ {
} }
Category(const Enum::Type enum_, Category(const Enum::Type enum_,
const std::string str_) const std::string &str_)
: _enum(enum_), : _enum(enum_),
_str(str_) _str(str_)
{ {
@ -66,15 +66,15 @@ namespace mergerfs
public: public:
operator const Enum::Type() const { return _enum; } 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; } operator const Category*() const { return this; }
bool operator==(const std::string str_) const bool operator==(const std::string &str_) const
{ return _str == str_; } { return _str == str_; }
bool operator==(const Enum::Type enum_) const bool operator==(const Enum::Type enum_) const
{ return _enum == enum_; } { return _enum == enum_; }
bool operator!=(const Category &r) const bool operator!=(const Category &r) const
{ return _enum != r._enum; } { return _enum != r._enum; }
@ -82,7 +82,7 @@ namespace mergerfs
{ return _enum < r._enum; } { return _enum < r._enum; }
public: public:
static const Category &find(const std::string); static const Category &find(const std::string&);
static const Category &find(const Enum::Type); static const Category &find(const Enum::Type);
public: public:

View File

@ -41,7 +41,7 @@ static
int int
_chmod(const fs::SearchFunc searchFunc, _chmod(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const mode_t mode) const mode_t mode)
{ {
int rv; int rv;

View File

@ -42,7 +42,7 @@ static
int int
_chown(const fs::SearchFunc searchFunc, _chown(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const uid_t uid, const uid_t uid,
const gid_t gid) const gid_t gid)
{ {

View File

@ -48,7 +48,7 @@ int
_create(const fs::SearchFunc searchFunc, _create(const fs::SearchFunc searchFunc,
const fs::SearchFunc createPathFunc, const fs::SearchFunc createPathFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const mode_t mode, const mode_t mode,
const int flags, const int flags,
uint64_t &fh) uint64_t &fh)

View File

@ -65,7 +65,7 @@ random_element(Iter begin,
namespace fs namespace fs
{ {
string string
dirname(const string path) dirname(const string &path)
{ {
string parent = path; string parent = path;
string::reverse_iterator i; string::reverse_iterator i;
@ -88,13 +88,13 @@ namespace fs
} }
string string
basename(const string path) basename(const string &path)
{ {
return path.substr(path.find_last_of('/')+1); return path.substr(path.find_last_of('/')+1);
} }
bool bool
dir_is_empty(const string path) dir_is_empty(const string &path)
{ {
DIR *dir; DIR *dir;
struct dirent *de; struct dirent *de;
@ -123,8 +123,8 @@ namespace fs
} }
string string
make_path(const string base, make_path(const string &base,
const string suffix) const string &suffix)
{ {
if(suffix[0] == '/' || if(suffix[0] == '/' ||
*base.rbegin() == '/') *base.rbegin() == '/')
@ -133,9 +133,9 @@ namespace fs
} }
bool bool
path_exists(vector<string>::const_iterator begin, path_exists(vector<string>::const_iterator begin,
vector<string>::const_iterator end, vector<string>::const_iterator end,
const string fusepath) const string &fusepath)
{ {
for(vector<string>::const_iterator for(vector<string>::const_iterator
iter = begin; iter != end; ++iter) iter = begin; iter != end; ++iter)
@ -155,7 +155,7 @@ namespace fs
bool bool
path_exists(const vector<string> &srcmounts, path_exists(const vector<string> &srcmounts,
const string fusepath) const string &fusepath)
{ {
return path_exists(srcmounts.begin(), return path_exists(srcmounts.begin(),
srcmounts.end(), srcmounts.end(),
@ -163,7 +163,7 @@ namespace fs
} }
int int
listxattr(const string path, listxattr(const string &path,
vector<char> &attrs) vector<char> &attrs)
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
@ -187,7 +187,7 @@ namespace fs
} }
int int
listxattr(const string path, listxattr(const string &path,
vector<string> &attrvector) vector<string> &attrvector)
{ {
int rv; int rv;
@ -204,8 +204,8 @@ namespace fs
} }
int int
listxattr(const string path, listxattr(const string &path,
string &attrstr) string &attrstr)
{ {
int rv; int rv;
vector<char> attrs; vector<char> attrs;
@ -218,8 +218,8 @@ namespace fs
} }
int int
getxattr(const string path, getxattr(const string &path,
const string attr, const string &attr,
vector<char> &value) vector<char> &value)
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
@ -243,8 +243,8 @@ namespace fs
} }
int int
getxattr(const string path, getxattr(const string &path,
const string attr, const string &attr,
string &value) string &value)
{ {
int rv; int rv;
@ -259,7 +259,7 @@ namespace fs
int int
getxattrs(const string path, getxattrs(const string &path,
map<string,string> &attrs) map<string,string> &attrs)
{ {
int rv; int rv;
@ -287,10 +287,10 @@ namespace fs
} }
int int
setxattr(const string path, setxattr(const string &path,
const string key, const string &key,
const string value, const string &value,
const int flags) const int flags)
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
return ::setxattr(path.c_str(), return ::setxattr(path.c_str(),
@ -305,10 +305,10 @@ namespace fs
} }
int int
setxattr(const int fd, setxattr(const int fd,
const string key, const string &key,
const string value, const string &value,
const int flags) const int flags)
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
return ::fsetxattr(fd, return ::fsetxattr(fd,
@ -323,7 +323,7 @@ namespace fs
} }
int int
setxattrs(const string path, setxattrs(const string &path,
const map<string,string> &attrs) const map<string,string> &attrs)
{ {
int fd; int fd;
@ -342,8 +342,8 @@ namespace fs
} }
int int
copyxattrs(const string from, copyxattrs(const string &from,
const string to) const string &to)
{ {
int rv; int rv;
map<string,string> attrs; map<string,string> attrs;
@ -356,8 +356,8 @@ namespace fs
} }
int int
copyattr(const string from, copyattr(const string &from,
const string to) const string &to)
{ {
int fd; int fd;
int rv; int rv;
@ -395,9 +395,9 @@ namespace fs
} }
int int
clonepath(const string fromsrc, clonepath(const string &fromsrc,
const string tosrc, const string &tosrc,
const string relative) const string &relative)
{ {
int rv; int rv;
struct stat st; struct stat st;
@ -492,7 +492,7 @@ namespace fs
{ {
int int
invalid(const vector<string> &basepaths, invalid(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
return (errno = EINVAL,-1); return (errno = EINVAL,-1);
@ -500,7 +500,7 @@ namespace fs
int int
ff(const vector<string> &basepaths, ff(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
errno = ENOENT; errno = ENOENT;
@ -524,7 +524,7 @@ namespace fs
int int
ffwp(const vector<string> &basepaths, ffwp(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
Path fallback; Path fallback;
@ -560,7 +560,7 @@ namespace fs
int int
newest(const vector<string> &basepaths, newest(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
time_t newest; time_t newest;
@ -595,7 +595,7 @@ namespace fs
int int
all(const vector<string> &basepaths, all(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
errno = ENOENT; errno = ENOENT;
@ -619,7 +619,7 @@ namespace fs
int int
mfs(const vector<string> &basepaths, mfs(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
fsblkcnt_t mfs; fsblkcnt_t mfs;
@ -634,8 +634,8 @@ namespace fs
++iter) ++iter)
{ {
int rv; int rv;
struct statvfs fsstats; struct statvfs fsstats;
const string mountpoint = *iter; const string &mountpoint = *iter;
rv = ::statvfs(mountpoint.c_str(),&fsstats); rv = ::statvfs(mountpoint.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
@ -663,7 +663,7 @@ namespace fs
int int
epmfs(const vector<string> &basepaths, epmfs(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
fsblkcnt_t existingmfs = 0; fsblkcnt_t existingmfs = 0;
@ -680,8 +680,8 @@ namespace fs
do do
{ {
int rv; int rv;
struct statvfs fsstats; struct statvfs fsstats;
const string mountpoint = *iter; const string &mountpoint = *iter;
rv = ::statvfs(mountpoint.c_str(),&fsstats); rv = ::statvfs(mountpoint.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
@ -722,7 +722,7 @@ namespace fs
int int
rand(const vector<string> &basepaths, rand(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths) PathVector &paths)
{ {
string randombasepath; string randombasepath;

View File

@ -38,8 +38,8 @@ namespace fs
struct Path struct Path
{ {
Path() {} Path() {}
Path(const string b, Path(const string &b,
const string f) const string &f)
: base(b), : base(b),
full(f) full(f)
{} {}
@ -49,60 +49,60 @@ namespace fs
}; };
typedef vector<Path> PathVector; 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 dirname(const string &path);
string basename(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, string make_path(const string &base,
const string suffix); const string &suffix);
bool path_exists(vector<string>::const_iterator begin, bool path_exists(vector<string>::const_iterator begin,
vector<string>::const_iterator end, vector<string>::const_iterator end,
const string fusepath); const string &fusepath);
bool path_exists(const vector<string> &srcmounts, bool path_exists(const vector<string> &srcmounts,
const string fusepath); const string &fusepath);
int clonepath(const string srcfrom, int clonepath(const string &srcfrom,
const string srcto, const string &srcto,
const string relative); const string &relative);
int listxattr(const string path, int listxattr(const string &path,
vector<char> &attrs); vector<char> &attrs);
int listxattr(const string path, int listxattr(const string &path,
string &attrs); string &attrs);
int listxattr(const string path, int listxattr(const string &path,
vector<string> &attrs); vector<string> &attrs);
int getxattr(const string path, int getxattr(const string &path,
const string attr, const string &attr,
vector<char> &value); vector<char> &value);
int getxattr(const string path, int getxattr(const string &path,
const string attr, const string &attr,
string &value); string &value);
int getxattrs(const string path, int getxattrs(const string &path,
map<string,string> &attrs); map<string,string> &attrs);
int setxattr(const string path, int setxattr(const string &path,
const string key, const string &key,
const string value, const string &value,
const int flags); const int flags);
int setxattr(const int fd, int setxattr(const int fd,
const string key, const string &key,
const string value, const string &value,
const int flags); const int flags);
int setxattrs(const string path, int setxattrs(const string &path,
const map<string,string> &attrs); const map<string,string> &attrs);
int copyxattrs(const string from, int copyxattrs(const string &from,
const string to); const string &to);
int copyattr(const string from, int copyattr(const string &from,
const string to); const string &to);
void glob(const vector<string> &patterns, void glob(const vector<string> &patterns,
vector<string> &strs); vector<string> &strs);
@ -113,28 +113,28 @@ namespace fs
namespace find namespace find
{ {
int invalid(const vector<string> &basepaths, int invalid(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths); PathVector &paths);
int ff(const vector<string> &basepaths, int ff(const vector<string> &basepaths,
const string fusepath, const string &fusepath,
PathVector &paths); PathVector &paths);
int ffwp(const vector<string> &paths, int ffwp(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
int newest(const vector<string> &paths, int newest(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
int all(const vector<string> &paths, int all(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
int mfs(const vector<string> &paths, int mfs(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
int epmfs(const vector<string> &paths, int epmfs(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
int rand(const vector<string> &paths, int rand(const vector<string> &paths,
const string fusepath, const string &fusepath,
PathVector &rv); PathVector &rv);
} }
}; };

View File

@ -67,7 +67,7 @@ static
int int
_getattr(const fs::SearchFunc searchFunc, _getattr(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
struct stat &buf) struct stat &buf)
{ {
int rv; int rv;

View File

@ -45,7 +45,7 @@ using namespace mergerfs::config;
static static
int int
_getxattr_controlfile(const Config &config, _getxattr_controlfile(const Config &config,
const string attrname, const string &attrname,
char *buf, char *buf,
const size_t count) const size_t count)
{ {
@ -100,7 +100,7 @@ static
int int
_getxattr(const fs::SearchFunc searchFunc, _getxattr(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const char *attrname, const char *attrname,
char *buf, char *buf,
const size_t count) const size_t count)

View File

@ -85,7 +85,7 @@ static
int int
_ioctl_dir_base(const fs::SearchFunc searchFunc, _ioctl_dir_base(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const int cmd, const int cmd,
void *arg, void *arg,
const unsigned int flags, const unsigned int flags,
@ -112,7 +112,7 @@ _ioctl_dir_base(const fs::SearchFunc searchFunc,
static static
int int
_ioctl_dir(const string fusepath, _ioctl_dir(const string &fusepath,
const int cmd, const int cmd,
void *arg, void *arg,
const unsigned int flags, const unsigned int flags,

View File

@ -43,8 +43,8 @@ static
int int
_link(const fs::SearchFunc searchFunc, _link(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string from, const string &from,
const string to) const string &to)
{ {
int rv; int rv;
int error; int error;

View File

@ -69,7 +69,7 @@ static
int int
_listxattr(const fs::SearchFunc searchFunc, _listxattr(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
char *list, char *list,
const size_t size) const size_t size)
{ {

View File

@ -32,7 +32,6 @@
#include "option_parser.hpp" #include "option_parser.hpp"
#include "resources.hpp" #include "resources.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "test.hpp"
#include "access.hpp" #include "access.hpp"
#include "chmod.hpp" #include "chmod.hpp"

View File

@ -45,7 +45,7 @@ int
_mkdir(const fs::SearchFunc searchFunc, _mkdir(const fs::SearchFunc searchFunc,
const fs::SearchFunc createPathFunc, const fs::SearchFunc createPathFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const mode_t mode) const mode_t mode)
{ {
int rv; int rv;

View File

@ -46,7 +46,7 @@ int
_mknod(const fs::SearchFunc searchFunc, _mknod(const fs::SearchFunc searchFunc,
const fs::SearchFunc createPathFunc, const fs::SearchFunc createPathFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const mode_t mode, const mode_t mode,
const dev_t dev) const dev_t dev)
{ {

View File

@ -45,7 +45,7 @@ static
int int
_open(const fs::SearchFunc searchFunc, _open(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const int flags, const int flags,
uint64_t &fh) uint64_t &fh)
{ {

View File

@ -28,6 +28,8 @@ namespace mergerfs
{ {
namespace opendir namespace opendir
{ {
int opendir(const char *fusepath, struct fuse_file_info *ffi); int
opendir(const char *fusepath,
struct fuse_file_info *ffi);
} }
} }

View File

@ -44,7 +44,7 @@ using namespace mergerfs;
static static
int int
process_opt(config::Config &config, process_opt(config::Config &config,
const std::string arg) const std::string &arg)
{ {
int rv = 0; int rv = 0;
std::vector<std::string> argvalue; std::vector<std::string> argvalue;

View File

@ -55,7 +55,7 @@ namespace mergerfs
const Policy &Policy::rand = Policy::policies[Policy::Enum::rand]; const Policy &Policy::rand = Policy::policies[Policy::Enum::rand];
const Policy& const Policy&
Policy::find(const std::string str) Policy::find(const std::string &str)
{ {
for(int i = Enum::BEGIN; i != Enum::END; ++i) for(int i = Enum::BEGIN; i != Enum::END; ++i)
{ {

View File

@ -65,9 +65,9 @@ namespace mergerfs
{ {
} }
Policy(const Enum::Type enum_, Policy(const Enum::Type enum_,
const std::string str_, const std::string &str_,
const fs::SearchFunc func_) const fs::SearchFunc func_)
: _enum(enum_), : _enum(enum_),
_str(str_), _str(str_),
_func(func_) _func(func_)
@ -76,17 +76,17 @@ namespace mergerfs
public: public:
operator const Enum::Type() const { return _enum; } 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 fs::SearchFunc() const { return _func; }
operator const Policy*() const { return this; } operator const Policy*() const { return this; }
bool operator==(const Enum::Type enum_) const bool operator==(const Enum::Type enum_) const
{ return _enum == enum_; } { return _enum == enum_; }
bool operator==(const std::string str_) const bool operator==(const std::string &str_) const
{ return _str == str_; } { return _str == str_; }
bool operator==(const fs::SearchFunc func_) const bool operator==(const fs::SearchFunc func_) const
{ return _func == func_; } { return _func == func_; }
bool operator!=(const Policy &r) const bool operator!=(const Policy &r) const
{ return _enum != r._enum; } { return _enum != r._enum; }
@ -94,7 +94,7 @@ namespace mergerfs
{ return _enum < r._enum; } { return _enum < r._enum; }
public: public:
static const Policy &find(const std::string); static const Policy &find(const std::string&);
static const Policy &find(const Enum::Type); static const Policy &find(const Enum::Type);
public: public:

View File

@ -48,7 +48,7 @@ using mergerfs::readdir::FileData;
static static
int int
_readdir(const vector<string> &srcmounts, _readdir(const vector<string> &srcmounts,
const string dirname, const string &dirname,
void *buf, void *buf,
const fuse_fill_dir_t filler) const fuse_fill_dir_t filler)
{ {
@ -107,7 +107,7 @@ namespace mergerfs
{ {
int int
readdir(const vector<string> &srcmounts, readdir(const vector<string> &srcmounts,
const string dirname, const string &dirname,
vector<FileData> &stats) vector<FileData> &stats)
{ {
return _readdir(srcmounts, return _readdir(srcmounts,

View File

@ -40,8 +40,8 @@ namespace mergerfs
{ {
struct FileData struct FileData
{ {
FileData(std::string filename_, FileData(const std::string &filename_,
struct stat stats_) const struct stat &stats_)
: filename(filename_), : filename(filename_),
stats(stats_) stats(stats_)
{} {}
@ -59,7 +59,7 @@ namespace mergerfs
int int
readdir(const std::vector<std::string> &srcmounts, readdir(const std::vector<std::string> &srcmounts,
const std::string dirname, const std::string &dirname,
std::vector<FileData> &stats); std::vector<FileData> &stats);
} }
} }

View File

@ -42,8 +42,8 @@ using mergerfs::Policy;
static static
int int
_readlink(const fs::SearchFunc searchFunc, _readlink(const fs::SearchFunc searchFunc,
const vector<string>& srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
char *buf, char *buf,
const size_t size) const size_t size)
{ {

View File

@ -28,6 +28,8 @@ namespace mergerfs
{ {
namespace releasedir namespace releasedir
{ {
int releasedir(const char *fusepath, struct fuse_file_info *ffi); int
releasedir(const char *fusepath,
struct fuse_file_info *ffi);
} }
} }

View File

@ -43,7 +43,7 @@ static
int int
_removexattr(const fs::SearchFunc searchFunc, _removexattr(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const char *attrname) const char *attrname)
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR

View File

@ -43,8 +43,8 @@ static
int int
_rename(const fs::SearchFunc searchFunc, _rename(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string from, const string &from,
const string to) const string &to)
{ {
int rv; int rv;
string pathto; string pathto;

View File

@ -42,7 +42,7 @@ static
int int
_rmdir(const fs::SearchFunc searchFunc, _rmdir(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath) const string &fusepath)
{ {
int rv; int rv;
int error; int error;

View File

@ -42,10 +42,11 @@ namespace mergerfs
pthread_rwlock_unlock(_lock); pthread_rwlock_unlock(_lock);
} }
pthread_rwlock_t *_lock;
private: private:
ReadGuard(); ReadGuard();
private:
pthread_rwlock_t *_lock;
}; };
class WriteGuard class WriteGuard
@ -62,10 +63,11 @@ namespace mergerfs
pthread_rwlock_unlock(_lock); pthread_rwlock_unlock(_lock);
} }
pthread_rwlock_t *_lock;
private: private:
WriteGuard(); WriteGuard();
private:
pthread_rwlock_t *_lock;
}; };
} }
} }

View File

@ -48,8 +48,8 @@ static
int int
_add_srcmounts(vector<string> &srcmounts, _add_srcmounts(vector<string> &srcmounts,
pthread_rwlock_t &srcmountslock, pthread_rwlock_t &srcmountslock,
const string destmount, const string &destmount,
const string values, const string &values,
vector<string>::iterator pos) vector<string>::iterator pos)
{ {
vector<string> patterns; vector<string> patterns;
@ -73,7 +73,7 @@ _add_srcmounts(vector<string> &srcmounts,
static static
int int
_erase_srcmounts(vector<string> &srcmounts, _erase_srcmounts(vector<string> &srcmounts,
pthread_rwlock_t srcmountslock, pthread_rwlock_t &srcmountslock,
const string &values) const string &values)
{ {
if(srcmounts.empty()) if(srcmounts.empty())
@ -83,9 +83,11 @@ _erase_srcmounts(vector<string> &srcmounts,
str::split(patterns,values,':'); 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; return 0;
} }
@ -93,9 +95,9 @@ _erase_srcmounts(vector<string> &srcmounts,
static static
int int
_replace_srcmounts(vector<string> &srcmounts, _replace_srcmounts(vector<string> &srcmounts,
pthread_rwlock_t srcmountslock, pthread_rwlock_t &srcmountslock,
const string destmount, const string &destmount,
const string values) const string &values)
{ {
vector<string> patterns; vector<string> patterns;
vector<string> newmounts; vector<string> newmounts;
@ -114,7 +116,7 @@ _replace_srcmounts(vector<string> &srcmounts,
static static
void void
_split_attrval(const string attrval, _split_attrval(const string &attrval,
string &instruction, string &instruction,
string &values) string &values)
{ {
@ -130,8 +132,8 @@ static
int int
_setxattr_srcmounts(vector<string> &srcmounts, _setxattr_srcmounts(vector<string> &srcmounts,
pthread_rwlock_t &srcmountslock, pthread_rwlock_t &srcmountslock,
const string destmount, const string &destmount,
const string attrval, const string &attrval,
const int flags) const int flags)
{ {
string instruction; string instruction;
@ -165,8 +167,8 @@ _setxattr_srcmounts(vector<string> &srcmounts,
static static
int int
_setxattr_policy(const Policy *policies[], _setxattr_policy(const Policy *policies[],
const string attrname, const string &attrname,
const string attrval, const string &attrval,
const int flags) const int flags)
{ {
const Category *cat; const Category *cat;
@ -191,8 +193,8 @@ _setxattr_policy(const Policy *policies[],
static static
int int
_setxattr_controlfile(config::Config &config, _setxattr_controlfile(config::Config &config,
const string attrname, const string &attrname,
const string attrval, const string &attrval,
const int flags) const int flags)
{ {
vector<string> nameparts; vector<string> nameparts;
@ -224,7 +226,7 @@ static
int int
_setxattr(const fs::SearchFunc searchFunc, _setxattr(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const char *attrname, const char *attrname,
const char *attrval, const char *attrval,
const size_t attrvalsize, const size_t attrvalsize,

View File

@ -34,7 +34,7 @@ namespace str
{ {
void void
split(vector<string> &result, split(vector<string> &result,
const string str, const string &str,
const char delimiter) const char delimiter)
{ {
string part; string part;

View File

@ -27,10 +27,12 @@
namespace str namespace str
{ {
void split(std::vector<std::string> &result, void
const std::string str, split(std::vector<std::string> &result,
const char delimiter); const std::string &str,
const char delimiter);
std::string join(const std::vector<std::string> &vec, std::string
const char sep); join(const std::vector<std::string> &vec,
const char sep);
} }

View File

@ -40,8 +40,8 @@ using std::vector;
static static
int int
_symlink(const vector<string> &srcmounts, _symlink(const vector<string> &srcmounts,
const string from, const string &from,
const string to) const string &to)
{ {
int rv; int rv;
fs::PathVector paths; fs::PathVector paths;

View File

@ -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;
}
}

View File

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

View File

@ -43,7 +43,7 @@ static
int int
_truncate(const fs::SearchFunc searchFunc, _truncate(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const off_t size) const off_t size)
{ {
int rv; int rv;

View File

@ -42,7 +42,7 @@ static
int int
_unlink(const fs::SearchFunc searchFunc, _unlink(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath) const string &fusepath)
{ {
int rv; int rv;
int error; int error;

View File

@ -41,10 +41,10 @@ using std::vector;
static static
int int
_utimens(const fs::SearchFunc searchFunc, _utimens(const fs::SearchFunc searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const string fusepath, const string &fusepath,
const struct timespec ts[2]) const struct timespec ts[2])
{ {
int rv; int rv;
int error; int error;