Browse Source

create different policies based on category of use

pull/78/head
Antonio SJ Musumeci 10 years ago
parent
commit
0c60701b29
  1. 5
      src/chmod.cpp
  2. 5
      src/chown.cpp
  3. 5
      src/link.cpp
  4. 11
      src/mkdir.cpp
  5. 11
      src/mknod.cpp
  6. 43
      src/policy_all.cpp
  7. 215
      src/policy_epmfs.cpp
  8. 50
      src/policy_ff.cpp
  9. 72
      src/policy_ffwp.cpp
  10. 98
      src/policy_fwfs.cpp
  11. 130
      src/policy_lfs.cpp
  12. 120
      src/policy_mfs.cpp
  13. 69
      src/policy_newest.cpp
  14. 7
      src/readdir.cpp
  15. 5
      src/removexattr.cpp
  16. 5
      src/rename.cpp
  17. 5
      src/rmdir.cpp
  18. 5
      src/setxattr.cpp
  19. 4
      src/statfs.cpp
  20. 7
      src/symlink.cpp
  21. 5
      src/truncate.cpp
  22. 5
      src/unlink.cpp
  23. 5
      src/utimens.cpp

5
src/chmod.cpp

@ -54,10 +54,9 @@ _chmod(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::chmod(i->full.c_str(),mode);
rv = ::chmod(paths[i].full.c_str(),mode);
if(rv == -1)
error = errno;
}

5
src/chown.cpp

@ -56,10 +56,9 @@ _chown(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::lchown(i->full.c_str(),uid,gid);
rv = ::lchown(paths[i].full.c_str(),uid,gid);
if(rv == -1)
error = errno;
}

5
src/link.cpp

@ -92,10 +92,9 @@ _link(Policy::Func::Search searchFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i)
for(size_t i = 0, ei = oldpaths.size(); i != ei; i++)
{
rv = _single_link(searchFunc,srcmounts,minfreespace,i->base,oldpath,newpath);
rv = _single_link(searchFunc,srcmounts,minfreespace,oldpaths[i].base,oldpath,newpath);
if(rv == -1)
error = errno;
}

11
src/mkdir.cpp

@ -66,16 +66,17 @@ _mkdir(Policy::Func::Search searchFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = createpaths.begin(), ei = createpaths.end(); i != ei; ++i)
for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
{
if(i->base != existingpath[0].base)
const string &createpath = createpaths[i].base;
if(createpath != existingpath[0].base)
{
const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(existingpath[0].base,i->base,dirname);
fs::clonepath(existingpath[0].base,createpath,dirname);
}
fullpath = fs::make_path(i->base,fusepath);
fullpath = fs::make_path(createpath,fusepath);
rv = ::mkdir(fullpath.c_str(),mode);
if(rv == -1)

11
src/mknod.cpp

@ -69,16 +69,17 @@ _mknod(Policy::Func::Search searchFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = createpaths.begin(), ei = createpaths.end(); i != ei; ++i)
for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
{
if(i->base != existingpath[0].base)
const string &createpath = createpaths[0].base;
if(createpath != existingpath[0].base)
{
const mergerfs::ugid::SetResetGuard ugid(0,0);
fs::clonepath(existingpath[0].base,i->base,dirname);
fs::clonepath(existingpath[0].base,createpath,dirname);
}
fullpath = fs::make_path(i->base,fusepath);
fullpath = fs::make_path(createpath,fusepath);
rv = ::mknod(fullpath.c_str(),mode,dev);
if(rv == -1)

43
src/policy_all.cpp

@ -36,6 +36,31 @@ using std::string;
using std::vector;
using std::size_t;
static
int
_all(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
int rv;
struct stat st;
string fullpath;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
const char *basepath;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
paths.push_back(Path(basepath,fullpath));
}
return paths.empty() ? (errno=ENOENT,-1) : 0;
}
namespace mergerfs
{
int
@ -45,22 +70,6 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
int rv;
struct stat st;
string fullpath;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
fullpath = fs::make_path(*iter,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
paths.push_back(Path(*iter,fullpath));
}
return paths.empty() ? (errno=ENOENT,-1) : 0;
return _all(basepaths,fusepath,paths);
}
}

215
src/policy_epmfs.cpp

