mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-02 01:18:10 +08:00
Merge pull request #75 from trapexit/fwfs
first w/ free space policy. closes #72
This commit is contained in:
commit
9ea4bf2828
31
src/fs.cpp
31
src/fs.cpp
|
@ -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,
|
||||
|
|
|
@ -140,6 +140,10 @@ namespace fs
|
|||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &path);
|
||||
int fwfs(const vector<string> &paths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
Paths &path);
|
||||
int newest(const vector<string> &paths,
|
||||
const string &fusepath,
|
||||
const size_t minfreespace,
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace mergerfs
|
|||
(POLICY(epmfs))
|
||||
(POLICY(ff))
|
||||
(POLICY(ffwp))
|
||||
(POLICY(fwfs))
|
||||
(POLICY(mfs))
|
||||
(POLICY(newest))
|
||||
(POLICY(rand));
|
||||
|
@ -50,6 +51,7 @@ namespace mergerfs
|
|||
const Policy &Policy::epmfs = Policy::policies[Policy::Enum::epmfs];
|
||||
const Policy &Policy::ff = Policy::policies[Policy::Enum::ff];
|
||||
const Policy &Policy::ffwp = Policy::policies[Policy::Enum::ffwp];
|
||||
const Policy &Policy::fwfs = Policy::policies[Policy::Enum::fwfs];
|
||||
const Policy &Policy::mfs = Policy::policies[Policy::Enum::mfs];
|
||||
const Policy &Policy::newest = Policy::policies[Policy::Enum::newest];
|
||||
const Policy &Policy::rand = Policy::policies[Policy::Enum::rand];
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace mergerfs
|
|||
epmfs,
|
||||
ff,
|
||||
ffwp,
|
||||
fwfs,
|
||||
mfs,
|
||||
newest,
|
||||
rand,
|
||||
|
@ -105,6 +106,7 @@ namespace mergerfs
|
|||
static const Policy &epmfs;
|
||||
static const Policy &ff;
|
||||
static const Policy &ffwp;
|
||||
static const Policy &fwfs;
|
||||
static const Policy &mfs;
|
||||
static const Policy &newest;
|
||||
static const Policy &rand;
|
||||
|
|
Loading…
Reference in New Issue
Block a user