Browse Source

Merge pull request #75 from trapexit/fwfs

first w/ free space policy. closes #72
pull/76/head
Antonio SJ Musumeci 10 years ago
parent
commit
9ea4bf2828
  1. 31
      src/fs.cpp
  2. 4
      src/fs.hpp
  3. 2
      src/policy.cpp
  4. 2
      src/policy.hpp

31
src/fs.cpp

@ -594,6 +594,37 @@ namespace fs
return -1; 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 int
newest(const vector<string> &basepaths, newest(const vector<string> &basepaths,
const string &fusepath, const string &fusepath,

4
src/fs.hpp

@ -140,6 +140,10 @@ namespace fs
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,
Paths &path); Paths &path);
int fwfs(const vector<string> &paths,
const string &fusepath,
const size_t minfreespace,
Paths &path);
int newest(const vector<string> &paths, int newest(const vector<string> &paths,
const string &fusepath, const string &fusepath,
const size_t minfreespace, const size_t minfreespace,

2
src/policy.cpp

@ -39,6 +39,7 @@ namespace mergerfs
(POLICY(epmfs)) (POLICY(epmfs))
(POLICY(ff)) (POLICY(ff))
(POLICY(ffwp)) (POLICY(ffwp))
(POLICY(fwfs))
(POLICY(mfs)) (POLICY(mfs))
(POLICY(newest)) (POLICY(newest))
(POLICY(rand)); (POLICY(rand));
@ -50,6 +51,7 @@ namespace mergerfs
const Policy &Policy::epmfs = Policy::policies[Policy::Enum::epmfs]; const Policy &Policy::epmfs = Policy::policies[Policy::Enum::epmfs];
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::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];

2
src/policy.hpp

@ -45,6 +45,7 @@ namespace mergerfs
epmfs, epmfs,
ff, ff,
ffwp, ffwp,
fwfs,
mfs, mfs,
newest, newest,
rand, rand,
@ -105,6 +106,7 @@ namespace mergerfs
static const Policy &epmfs; static const Policy &epmfs;
static const Policy &ff; static const Policy &ff;
static const Policy &ffwp; static const Policy &ffwp;
static const Policy &fwfs;
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…
Cancel
Save