@ -37,6 +37,162 @@ using std::string;
using std::vector;
using std::size_t;
static
inline
void
_calc_epmfs(const struct statvfs &fsstats,
const char *basepath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > epmfs)
{
epmfs = spaceavail;
epmfsbasepath = basepath;
}
if(spaceavail > mfs)
{
mfs = spaceavail;
mfsbasepath = basepath;
}
}
static
inline
void
_calc_mfs(const struct statvfs &fsstats,
const char *basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > mfs)
{
mfs = spaceavail;
mfsbasepath = basepath;
}
}
static
inline
int
_try_statvfs(const char *basepath,
const string &fullpath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
{
int rv;
struct statvfs fsstats;
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
_calc_epmfs(fsstats,basepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
return rv;
}
static
inline
int
_try_statvfs(const char *basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
{
int rv;
struct statvfs fsstats;
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
_calc_mfs(fsstats,basepath,mfs,mfsbasepath);
return rv;
}
static
int
_epmfs_create(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
fsblkcnt_t epmfs;
fsblkcnt_t mfs;
const char *basepath;
const char *mfsbasepath;
const char *epmfsbasepath;
string fullpath;
mfs = 0;
epmfs = 0;
mfsbasepath = NULL;
epmfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
if(rv == -1)
_try_statvfs(basepath,mfs,mfsbasepath);
}
if(epmfsbasepath == NULL)
epmfsbasepath = mfsbasepath;
paths.push_back(Path(epmfsbasepath,
fs::make_path(epmfsbasepath,fusepath)));
return 0;
}
static
int
_epmfs(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
fsblkcnt_t epmfs;
const char *basepath;
const char *epmfsbasepath;
string fullpath;
epmfs = 0;
epmfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
_calc_mfs(fsstats,basepath,epmfs,epmfsbasepath);
}
if(epmfsbasepath == NULL)
return (errno=ENOENT,-1);
paths.push_back(Path(epmfsbasepath,
fs::make_path(epmfsbasepath,fusepath)));
return 0;
}
namespace mergerfs
{
int
@ -46,60 +202,9 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
fsblkcnt_t existingmfs;
fsblkcnt_t generalmfs;
string fullpath;
string generalmfspath;
string existingmfspath;
vector<string>::const_iterator iter = basepaths.begin();
vector<string>::const_iterator eiter = basepaths.end();
if(iter == eiter)
return (errno = ENOENT,-1);
existingmfs = 0;
generalmfs = 0;
do
{
int rv;
struct statvfs fsstats;
const string &mountpoint = *iter;
rv = ::statvfs(mountpoint.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
struct stat st;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > generalmfs)
{
generalmfs = spaceavail;
generalmfspath = mountpoint;
}
fullpath = fs::make_path(mountpoint,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
{
if(spaceavail > existingmfs)
{
existingmfs = spaceavail;
existingmfspath = mountpoint;
}
}
}
++iter;
}
while(iter != eiter);
if(existingmfspath.empty())
existingmfspath = generalmfspath;
paths.push_back(Path(existingmfspath,
fullpath));
return 0;
if(type == Category::Enum::create)
return _epmfs_create(basepaths,fusepath,paths);
return _epmfs(basepaths,fusepath,paths);
}
}

50
src/policy_ff.cpp

@ -37,6 +37,34 @@ using std::string;
using std::vector;
using std::size_t;
static
int
_ff(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == -1)
continue;
paths.push_back(Path(basepath,fullpath));
return 0;
}
return (errno=ENOENT,-1);
}
namespace mergerfs
{
int
@ -46,26 +74,6 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
struct stat st;
string fullpath;
fullpath = fs::make_path(*iter,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
{
paths.push_back(Path(*iter,fullpath));
return 0;
}
}
return -1;
return _ff(basepaths,fusepath,paths);
}
}

72
src/policy_ffwp.cpp

@ -36,6 +36,46 @@ using std::string;
using std::vector;
using std::size_t;
static
int
_ffwp(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
const char *fallback;
fallback = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
{
paths.push_back(Path(basepath,fullpath));
return 0;
}
else if(errno == EACCES)
{
fallback = basepath;
}
}
if(fallback == NULL)
return (errno=ENOENT,-1);
paths.push_back(Path(fallback,
fs::make_path(fallback,fusepath)));
return 0;
}
namespace mergerfs
{
int
@ -45,36 +85,6 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
Path fallback;
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
struct stat st;
string fullpath;
fullpath = fs::make_path(*iter,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0)
{
paths.push_back(Path(*iter,fullpath));
return 0;
}
else if(errno == EACCES)
{
fallback.base = *iter;
fallback.full = fullpath;
}
}
if(!fallback.base.empty())
return (paths.push_back(fallback),0);
return -1;
return _ffwp(basepaths,fusepath,paths);
}
}

98
src/policy_fwfs.cpp

