Browse Source

stop auto calculating and storing fullpath in policies

pull/78/head
Antonio SJ Musumeci 10 years ago
parent
commit
b2cd79154a
  1. 8
      src/access.cpp
  2. 6
      src/chmod.cpp
  3. 6
      src/chown.cpp
  4. 15
      src/create.cpp
  5. 152
      src/fs.cpp
  6. 42
      src/fs.hpp
  7. 6
      src/getattr.cpp
  8. 22
      src/getxattr.cpp
  9. 8
      src/ioctl.cpp
  10. 14
      src/link.cpp
  11. 6
      src/listxattr.cpp
  12. 2
      src/mergerfs.cpp
  13. 16
      src/mkdir.cpp
  14. 17
      src/mknod.cpp
  15. 4
      src/open.cpp
  16. 4
      src/option_parser.cpp
  17. 28
      src/policy.hpp
  18. 10
      src/policy_all.cpp
  19. 16
      src/policy_epmfs.cpp
  20. 8
      src/policy_ff.cpp
  21. 11
      src/policy_ffwp.cpp
  22. 13
      src/policy_fwfs.cpp
  23. 2
      src/policy_invalid.cpp
  24. 14
      src/policy_lfs.cpp
  25. 16
      src/policy_mfs.cpp
  26. 9
      src/policy_newest.cpp
  27. 2
      src/policy_rand.cpp
  28. 2
      src/readdir.cpp
  29. 6
      src/readlink.cpp
  30. 6
      src/removexattr.cpp
  31. 30
      src/rename.cpp
  32. 6
      src/rmdir.cpp
  33. 6
      src/setxattr.cpp
  34. 8
      src/symlink.cpp
  35. 6
      src/truncate.cpp
  36. 6
      src/unlink.cpp
  37. 6
      src/utimens.cpp

8
src/access.cpp

@ -53,13 +53,15 @@ _access(Policy::Func::Search searchFunc,
const int mask) const int mask)
{ {
int rv; int rv;
Paths paths;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,paths);
rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
rv = ::eaccess(paths[0].full.c_str(),mask);
fs::path::append(path[0],fusepath);
rv = ::eaccess(path[0].c_str(),mask);
return ((rv == -1) ? -errno : 0); return ((rv == -1) ? -errno : 0);
} }

6
src/chmod.cpp

