Browse Source

pass const strings by reference. closes #33

pull/37/merge
Antonio SJ Musumeci 10 years ago
parent
commit
6c3ff01a0a
  1. 2
      src/access.cpp
  2. 2
      src/category.cpp
  3. 10
      src/category.hpp
  4. 2
      src/chmod.cpp
  5. 2
      src/chown.cpp
  6. 2
      src/create.cpp
  7. 92
      src/fs.cpp
  8. 84
      src/fs.hpp
  9. 2
      src/getattr.cpp
  10. 4
      src/getxattr.cpp
  11. 4
      src/ioctl.cpp
  12. 4
      src/link.cpp
  13. 2
      src/listxattr.cpp
  14. 1
      src/mergerfs.cpp
  15. 2
      src/mkdir.cpp
  16. 2
      src/mknod.cpp
  17. 2
      src/open.cpp
  18. 4
      src/opendir.hpp
  19. 2
      src/option_parser.cpp
  20. 2
      src/policy.cpp
  21. 12
      src/policy.hpp
  22. 4
      src/readdir.cpp
  23. 6
      src/readdir.hpp
  24. 4
      src/readlink.cpp
  25. 4
      src/releasedir.hpp
  26. 2
      src/removexattr.cpp
  27. 4
      src/rename.cpp
  28. 2
      src/rmdir.cpp
  29. 10
      src/rwlock.hpp
  30. 34
      src/setxattr.cpp
  31. 2
      src/str.cpp
  32. 12
      src/str.hpp
  33. 4
      src/symlink.cpp
  34. 55
      src/test.cpp
  35. 30
      src/test.hpp
  36. 2
      src/truncate.cpp
  37. 2
      src/unlink.cpp
  38. 8
      src/utimens.cpp

2
src/access.cpp

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

2
src/category.cpp

@ -47,7 +47,7 @@ namespace mergerfs
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)
{ {

10
src/category.hpp

@ -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_), : _enum(enum_),
_str(str_) _str(str_)
{ {
@ -66,10 +66,10 @@ 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
@ -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:

2
src/chmod.cpp

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

2
src/chown.cpp

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

2
src/create.cpp

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

92
src/fs.cpp

@ -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,
const string suffix)
make_path(const string &base,
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,
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 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,
string &attrstr)
listxattr(const string &path,
string &attrstr)
{ {
int rv; int rv;
vector<char> attrs; vector<char> attrs;
@ -218,8 +218,8 @@ namespace fs
} }
int int
getxattr(const string path,
const string attr,
getxattr(const string &path,
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,
const string attr,
getxattr(const string &path,
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,
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 #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,
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 #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,
const string to)
copyxattrs(const string &from,
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,
const string to)
copyattr(const string &from,
const string &to)
{ {
int fd; int fd;
int rv; int rv;
@ -395,9 +395,9 @@ namespace fs
} }
int int
clonepath(const string fromsrc,
const string tosrc,
const string relative)
clonepath(const string &fromsrc,
const string &tosrc,
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;
const string mountpoint = *iter;
struct statvfs fsstats;
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;
const string mountpoint = *iter;
struct statvfs fsstats;
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;

84
src/fs.hpp

@ -38,8 +38,8 @@ namespace fs
struct Path struct Path
{ {
Path() {} Path() {}
Path(const string b,
const string f)
Path(const string &b,
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 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, 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,
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); 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,
const string attr,
int getxattr(const string &path,
const string &attr,
vector<char> &value); vector<char> &value);
int getxattr(const string path,
const string attr,
int getxattr(const string &path,
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,
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); 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, 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);
} }
}; };

2
src/getattr.cpp

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

4
src/getxattr.cpp

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

4
src/ioctl.cpp

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

4
src/link.cpp

@ -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 to)
const string &from,
const string &to)
{ {
int rv; int rv;
int error; int error;

2
src/listxattr.cpp

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

1
src/mergerfs.cpp

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

2
src/mkdir.cpp

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

2
src/mknod.cpp

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

2
src/open.cpp

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

4
src/opendir.hpp

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

2
src/option_parser.cpp

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

2
src/policy.cpp

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

12
src/policy.hpp

@ -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_), : _enum(enum_),
_str(str_), _str(str_),
_func(func_) _func(func_)
@ -76,13 +76,13 @@ 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_; }
@ -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:

4
src/readdir.cpp

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

6
src/readdir.hpp

@ -40,8 +40,8 @@ namespace mergerfs
{ {
struct FileData struct FileData
{ {
FileData(std::string filename_,
struct stat stats_)
FileData(const std::string &filename_,
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);
} }
} }

4
src/readlink.cpp

@ -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 string fusepath,
const vector<string> &srcmounts,
const string &fusepath,
char *buf, char *buf,
const size_t size) const size_t size)
{ {

4
src/releasedir.hpp

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

2
src/removexattr.cpp

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

4
src/rename.cpp

@ -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 to)
const string &from,
const string &to)
{ {
int rv; int rv;
string pathto; string pathto;

2
src/rmdir.cpp

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

10
src/rwlock.hpp

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

34
src/setxattr.cpp

@ -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 values,
const string &destmount,
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,
const string destmount,
const string values)
pthread_rwlock_t &srcmountslock,
const string &destmount,
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 attrval,
const string &destmount,
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 attrval,
const string &attrname,
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 attrval,
const string &attrname,
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,

2
src/str.cpp

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

12
src/str.hpp

@ -27,10 +27,12 @@
namespace str 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);
} }

4
src/symlink.cpp

@ -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 to)
const string &from,
const string &to)
{ {
int rv; int rv;
fs::PathVector paths; fs::PathVector paths;

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

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

2
src/truncate.cpp

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

2
src/unlink.cpp

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

8
src/utimens.cpp

@ -41,10 +41,10 @@ using std::vector;
static static
int 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 rv;
int error; int error;

Loading…
Cancel
Save