@ -33,6 +33,77 @@
using std::string;
using std::vector;
using std::size_t;
using mergerfs::Policy;
using mergerfs::Category;
static
int
_fwfs_create(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
for(size_t i = 0, size = basepaths.size(); i != size; i++)
{
int rv;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail < minfreespace)
continue;
paths.push_back(Path(basepath,
fs::make_path(basepath,fusepath)));
return 0;
}
}
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
}
static
int
_fwfs(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
for(size_t i = 0, size = basepaths.size(); i != size; i++)
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail < minfreespace)
continue;
paths.push_back(Path(basepath,fullpath));
return 0;
}
}
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
}
namespace mergerfs
{
@ -43,28 +114,9 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
for(size_t i = 0, size = basepaths.size(); i != size; i++)
{
int rv;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > minfreespace)
{
paths.push_back(Path(basepath,
fs::make_path(basepath,fusepath)));
return 0;
}
}
}
return mfs(type,basepaths,fusepath,minfreespace,paths);
if(type == Category::Enum::create)
return _fwfs_create(type,basepaths,fusepath,minfreespace,paths);
return _fwfs(type,basepaths,fusepath,minfreespace,paths);
}
}

130
src/policy_lfs.cpp

@ -36,6 +36,98 @@
using std::string;
using std::vector;
using std::size_t;
using mergerfs::Policy;
using mergerfs::Category;
static
int
_lfs_create(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
lfs = -1;
lfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if((spaceavail > minfreespace) &&
(spaceavail < lfs))
{
lfs = spaceavail;
lfsstr = basepath;
}
}
}
if(lfsstr == NULL)
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath)));
return 0;
}
static
int
_lfs(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
lfs = -1;
lfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if((spaceavail > minfreespace) &&
(spaceavail < lfs))
{
lfs = spaceavail;
lfsstr = basepath;
}
}
}
if(lfsstr == NULL)
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath)));
return 0;
}
namespace mergerfs
{
@ -46,39 +138,9 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
lfs = -1;
lfsstr = NULL;
for(size_t i = 0, size = basepaths.size(); i != size; i++)
{
int rv;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if((spaceavail > minfreespace) &&
(spaceavail < lfs))
{
lfs = spaceavail;
lfsstr = basepath;
}
}
}
if(lfsstr == NULL)
return mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath)));
return 0;
if(type == Category::Enum::create)
return _lfs_create(type,basepaths,fusepath,minfreespace,paths);
return _lfs(type,basepaths,fusepath,minfreespace,paths);
}
}

120
src/policy_mfs.cpp

@ -34,6 +34,90 @@ using std::string;
using std::vector;
using std::size_t;
static
int
_mfs_create(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
mfs = 0;
mfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
rv = ::statvfs(basepath,&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > mfs)
{
mfs = spaceavail;
mfsstr = basepath;
}
}
}
if(mfsstr == NULL)
return (errno=ENOENT,-1);
paths.push_back(Path(mfsstr,
fs::make_path(mfsstr,fusepath)));
return 0;
}
static
int
_mfs(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
mfs = 0;
mfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > mfs)
{
mfs = spaceavail;
mfsstr = basepath;
}
}
}
if(mfsstr == NULL)
return (errno=ENOENT,-1);
paths.push_back(Path(mfsstr,
fs::make_path(mfsstr,fusepath)));
return 0;
}
namespace mergerfs
{
int
@ -43,37 +127,9 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
fsblkcnt_t mfs;
size_t mfsidx;
mfs = 0;
for(size_t i = 0, size = basepaths.size();
i != size;
i++)
{
int rv;
struct statvfs fsstats;
rv = ::statvfs(basepaths[i].c_str(),&fsstats);
if(rv == 0)
{
fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > mfs)
{
mfs = spaceavail;
mfsidx = i;
}
}
}
if(mfs == 0)
return (errno=ENOENT,-1);
paths.push_back(Path(basepaths[mfsidx],
fs::make_path(basepaths[mfsidx],fusepath)));
return 0;
if(type == Category::Enum::create)
return _mfs_create(basepaths,fusepath,paths);
return _mfs(basepaths,fusepath,paths);
}
}

69
src/policy_newest.cpp

@ -36,6 +36,44 @@ using std::string;
using std::vector;
using std::size_t;
static
int
_newest(const vector<string> &basepaths,
const string &fusepath,
Paths &paths)
{
time_t newest;
const char *neweststr;
newest = 0;
neweststr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
basepath = basepaths[i].c_str();
fullpath = fs::make_path(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0 && st.st_mtime > newest)
{
newest = st.st_mtime;
neweststr = basepath;
}
}
if(neweststr == NULL)
return (errno=ENOENT,-1);
paths.push_back(Path(neweststr,
fs::make_path(neweststr,fusepath)));
return 0;
}
namespace mergerfs
{
int
@ -45,35 +83,6 @@ namespace mergerfs
const size_t minfreespace,
Paths &paths)
{
time_t newest;
string npath;
vector<string>::const_iterator niter;
newest = 0;
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
++iter)
{
int rv;
struct stat st;
string fullpath;
fullpath = fs::make_path(*iter,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
if(rv == 0 && st.st_mtime > newest)
{
newest = st.st_mtime;
niter = iter;
npath = fullpath;
}
}
if(newest)
return (paths.push_back(Path(*niter,npath)),0);
return -1;
return _newest(basepaths,fusepath,paths);
}
}

