create different policies based on category of use

This commit is contained in:
Antonio SJ Musumeci 2015-06-30 23:35:28 -04:00
parent 51b6d3f647
commit 0c60701b29
23 changed files with 589 additions and 290 deletions

View File

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

View File

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

View File

@ -92,10 +92,9 @@ _link(Policy::Func::Search searchFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::const_iterator for(size_t i = 0, ei = oldpaths.size(); i != ei; i++)
i = oldpaths.begin(), ei = oldpaths.end(); 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) if(rv == -1)
error = errno; error = errno;
} }

View File

@ -66,16 +66,17 @@ _mkdir(Policy::Func::Search searchFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::const_iterator for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
i = createpaths.begin(), ei = createpaths.end(); 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); 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); rv = ::mkdir(fullpath.c_str(),mode);
if(rv == -1) if(rv == -1)

View File

@ -69,16 +69,17 @@ _mknod(Policy::Func::Search searchFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::const_iterator for(size_t i = 0, ei = createpaths.size(); i != ei; i++)
i = createpaths.begin(), ei = createpaths.end(); 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); 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); rv = ::mknod(fullpath.c_str(),mode,dev);
if(rv == -1) if(rv == -1)

View File

@ -36,6 +36,31 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -45,22 +70,6 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
int rv; return _all(basepaths,fusepath,paths);
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;
} }
} }

View File

@ -37,6 +37,162 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -46,60 +202,9 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
fsblkcnt_t existingmfs; if(type == Category::Enum::create)
fsblkcnt_t generalmfs; return _epmfs_create(basepaths,fusepath,paths);
string fullpath;
string generalmfspath;
string existingmfspath;
vector<string>::const_iterator iter = basepaths.begin();
vector<string>::const_iterator eiter = basepaths.end();
if(iter == eiter) return _epmfs(basepaths,fusepath,paths);
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;
} }
} }

View File

@ -37,6 +37,34 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -46,26 +74,6 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
errno = ENOENT; return _ff(basepaths,fusepath,paths);
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;
} }
} }

View File

@ -36,6 +36,46 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -45,36 +85,6 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
Path fallback; return _ffwp(basepaths,fusepath,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;
}
else if(errno == EACCES)
{
fallback.base = *iter;
fallback.full = fullpath;
}
}
if(!fallback.base.empty())
return (paths.push_back(fallback),0);
return -1;
} }
} }

View File

@ -33,11 +33,12 @@
using std::string; using std::string;
using std::vector; using std::vector;
using std::size_t; using std::size_t;
using mergerfs::Policy;
using mergerfs::Category;
namespace mergerfs static
{
int int
Policy::Func::fwfs(const Category::Enum::Type type, _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,
@ -56,15 +57,66 @@ namespace mergerfs
fsblkcnt_t spaceavail; fsblkcnt_t spaceavail;
spaceavail = (fsstats.f_frsize * fsstats.f_bavail); spaceavail = (fsstats.f_frsize * fsstats.f_bavail);
if(spaceavail > minfreespace) if(spaceavail < minfreespace)
{ continue;
paths.push_back(Path(basepath, paths.push_back(Path(basepath,
fs::make_path(basepath,fusepath))); fs::make_path(basepath,fusepath)));
return 0; return 0;
} }
} }
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
} }
return 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
{
int
Policy::Func::fwfs(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
if(type == Category::Enum::create)
return _fwfs_create(type,basepaths,fusepath,minfreespace,paths);
return _fwfs(type,basepaths,fusepath,minfreespace,paths);
} }
} }

View File

@ -36,11 +36,12 @@
using std::string; using std::string;
using std::vector; using std::vector;
using std::size_t; using std::size_t;
using mergerfs::Policy;
using mergerfs::Category;
namespace mergerfs static
{
int int
Policy::Func::lfs(const Category::Enum::Type type, _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,
@ -51,7 +52,7 @@ namespace mergerfs
lfs = -1; lfs = -1;
lfsstr = NULL; lfsstr = NULL;
for(size_t i = 0, size = basepaths.size(); i != size; i++) for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{ {
int rv; int rv;
const char *basepath; const char *basepath;
@ -74,11 +75,72 @@ namespace mergerfs
} }
if(lfsstr == NULL) if(lfsstr == NULL)
return mfs(type,basepaths,fusepath,minfreespace,paths); return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
paths.push_back(Path(lfsstr, paths.push_back(Path(lfsstr,
fs::make_path(lfsstr,fusepath))); fs::make_path(lfsstr,fusepath)));
return 0; 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
{
int
Policy::Func::lfs(const Category::Enum::Type type,
const vector<string> &basepaths,
const string &fusepath,
const size_t minfreespace,
Paths &paths)
{
if(type == Category::Enum::create)
return _lfs_create(type,basepaths,fusepath,minfreespace,paths);
return _lfs(type,basepaths,fusepath,minfreespace,paths);
}
} }

View File

@ -34,6 +34,90 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -43,37 +127,9 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
fsblkcnt_t mfs; if(type == Category::Enum::create)
size_t mfsidx; return _mfs_create(basepaths,fusepath,paths);
mfs = 0; return _mfs(basepaths,fusepath,paths);
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;
} }
} }

View File

@ -36,6 +36,44 @@ using std::string;
using std::vector; using std::vector;
using std::size_t; 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 namespace mergerfs
{ {
int int
@ -45,35 +83,6 @@ namespace mergerfs
const size_t minfreespace, const size_t minfreespace,
Paths &paths) Paths &paths)
{ {
time_t newest; return _newest(basepaths,fusepath,paths);
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;
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -259,10 +259,9 @@ _setxattr(Policy::Func::Action actionFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::const_iterator for(size_t i = 0, ei = paths.size(); i != ei; i++)
i = paths.begin(), ei = paths.end(); 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) if(rv == -1)
error = errno; error = errno;
} }

View File

@ -82,11 +82,11 @@ _statfs(const vector<string> &srcmounts,
vector<string>::const_iterator iter; vector<string>::const_iterator iter;
vector<string>::const_iterator enditer; 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; int rv;
struct statvfs fsstat; struct statvfs fsstat;
rv = ::statvfs(iter->c_str(),&fsstat); rv = ::statvfs(srcmounts[i].c_str(),&fsstat);
if(rv != 0) if(rv != 0)
continue; continue;

View File

@ -57,12 +57,11 @@ _symlink(Policy::Func::Create createFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::iterator for(size_t i = 0, ei = newpathdirs.size(); i != ei; i++)
i = newpathdirs.begin(), ei = newpathdirs.end(); 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) if(rv == -1)
error = errno; error = errno;
} }

View File

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

View File

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

View File

@ -57,10 +57,9 @@ _utimens(Policy::Func::Action actionFunc,
return -errno; return -errno;
error = 0; error = 0;
for(Paths::const_iterator for(size_t i = 0, ei = paths.size(); i != ei; i++)
i = paths.begin(), ei = paths.end(); 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) if(rv == -1)
error = errno; error = errno;
} }