mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-04-21 12:31:43 +00:00
first w/ free space policy. closes #72
This commit is contained in:
+31
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user