7
src/readdir.cpp

@ -57,15 +57,12 @@ _readdir(const vector<string> &srcmounts,
set<string> found;
struct stat st = {0};
for(vector<string>::const_iterator
iter = srcmounts.begin(), enditer = srcmounts.end();
iter != enditer;
++iter)
for(size_t i = 0, ei = srcmounts.size(); i != ei; i++)
{
DIR *dh;
string basepath;
basepath = fs::make_path(*iter,dirname);
basepath = fs::make_path(srcmounts[i],dirname);
dh = ::opendir(basepath.c_str());
if(!dh)
continue;

5
src/removexattr.cpp

@ -58,10 +58,9 @@ _removexattr(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::lremovexattr(i->full.c_str(),attrname);
rv = ::lremovexattr(paths[i].full.c_str(),attrname);
if(rv == -1)
error = errno;
}

5
src/rename.cpp

@ -91,10 +91,9 @@ _rename(Policy::Func::Search searchFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i)
for(size_t i = 0, ei = oldpaths.size(); i != ei; i++)
{
rv = _single_rename(searchFunc,srcmounts,minfreespace,*i,newpath);
rv = _single_rename(searchFunc,srcmounts,minfreespace,oldpaths[i],newpath);
if(rv == -1)
error = errno;
}

5
src/rmdir.cpp

@ -54,10 +54,9 @@ _rmdir(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::rmdir(i->full.c_str());
rv = ::rmdir(paths[i].full.c_str());
if(rv == -1)
error = errno;
}

5
src/setxattr.cpp

@ -259,10 +259,9 @@ _setxattr(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::lsetxattr(i->full.c_str(),attrname,attrval,attrvalsize,flags);
rv = ::lsetxattr(paths[i].full.c_str(),attrname,attrval,attrvalsize,flags);
if(rv == -1)
error = errno;
}

4
src/statfs.cpp

@ -82,11 +82,11 @@ _statfs(const vector<string> &srcmounts,
vector<string>::const_iterator iter;
vector<string>::const_iterator enditer;
for(iter = srcmounts.begin(), enditer = srcmounts.end(); iter != enditer; ++iter)
for(size_t i = 0, ei = srcmounts.size(); i != ei; i++)
{
int rv;
struct statvfs fsstat;
rv = ::statvfs(iter->c_str(),&fsstat);
rv = ::statvfs(srcmounts[i].c_str(),&fsstat);
if(rv != 0)
continue;

7
src/symlink.cpp

@ -57,12 +57,11 @@ _symlink(Policy::Func::Create createFunc,
return -errno;
error = 0;
for(Paths::iterator
i = newpathdirs.begin(), ei = newpathdirs.end(); i != ei; ++i)
for(size_t i = 0, ei = newpathdirs.size(); i != ei; i++)
{
i->full = fs::make_path(i->base,newpath);
newpathdirs[i].full = fs::make_path(newpathdirs[i].base,newpath);
rv = symlink(oldpath.c_str(),i->full.c_str());
rv = symlink(oldpath.c_str(),newpathdirs[i].full.c_str());
if(rv == -1)
error = errno;
}

5
src/truncate.cpp

@ -57,10 +57,9 @@ _truncate(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::truncate(i->full.c_str(),size);
rv = ::truncate(paths[i].full.c_str(),size);
if(rv == -1)
error = errno;
}

5
src/unlink.cpp

@ -55,10 +55,9 @@ _unlink(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::unlink(i->full.c_str());
rv = ::unlink(paths[i].full.c_str());
if(rv == -1)
error = errno;
}

5
src/utimens.cpp

@ -57,10 +57,9 @@ _utimens(Policy::Func::Action actionFunc,
return -errno;
error = 0;
for(Paths::const_iterator
i = paths.begin(), ei = paths.end(); i != ei; ++i)
for(size_t i = 0, ei = paths.size(); i != ei; i++)
{
rv = ::utimensat(0,i->full.c_str(),ts,AT_SYMLINK_NOFOLLOW);
rv = ::utimensat(0,paths[i].full.c_str(),ts,AT_SYMLINK_NOFOLLOW);
if(rv == -1)
error = errno;
}

Loading…
Cancel
Save