mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-03-15 02:35:12 +08:00
commit
23cca83742
43
src/fs.cpp
43
src/fs.cpp
@ -663,6 +663,49 @@ namespace fs
|
|||||||
return -1;
|
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
|
int
|
||||||
mfs(const vector<string> &basepaths,
|
mfs(const vector<string> &basepaths,
|
||||||
const string &fusepath,
|
const string &fusepath,
|
||||||
|
@ -148,6 +148,10 @@ namespace fs
|
|||||||
const string &fusepath,
|
const string &fusepath,
|
||||||
const size_t minfreespace,
|
const size_t minfreespace,
|
||||||
Paths &path);
|
Paths &path);
|
||||||
|
int lfs(const vector<string> &paths,
|
||||||
|
const string &fusepath,
|
||||||
|
const size_t minfreespace,
|
||||||
|
Paths &path);
|
||||||
int mfs(const vector<string> &paths,
|
int mfs(const vector<string> &paths,
|
||||||
const string &fusepath,
|
const string &fusepath,
|
||||||
const size_t minfreespace,
|
const size_t minfreespace,
|
||||||
|
@ -40,6 +40,7 @@ namespace mergerfs
|
|||||||
(POLICY(ff))
|
(POLICY(ff))
|
||||||
(POLICY(ffwp))
|
(POLICY(ffwp))
|
||||||
(POLICY(fwfs))
|
(POLICY(fwfs))
|
||||||
|
(POLICY(lfs))
|
||||||
(POLICY(mfs))
|
(POLICY(mfs))
|
||||||
(POLICY(newest))
|
(POLICY(newest))
|
||||||
(POLICY(rand));
|
(POLICY(rand));
|
||||||
@ -52,6 +53,7 @@ namespace mergerfs
|
|||||||
const Policy &Policy::ff = Policy::policies[Policy::Enum::ff];
|
const Policy &Policy::ff = Policy::policies[Policy::Enum::ff];
|
||||||
const Policy &Policy::ffwp = Policy::policies[Policy::Enum::ffwp];
|
const Policy &Policy::ffwp = Policy::policies[Policy::Enum::ffwp];
|
||||||
const Policy &Policy::fwfs = Policy::policies[Policy::Enum::fwfs];
|
const Policy &Policy::fwfs = Policy::policies[Policy::Enum::fwfs];
|
||||||
|
const Policy &Policy::lfs = Policy::policies[Policy::Enum::lfs];
|
||||||
const Policy &Policy::mfs = Policy::policies[Policy::Enum::mfs];
|
const Policy &Policy::mfs = Policy::policies[Policy::Enum::mfs];
|
||||||
const Policy &Policy::newest = Policy::policies[Policy::Enum::newest];
|
const Policy &Policy::newest = Policy::policies[Policy::Enum::newest];
|
||||||
const Policy &Policy::rand = Policy::policies[Policy::Enum::rand];
|
const Policy &Policy::rand = Policy::policies[Policy::Enum::rand];
|
||||||
|
@ -46,6 +46,7 @@ namespace mergerfs
|
|||||||
ff,
|
ff,
|
||||||
ffwp,
|
ffwp,
|
||||||
fwfs,
|
fwfs,
|
||||||
|
lfs,
|
||||||
mfs,
|
mfs,
|
||||||
newest,
|
newest,
|
||||||
rand,
|
rand,
|
||||||
@ -107,6 +108,7 @@ namespace mergerfs
|
|||||||
static const Policy &ff;
|
static const Policy &ff;
|
||||||
static const Policy &ffwp;
|
static const Policy &ffwp;
|
||||||
static const Policy &fwfs;
|
static const Policy &fwfs;
|
||||||
|
static const Policy &lfs;
|
||||||
static const Policy &mfs;
|
static const Policy &mfs;
|
||||||
static const Policy &newest;
|
static const Policy &newest;
|
||||||
static const Policy &rand;
|
static const Policy &rand;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user