@ -47,7 +47,7 @@ _chmod(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -56,7 +56,9 @@ _chmod(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::chmod(paths[i].full.c_str(),mode);
fs::path::append(paths[i],fusepath);
rv = ::chmod(paths[i].c_str(),mode);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/chown.cpp

@ -49,7 +49,7 @@ _chown(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -58,7 +58,9 @@ _chown(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::lchown(paths[i].full.c_str(),uid,gid);
fs::path::append(paths[i],fusepath);
rv = ::lchown(paths[i].c_str(),uid,gid);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

15
src/create.cpp

@ -54,12 +54,11 @@ _create(Policy::Func::Search searchFunc,
{ {
int fd; int fd;
int rv; int rv;
string path;
string dirname; string dirname;
Paths createpath;
Paths existingpath;
vector<string> createpath;
vector<string> existingpath;
dirname = fs::dirname(fusepath);
dirname = fs::path::dirname(fusepath);
rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
@ -68,15 +67,15 @@ _create(Policy::Func::Search searchFunc,
if(rv == -1) if(rv == -1)
return -errno; return -errno;
if(createpath[0].base != existingpath[0].base)
if(createpath[0] != existingpath[0])
{ {
const mergerfs::ugid::SetResetGuard ugid(0,0); const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);
fs::clonepath(existingpath[0],createpath[0],dirname);
} }
path = fs::make_path(createpath[0].base,fusepath);
fs::path::append(createpath[0],fusepath);
fd = ::open(path.c_str(),flags,mode);
fd = ::open(createpath[0].c_str(),flags,mode);
if(fd == -1) if(fd == -1)
return -errno; return -errno;

152
src/fs.cpp

@ -63,102 +63,85 @@ random_element(Iter begin,
namespace fs namespace fs
{ {
string
dirname(const string &path)
namespace path
{ {
string parent = path;
string::reverse_iterator i;
string::reverse_iterator bi;
bi = parent.rend();
i = parent.rbegin();
while(*i == '/' && i != bi)
i++;
string
dirname(const string &path)
{
string parent = path;
string::reverse_iterator i;
string::reverse_iterator bi;
while(*i != '/' && i != bi)
i++;
bi = parent.rend();
i = parent.rbegin();
while(*i == '/' && i != bi)
i++;
while(*i == '/' && i != bi)
i++;
while(*i != '/' && i != bi)
i++;
parent.erase(i.base(),parent.end());
while(*i == '/' && i != bi)
i++;
return parent;
}
parent.erase(i.base(),parent.end());
string
basename(const string &path)
{
return path.substr(path.find_last_of('/')+1);
}
return parent;
}
bool
dir_is_empty(const string &path)
{
DIR *dir;
struct dirent *de;
string
basename(const string &path)
{
return path.substr(path.find_last_of('/')+1);
}
dir = ::opendir(path.c_str());
if(!dir)
return false;
bool
is_empty(const string &path)
{
DIR *dir;
struct dirent *de;
while((de = ::readdir(dir)))
{
const char *d_name = de->d_name;
dir = ::opendir(path.c_str());
if(!dir)
return false;
if(d_name[0] == '.' &&
((d_name[1] == '\0') ||
(d_name[1] == '.' && d_name[2] == '\0')))
continue;
while((de = ::readdir(dir)))
{
const char *d_name = de->d_name;
::closedir(dir);
if(d_name[0] == '.' &&
((d_name[1] == '\0') ||
(d_name[1] == '.' && d_name[2] == '\0')))
continue;
return false;
}
::closedir(dir);
::closedir(dir);
return false;
}
return true;
}
::closedir(dir);
string
make_path(const string &base,
const string &suffix)
{
if(suffix[0] == '/' ||
*base.rbegin() == '/')
return base + suffix;
return base + '/' + suffix;
}
return true;
}
bool
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)
{
int rv;
string path;
struct stat st;
bool
exists(const vector<string> &paths,
const string &fusepath)
{
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
int rv;
string path;
struct stat st;
path = fs::make_path(*iter,fusepath);
rv = ::lstat(path.c_str(),&st);
if(rv == 0)
return true;
}
path = fs::path::make(paths[i],fusepath);
return false;
}
rv = ::lstat(path.c_str(),&st);
if(rv == 0)
return true;
}
bool
path_exists(const vector<string> &srcmounts,
const string &fusepath)
{
return path_exists(srcmounts.begin(),
srcmounts.end(),
fusepath);
return false;
}
} }
void void
@ -166,16 +149,14 @@ namespace fs
const string &fusepath, const string &fusepath,
vector<string> &paths) vector<string> &paths)
{ {
for(vector<string>::const_iterator
iter = srcmounts.begin(), eiter = srcmounts.end();
iter != eiter;
++iter)
for(size_t i = 0, ei = srcmounts.size(); i != ei; i++)
{ {
int rv; int rv;
string fullpath; string fullpath;
struct stat st; struct stat st;
fullpath = fs::make_path(*iter,fusepath);
fullpath = fs::path::make(srcmounts[i],fusepath);
rv = ::lstat(fullpath.c_str(),&st); rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0) if(rv == 0)
paths.push_back(fullpath); paths.push_back(fullpath);
@ -450,7 +431,7 @@ namespace fs
string frompath; string frompath;
string dirname; string dirname;
dirname = fs::dirname(relative);
dirname = fs::path::dirname(relative);
if(!dirname.empty()) if(!dirname.empty())
{ {
rv = clonepath(fromsrc,tosrc,dirname); rv = clonepath(fromsrc,tosrc,dirname);
@ -458,15 +439,14 @@ namespace fs
return -1; return -1;
} }
frompath = fs::make_path(fromsrc,relative);
frompath = fs::path::make(fromsrc,relative);
rv = ::stat(frompath.c_str(),&st); rv = ::stat(frompath.c_str(),&st);
if(rv == -1) if(rv == -1)
return -1; return -1;
else if(!S_ISDIR(st.st_mode)) else if(!S_ISDIR(st.st_mode))
return (errno = ENOTDIR,-1); return (errno = ENOTDIR,-1);
topath = fs::make_path(tosrc,relative);
topath = fs::path::make(tosrc,relative);
rv = ::mkdir(topath.c_str(),st.st_mode); rv = ::mkdir(topath.c_str(),st.st_mode);
if(rv == -1) if(rv == -1)
{ {

42
src/fs.hpp

@ -38,19 +38,35 @@ namespace fs
using std::vector; using std::vector;
using std::map; using std::map;
string dirname(const string &path);
string basename(const string &path);
bool dir_is_empty(const string &path);
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);
bool path_exists(const vector<string> &srcmounts,
const string &fusepath);
namespace path
{
string dirname(const string &path);
string basename(const string &path);
bool is_empty(const string &path);
bool exists(vector<string>::const_iterator begin,
vector<string>::const_iterator end,
const string &fusepath);
bool exists(const vector<string> &srcmounts,
const string &fusepath);
inline
string
make(const string &base,
const string &suffix)
{
return base + suffix;
}
inline
void
append(string &base,
const string &suffix)
{
base += suffix;
}
}
void findallfiles(const vector<string> &srcmounts, void findallfiles(const vector<string> &srcmounts,
const string &fusepath, const string &fusepath,

6
src/getattr.cpp

@ -73,13 +73,15 @@ _getattr(Policy::Func::Search searchFunc,
struct stat &buf) struct stat &buf)
{ {
int rv; int rv;
Paths path;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,path); rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
rv = ::lstat(path[0].full.c_str(),&buf);
fs::path::append(path[0],fusepath);
rv = ::lstat(path[0].c_str(),&buf);
return ((rv == -1) ? -errno : 0); return ((rv == -1) ? -errno : 0);
} }

22
src/getxattr.cpp

@ -167,9 +167,10 @@ _getxattr_user_mergerfs_allpaths(const vector<string> &srcmounts,
static static
int int
_getxattr_user_mergerfs(const Path &path,
const vector<string> &srcmounts,
_getxattr_user_mergerfs(const string &basepath,
const string &fusepath, const string &fusepath,
const string &fullpath,
const vector<string> &srcmounts,
const char *attrname, const char *attrname,
char *buf, char *buf,
const size_t count) const size_t count)
@ -177,15 +178,15 @@ _getxattr_user_mergerfs(const Path &path,
const char *attrbasename = &attrname[sizeof("user.mergerfs")]; const char *attrbasename = &attrname[sizeof("user.mergerfs")];
if(!strcmp(attrbasename,"basepath")) if(!strcmp(attrbasename,"basepath"))
return ::_getxattr_from_string(buf,count,path.base);
return ::_getxattr_from_string(buf,count,basepath);
else if(!strcmp(attrbasename,"fullpath")) else if(!strcmp(attrbasename,"fullpath"))
return ::_getxattr_from_string(buf,count,path.full);
return ::_getxattr_from_string(buf,count,fullpath);
else if(!strcmp(attrbasename,"relpath")) else if(!strcmp(attrbasename,"relpath"))
return ::_getxattr_from_string(buf,count,fusepath); return ::_getxattr_from_string(buf,count,fusepath);
else if(!strcmp(attrbasename,"allpaths")) else if(!strcmp(attrbasename,"allpaths"))
return ::_getxattr_user_mergerfs_allpaths(srcmounts,fusepath,buf,count); return ::_getxattr_user_mergerfs_allpaths(srcmounts,fusepath,buf,count);
return ::lgetxattr(path.full.c_str(),attrname,buf,count);
return ::lgetxattr(fullpath.c_str(),attrname,buf,count);
} }
static static
@ -200,16 +201,19 @@ _getxattr(Policy::Func::Search searchFunc,
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
int rv; int rv;
Paths path;
vector<string> basepath;
string fullpath;
rv = searchFunc(srcmounts,fusepath,minfreespace,path);
rv = searchFunc(srcmounts,fusepath,minfreespace,basepath);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
fullpath = fs::path::make(basepath[0],fusepath);
if(!strncmp("user.mergerfs.",attrname,sizeof("user.mergerfs.")-1)) if(!strncmp("user.mergerfs.",attrname,sizeof("user.mergerfs.")-1))
rv = _getxattr_user_mergerfs(path[0],srcmounts,fusepath,attrname,buf,count);
rv = _getxattr_user_mergerfs(basepath[0],fusepath,fullpath,srcmounts,attrname,buf,count);
else else
rv = ::lgetxattr(path[0].full.c_str(),attrname,buf,count);
rv = ::lgetxattr(fullpath.c_str(),attrname,buf,count);
return ((rv == -1) ? -errno : rv); return ((rv == -1) ? -errno : rv);
#else #else

8
src/ioctl.cpp

@ -93,19 +93,21 @@ _ioctl_dir_base(Policy::Func::Search searchFunc,
{ {
int fd; int fd;
int rv; int rv;
Paths path;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,path); rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
fd = ::open(path[0].full.c_str(),flags);
fs::path::append(path[0],fusepath);
fd = ::open(path[0].c_str(),flags);
if(fd == -1) if(fd == -1)
return -errno; return -errno;
rv = _ioctl(fd,cmd,arg,flags,data); rv = _ioctl(fd,cmd,arg,flags,data);
close(fd);
::close(fd);
return rv; return rv;
} }

14
src/link.cpp

@ -49,23 +49,23 @@ _single_link(Policy::Func::Search searchFunc,
const string &newpath) const string &newpath)
{ {
int rv; int rv;
const string fulloldpath = fs::make_path(base,oldpath);
const string fullnewpath = fs::make_path(base,newpath);
const string fulloldpath = fs::path::make(base,oldpath);
const string fullnewpath = fs::path::make(base,newpath);
rv = ::link(fulloldpath.c_str(),fullnewpath.c_str()); rv = ::link(fulloldpath.c_str(),fullnewpath.c_str());
if(rv == -1 && errno == ENOENT) if(rv == -1 && errno == ENOENT)
{ {
string newpathdir; string newpathdir;
Paths foundpath;
vector<string> foundpath;
newpathdir = fs::dirname(newpath);
newpathdir = fs::path::dirname(newpath);
rv = searchFunc(srcmounts,newpathdir,minfreespace,foundpath); rv = searchFunc(srcmounts,newpathdir,minfreespace,foundpath);
if(rv == -1) if(rv == -1)
return -1; return -1;
{ {
const mergerfs::ugid::SetResetGuard ugid(0,0); const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(foundpath[0].base,base,newpathdir);
fs::clonepath(foundpath[0],base,newpathdir);
} }
rv = ::link(fulloldpath.c_str(),fullnewpath.c_str()); rv = ::link(fulloldpath.c_str(),fullnewpath.c_str());
@ -85,7 +85,7 @@ _link(Policy::Func::Search searchFunc,
{ {
int rv; int rv;
int error; int error;
Paths oldpaths;
vector<string> oldpaths;
rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths); rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths);
if(rv == -1) if(rv == -1)
@ -94,7 +94,7 @@ _link(Policy::Func::Search searchFunc,
error = 0; error = 0;
for(size_t i = 0, ei = oldpaths.size(); i != ei; i++) for(size_t i = 0, ei = oldpaths.size(); i != ei; i++)
{ {
rv = _single_link(searchFunc,srcmounts,minfreespace,oldpaths[i].base,oldpath,newpath);
rv = _single_link(searchFunc,srcmounts,minfreespace,oldpaths[i],oldpath,newpath);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/listxattr.cpp

@ -78,13 +78,15 @@ _listxattr(Policy::Func::Search searchFunc,
{ {
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
int rv; int rv;
Paths path;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,path); rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
rv = ::llistxattr(path[0].full.c_str(),list,size);
fs::path::append(path[0],fusepath);
rv = ::llistxattr(path[0].c_str(),list,size);
return ((rv == -1) ? -errno : rv); return ((rv == -1) ? -errno : rv);
#else #else

2
src/mergerfs.cpp

@ -80,7 +80,7 @@ namespace local
getappname(const int argc, getappname(const int argc,
char * const *argv) char * const *argv)
{ {
return fs::basename(argv[0]);
return fs::path::basename(argv[0]);
} }
static static

16
src/mkdir.cpp

@ -53,10 +53,10 @@ _mkdir(Policy::Func::Search searchFunc,
int error; int error;
string dirname; string dirname;
string fullpath; string fullpath;
Paths createpaths;
Paths existingpath;
vector<string> createpaths;
vector<string> existingpath;
dirname = fs::dirname(fusepath);
dirname = fs::path::dirname(fusepath);
rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
@ -68,17 +68,17 @@ _mkdir(Policy::Func::Search searchFunc,
error = 0; error = 0;
for(size_t i = 0, ei = createpaths.size(); i != ei; i++) for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
{ {
const string &createpath = createpaths[i].base;
string &createpath = createpaths[i];
if(createpath != existingpath[0].base)
if(createpath != existingpath[0])
{ {
const mergerfs::ugid::SetResetGuard ugid(0,0); const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(existingpath[0].base,createpath,dirname);
fs::clonepath(existingpath[0],createpath,dirname);
} }
fullpath = fs::make_path(createpath,fusepath);
fs::path::append(createpath,fusepath);
rv = ::mkdir(fullpath.c_str(),mode);
rv = ::mkdir(createpath.c_str(),mode);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

17
src/mknod.cpp

@ -55,11 +55,10 @@ _mknod(Policy::Func::Search searchFunc,
int rv; int rv;
int error; int error;
string dirname; string dirname;
string fullpath;
Paths createpaths;
Paths existingpath;
vector<string> createpaths;
vector<string> existingpath;
dirname = fs::dirname(fusepath);
dirname = fs::path::dirname(fusepath);
rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
@ -71,17 +70,17 @@ _mknod(Policy::Func::Search searchFunc,
error = 0; error = 0;
for(size_t i = 0, ei = createpaths.size(); i != ei; i++) for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
{ {
const string &createpath = createpaths[0].base;
string &createpath = createpaths[0];
if(createpath != existingpath[0].base)
if(createpath != existingpath[0])
{ {
const mergerfs::ugid::SetResetGuard ugid(0,0); const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(existingpath[0].base,createpath,dirname);
fs::clonepath(existingpath[0],createpath,dirname);
} }
fullpath = fs::make_path(createpath,fusepath);
fs::path::append(createpath,fusepath);
rv = ::mknod(fullpath.c_str(),mode,dev);
rv = ::mknod(createpath.c_str(),mode,dev);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

4
src/open.cpp

@ -51,13 +51,13 @@ _open(Policy::Func::Search searchFunc,
{ {
int fd; int fd;
int rv; int rv;
Paths path;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,path); rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
fd = ::open(path[0].full.c_str(),flags);
fd = ::open(path[0].c_str(),flags);
if(fd == -1) if(fd == -1)
return -errno; return -errno;

4
src/option_parser.cpp

@ -121,8 +121,8 @@ parse_and_process_minfreespace(const std::string &value,
minfreespace *= (1024 * 1024); minfreespace *= (1024 * 1024);
break; break;
case 'b':
case 'B':
case 'g':
case 'G':
minfreespace *= (1024 * 1024 * 1024); minfreespace *= (1024 * 1024 * 1024);
break; break;

28
src/policy.hpp

@ -67,7 +67,7 @@ namespace mergerfs
typedef const strvec cstrvec; typedef const strvec cstrvec;
typedef const Category::Enum::Type CType; typedef const Category::Enum::Type CType;
typedef int (*Ptr)(CType,cstrvec&,cstring&,csize_t,Paths&);
typedef int (*Ptr)(CType,cstrvec&,cstring&,csize_t,strvec&);
class Action class Action
{ {
@ -77,7 +77,7 @@ namespace mergerfs
{} {}
int int
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
{ {
return func(Category::Enum::action,b,c,d,e); return func(Category::Enum::action,b,c,d,e);
} }
@ -94,7 +94,7 @@ namespace mergerfs
{} {}
int int
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
{ {
return func(Category::Enum::create,b,c,d,e); return func(Category::Enum::create,b,c,d,e);
} }
@ -111,7 +111,7 @@ namespace mergerfs
{} {}
int int
operator()(cstrvec& b,cstring& c,csize_t d,Paths& e)
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
{ {
return func(Category::Enum::search,b,c,d,e); return func(Category::Enum::search,b,c,d,e);
} }
@ -120,16 +120,16 @@ namespace mergerfs
const Ptr func; const Ptr func;
}; };
static int invalid(CType,cstrvec&,cstring&,csize_t,Paths&);
static int all(CType,cstrvec&,cstring&,csize_t,Paths&);
static int epmfs(CType,cstrvec&,cstring&,csize_t,Paths&);
static int ff(CType,cstrvec&,cstring&,csize_t,Paths&);
static int ffwp(CType,cstrvec&,cstring&,csize_t,Paths&);
static int fwfs(CType,cstrvec&,cstring&,csize_t,Paths&);
static int lfs(CType,cstrvec&,cstring&,csize_t,Paths&);
static int mfs(CType,cstrvec&,cstring&,csize_t,Paths&);
static int newest(CType,cstrvec&,cstring&,csize_t,Paths&);
static int rand(CType,cstrvec&,cstring&,csize_t,Paths&);
static int invalid(CType,cstrvec&,cstring&,csize_t,strvec&);
static int all(CType,cstrvec&,cstring&,csize_t,strvec&);
static int epmfs(CType,cstrvec&,cstring&,csize_t,strvec&);
static int ff(CType,cstrvec&,cstring&,csize_t,strvec&);
static int ffwp(CType,cstrvec&,cstring&,csize_t,strvec&);
static int fwfs(CType,cstrvec&,cstring&,csize_t,strvec&);
static int lfs(CType,cstrvec&,cstring&,csize_t,strvec&);
static int mfs(CType,cstrvec&,cstring&,csize_t,strvec&);
static int newest(CType,cstrvec&,cstring&,csize_t,strvec&);
static int rand(CType,cstrvec&,cstring&,csize_t,strvec&);
}; };
private: private:

10
src/policy_all.cpp

@ -39,8 +39,8 @@ using std::size_t;
static static
int int
_all(const vector<string> &basepaths, _all(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
const string &fusepath,
vector<string> &paths)
{ {
int rv; int rv;
struct stat st; struct stat st;
@ -51,11 +51,11 @@ _all(const vector<string> &basepaths,
const char *basepath; const char *basepath;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st); rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0) if(rv == 0)
paths.push_back(Path(basepath,fullpath));
paths.push_back(basepath);
} }
return paths.empty() ? (errno=ENOENT,-1) : 0; return paths.empty() ? (errno=ENOENT,-1) : 0;
@ -68,7 +68,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
return _all(basepaths,fusepath,paths); return _all(basepaths,fusepath,paths);
} }

16
src/policy_epmfs.cpp

@ -122,7 +122,7 @@ static
int int
_epmfs_create(const vector<string> &basepaths, _epmfs_create(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
fsblkcnt_t epmfs; fsblkcnt_t epmfs;
@ -141,7 +141,7 @@ _epmfs_create(const vector<string> &basepaths,
int rv; int rv;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath); rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
if(rv == -1) if(rv == -1)
@ -151,8 +151,7 @@ _epmfs_create(const vector<string> &basepaths,
if(epmfsbasepath == NULL) if(epmfsbasepath == NULL)
epmfsbasepath = mfsbasepath; epmfsbasepath = mfsbasepath;
paths.push_back(Path(epmfsbasepath,
fs::make_path(epmfsbasepath,fusepath)));
paths.push_back(epmfsbasepath);
return 0; return 0;
} }
@ -161,7 +160,7 @@ static
int int
_epmfs(const vector<string> &basepaths, _epmfs(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
fsblkcnt_t epmfs; fsblkcnt_t epmfs;
@ -177,7 +176,7 @@ _epmfs(const vector<string> &basepaths,
struct statvfs fsstats; struct statvfs fsstats;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats); rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
@ -187,8 +186,7 @@ _epmfs(const vector<string> &basepaths,
if(epmfsbasepath == NULL) if(epmfsbasepath == NULL)
return (errno=ENOENT,-1); return (errno=ENOENT,-1);
paths.push_back(Path(epmfsbasepath,
fs::make_path(epmfsbasepath,fusepath)));
paths.push_back(epmfsbasepath);
return 0; return 0;
} }
@ -200,7 +198,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
if(type == Category::Enum::create) if(type == Category::Enum::create)
return _epmfs_create(basepaths,fusepath,paths); return _epmfs_create(basepaths,fusepath,paths);

8
src/policy_ff.cpp

@ -41,7 +41,7 @@ static
int int
_ff(const vector<string> &basepaths, _ff(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
for(size_t i = 0, ei = basepaths.size(); i != ei; i++) for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{ {
@ -51,13 +51,13 @@ _ff(const vector<string> &basepaths,
string fullpath; string fullpath;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st); rv = ::lstat(fullpath.c_str(),&st);
if(rv == -1) if(rv == -1)
continue; continue;
paths.push_back(Path(basepath,fullpath));
paths.push_back(basepath);
return 0; return 0;
} }
@ -72,7 +72,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
return _ff(basepaths,fusepath,paths); return _ff(basepaths,fusepath,paths);
} }

11
src/policy_ffwp.cpp

@ -40,7 +40,7 @@ static
int int
_ffwp(const vector<string> &basepaths, _ffwp(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
const char *fallback; const char *fallback;
@ -53,12 +53,12 @@ _ffwp(const vector<string> &basepaths,
string fullpath; string fullpath;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st); rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0) if(rv == 0)
{ {
paths.push_back(Path(basepath,fullpath));
paths.push_back(basepath);
return 0; return 0;
} }
else if(errno == EACCES) else if(errno == EACCES)
@ -70,8 +70,7 @@ _ffwp(const vector<string> &basepaths,
if(fallback == NULL) if(fallback == NULL)
return (errno=ENOENT,-1); return (errno=ENOENT,-1);
paths.push_back(Path(fallback,
fs::make_path(fallback,fusepath)));
paths.push_back(fallback);
return 0; return 0;
} }
@ -83,7 +82,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
return _ffwp(basepaths,fusepath,paths); return _ffwp(basepaths,fusepath,paths);
} }

13
src/policy_fwfs.cpp

@ -42,7 +42,7 @@ _fwfs_create(const Category::Enum::Type type,
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
for(size_t i = 0, size = basepaths.size(); i != size; i++) for(size_t i = 0, size = basepaths.size(); i != size; i++)
{ {
@ -60,8 +60,7 @@ _fwfs_create(const Category::Enum::Type type,
if(spaceavail < minfreespace) if(spaceavail < minfreespace)
continue; continue;
paths.push_back(Path(basepath,
fs::make_path(basepath,fusepath)));
paths.push_back(basepath);
return 0; return 0;
} }
@ -76,7 +75,7 @@ _fwfs(const Category::Enum::Type type,
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
for(size_t i = 0, size = basepaths.size(); i != size; i++) for(size_t i = 0, size = basepaths.size(); i != size; i++)
{ {
@ -86,7 +85,7 @@ _fwfs(const Category::Enum::Type type,
struct statvfs fsstats; struct statvfs fsstats;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats); rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
{ {
@ -96,7 +95,7 @@ _fwfs(const Category::Enum::Type type,
if(spaceavail < minfreespace) if(spaceavail < minfreespace)
continue; continue;
paths.push_back(Path(basepath,fullpath));
paths.push_back(basepath);
return 0; return 0;
} }
@ -112,7 +111,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
if(type == Category::Enum::create) if(type == Category::Enum::create)
return _fwfs_create(type,basepaths,fusepath,minfreespace,paths); return _fwfs_create(type,basepaths,fusepath,minfreespace,paths);

2
src/policy_invalid.cpp

@ -40,7 +40,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &rv)
vector<string> &rv)
{ {
return (errno = EINVAL,-1); return (errno = EINVAL,-1);
} }

14
src/policy_lfs.cpp

@ -45,7 +45,7 @@ _lfs_create(const Category::Enum::Type type,
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
fsblkcnt_t lfs; fsblkcnt_t lfs;
const char *lfsstr; const char *lfsstr;
@ -77,8 +77,7 @@ _lfs_create(const Category::Enum::Type type,
if(lfsstr == NULL) if(lfsstr == NULL)
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths); return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath)));
paths.push_back(lfsstr);
return 0; return 0;
} }
@ -89,7 +88,7 @@ _lfs(const Category::Enum::Type type,
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
fsblkcnt_t lfs; fsblkcnt_t lfs;
const char *lfsstr; const char *lfsstr;
@ -104,7 +103,7 @@ _lfs(const Category::Enum::Type type,
struct statvfs fsstats; struct statvfs fsstats;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats); rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
{ {
@ -123,8 +122,7 @@ _lfs(const Category::Enum::Type type,
if(lfsstr == NULL) if(lfsstr == NULL)
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths); return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath)));
paths.push_back(lfsstr);
return 0; return 0;
} }
@ -136,7 +134,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
if(type == Category::Enum::create) if(type == Category::Enum::create)
return _lfs_create(type,basepaths,fusepath,minfreespace,paths); return _lfs_create(type,basepaths,fusepath,minfreespace,paths);

16
src/policy_mfs.cpp

@ -38,7 +38,7 @@ static
int int
_mfs_create(const vector<string> &basepaths, _mfs_create(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
fsblkcnt_t mfs; fsblkcnt_t mfs;
const char *mfsstr; const char *mfsstr;
@ -69,8 +69,7 @@ _mfs_create(const vector<string> &basepaths,
if(mfsstr == NULL) if(mfsstr == NULL)
return (errno=ENOENT,-1); return (errno=ENOENT,-1);
paths.push_back(Path(mfsstr,
fs::make_path(mfsstr,fusepath)));
paths.push_back(mfsstr);
return 0; return 0;
} }
@ -78,8 +77,8 @@ _mfs_create(const vector<string> &basepaths,
static static
int int
_mfs(const vector<string> &basepaths, _mfs(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
const string &fusepath,
vector<string> &paths)
{ {
fsblkcnt_t mfs; fsblkcnt_t mfs;
const char *mfsstr; const char *mfsstr;
@ -94,7 +93,7 @@ _mfs(const vector<string> &basepaths,
struct statvfs fsstats; struct statvfs fsstats;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats); rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0) if(rv == 0)
{ {
@ -112,8 +111,7 @@ _mfs(const vector<string> &basepaths,
if(mfsstr == NULL) if(mfsstr == NULL)
return (errno=ENOENT,-1); return (errno=ENOENT,-1);
paths.push_back(Path(mfsstr,
fs::make_path(mfsstr,fusepath)));
paths.push_back(mfsstr);
return 0; return 0;
} }
@ -125,7 +123,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
if(type == Category::Enum::create) if(type == Category::Enum::create)
return _mfs_create(basepaths,fusepath,paths); return _mfs_create(basepaths,fusepath,paths);

9
src/policy_newest.cpp

@ -40,7 +40,7 @@ static
int int
_newest(const vector<string> &basepaths, _newest(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
Paths &paths)
vector<string> &paths)
{ {
time_t newest; time_t newest;
const char *neweststr; const char *neweststr;
@ -55,7 +55,7 @@ _newest(const vector<string> &basepaths,
string fullpath; string fullpath;
basepath = basepaths[i].c_str(); basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st); rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0 && st.st_mtime > newest) if(rv == 0 && st.st_mtime > newest)
@ -68,8 +68,7 @@ _newest(const vector<string> &basepaths,
if(neweststr == NULL) if(neweststr == NULL)
return (errno=ENOENT,-1); return (errno=ENOENT,-1);
paths.push_back(Path(neweststr,
fs::make_path(neweststr,fusepath)));
paths.push_back(neweststr);
return 0; return 0;
} }
@ -81,7 +80,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
return _newest(basepaths,fusepath,paths); return _newest(basepaths,fusepath,paths);
} }

2
src/policy_rand.cpp

@ -41,7 +41,7 @@ namespace mergerfs
const vector<string> &basepaths, const vector<string> &basepaths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &paths)
vector<string> &paths)
{ {
int rv; int rv;

2
src/readdir.cpp

@ -62,7 +62,7 @@ _readdir(const vector<string> &srcmounts,
DIR *dh; DIR *dh;
string basepath; string basepath;
basepath = fs::make_path(srcmounts[i],dirname);
basepath = fs::path::make(srcmounts[i],dirname);
dh = ::opendir(basepath.c_str()); dh = ::opendir(basepath.c_str());
if(!dh) if(!dh)
continue; continue;

6
src/readlink.cpp

@ -49,13 +49,15 @@ _readlink(Policy::Func::Search searchFunc,
const size_t size) const size_t size)
{ {
int rv; int rv;
Paths path;
vector<string> path;
rv = searchFunc(srcmounts,fusepath,minfreespace,path); rv = searchFunc(srcmounts,fusepath,minfreespace,path);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
rv = ::readlink(path[0].full.c_str(),buf,size);
fs::path::append(path[0],fusepath);
rv = ::readlink(path[0].c_str(),buf,size);
if(rv == -1) if(rv == -1)
return -errno; return -errno;

6
src/removexattr.cpp

@ -51,7 +51,7 @@ _removexattr(Policy::Func::Action actionFunc,
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -60,7 +60,9 @@ _removexattr(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::lremovexattr(paths[i].full.c_str(),attrname);
fs::path::append(paths[i],fusepath);
rv = ::lremovexattr(paths[i].c_str(),attrname);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

30
src/rename.cpp

@ -45,29 +45,30 @@ int
_single_rename(Policy::Func::Search searchFunc, _single_rename(Policy::Func::Search searchFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const size_t minfreespace, const size_t minfreespace,
const Path &oldpath,
const string &oldbasepath,
const string &oldfullpath,
const string &newpath) const string &newpath)
{ {
int rv; int rv;
const string fullnewpath = fs::make_path(oldpath.base,newpath);
const string newfullpath = fs::path::make(oldbasepath,newpath);
rv = ::rename(oldpath.full.c_str(),fullnewpath.c_str());
rv = ::rename(oldfullpath.c_str(),newfullpath.c_str());
if(rv == -1 && errno == ENOENT) if(rv == -1 && errno == ENOENT)
{ {
string dirname; string dirname;
Paths newpathdir;
vector<string> newpathdir;
dirname = fs::dirname(newpath);
dirname = fs::path::dirname(newpath);
rv = searchFunc(srcmounts,dirname,minfreespace,newpathdir); rv = searchFunc(srcmounts,dirname,minfreespace,newpathdir);
if(rv == -1) if(rv == -1)
return -1; return -1;
{ {
const mergerfs::ugid::SetResetGuard ugid(0,0); const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(newpathdir[0].base,oldpath.base,dirname);
fs::clonepath(newpathdir[0],oldbasepath,dirname);
} }
rv = ::rename(oldpath.full.c_str(),fullnewpath.c_str());
rv = ::rename(oldfullpath.c_str(),newfullpath.c_str());
} }
return rv; return rv;
@ -79,21 +80,24 @@ _rename(Policy::Func::Search searchFunc,
Policy::Func::Action actionFunc, Policy::Func::Action actionFunc,
const vector<string> &srcmounts, const vector<string> &srcmounts,
const size_t minfreespace, const size_t minfreespace,
const string &oldpath,
const string &newpath)
const string &oldfusepath,
const string &newfusepath)
{ {
int rv; int rv;
int error; int error;
Paths oldpaths;
vector<string> oldbasepaths;
rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths);
rv = actionFunc(srcmounts,oldfusepath,minfreespace,oldbasepaths);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
error = 0; error = 0;
for(size_t i = 0, ei = oldpaths.size(); i != ei; i++)
for(size_t i = 0, ei = oldbasepaths.size(); i != ei; i++)
{ {
rv = _single_rename(searchFunc,srcmounts,minfreespace,oldpaths[i],newpath);
const string oldfullpath = fs::path::make(oldbasepaths[i],oldfusepath);
rv = _single_rename(searchFunc,srcmounts,minfreespace,
oldbasepaths[i],oldfullpath,newfusepath);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/rmdir.cpp

@ -47,7 +47,7 @@ _rmdir(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -56,7 +56,9 @@ _rmdir(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::rmdir(paths[i].full.c_str());
fs::path::append(paths[i],fusepath);
rv = ::rmdir(paths[i].c_str());
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/setxattr.cpp

@ -252,7 +252,7 @@ _setxattr(Policy::Func::Action actionFunc,
#ifndef WITHOUT_XATTR #ifndef WITHOUT_XATTR
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -261,7 +261,9 @@ _setxattr(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::lsetxattr(paths[i].full.c_str(),attrname,attrval,attrvalsize,flags);
fs::path::append(paths[i],fusepath);
rv = ::lsetxattr(paths[i].c_str(),attrname,attrval,attrvalsize,flags);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

8
src/symlink.cpp

@ -49,9 +49,9 @@ _symlink(Policy::Func::Create createFunc,
int rv; int rv;
int error; int error;
string newpathdir; string newpathdir;
Paths newpathdirs;
vector<string> newpathdirs;
newpathdir = fs::dirname(newpath);
newpathdir = fs::path::dirname(newpath);
rv = createFunc(srcmounts,newpathdir,minfreespace,newpathdirs); rv = createFunc(srcmounts,newpathdir,minfreespace,newpathdirs);
if(rv == -1) if(rv == -1)
return -errno; return -errno;
@ -59,9 +59,9 @@ _symlink(Policy::Func::Create createFunc,
error = 0; error = 0;
for(size_t i = 0, ei = newpathdirs.size(); i != ei; i++) for(size_t i = 0, ei = newpathdirs.size(); i != ei; i++)
{ {
newpathdirs[i].full = fs::make_path(newpathdirs[i].base,newpath);
fs::path::append(newpathdirs[i],newpath);
rv = symlink(oldpath.c_str(),newpathdirs[i].full.c_str());
rv = symlink(oldpath.c_str(),newpathdirs[i].c_str());
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/truncate.cpp

@ -50,7 +50,7 @@ _truncate(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -59,7 +59,9 @@ _truncate(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::truncate(paths[i].full.c_str(),size);
fs::path::append(paths[i],fusepath);
rv = ::truncate(paths[i].c_str(),size);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/unlink.cpp

@ -48,7 +48,7 @@ _unlink(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -57,7 +57,9 @@ _unlink(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::unlink(paths[i].full.c_str());
fs::path::append(paths[i],fusepath);
rv = ::unlink(paths[i].c_str());
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

6
src/utimens.cpp

@ -50,7 +50,7 @@ _utimens(Policy::Func::Action actionFunc,
{ {
int rv; int rv;
int error; int error;
Paths paths;
vector<string> paths;
rv = actionFunc(srcmounts,fusepath,minfreespace,paths); rv = actionFunc(srcmounts,fusepath,minfreespace,paths);
if(rv == -1) if(rv == -1)
@ -59,7 +59,9 @@ _utimens(Policy::Func::Action actionFunc,
error = 0; error = 0;
for(size_t i = 0, ei = paths.size(); i != ei; i++) for(size_t i = 0, ei = paths.size(); i != ei; i++)
{ {
rv = ::utimensat(0,paths[i].full.c_str(),ts,AT_SYMLINK_NOFOLLOW);
fs::path::append(paths[i],fusepath);
rv = ::utimensat(0,paths[i].c_str(),ts,AT_SYMLINK_NOFOLLOW);
if(rv == -1) if(rv == -1)
error = errno; error = errno;
} }

Loading…
Cancel
Save