first w/ free space policy. closes #72

This commit is contained in:
Antonio SJ Musumeci
2015-06-22 10:53:39 -04:00
parent 6578b93190
commit 58167c3636
4 changed files with 39 additions and 0 deletions
+31
View File
@@ -594,6 +594,37 @@ namespace fs
return -1;
}
int
fwfs(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)
{
paths.push_back(Path(basepath,
fs::make_path(basepath,fusepath)));
return 0;
}
}
}
return mfs(basepaths,fusepath,minfreespace,paths);
}
int
newest(const vector<string> &basepaths,
const string &fusepath,