mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-04-21 12:31:43 +00:00
create lfs policy. closes #73
This commit is contained in:
+43
@@ -663,6 +663,49 @@ namespace fs
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
lfs(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, 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(basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
paths.push_back(Path(lfsstr,
|
||||
fs::make_path(lfsstr,fusepath)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
mfs(const vector<string> &basepaths,
|
||||
const string &fusepath,
|
||||
|
||||
Reference in New Issue
Block a user