mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
rework policy code
This commit is contained in:
parent
345d0bbdc4
commit
aab90b0503
35 changed files with 983 additions and 991 deletions
|
|
@ -43,31 +43,31 @@ using mergerfs::Policy;
|
|||
|
||||
static
|
||||
int
|
||||
_mkdir(const Policy::Search::Func searchFunc,
|
||||
const Policy::Create::Func createPathFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const mode_t mode)
|
||||
_mkdir(const fs::SearchFunc searchFunc,
|
||||
const fs::SearchFunc createPathFunc,
|
||||
const vector<string> &srcmounts,
|
||||
const string fusepath,
|
||||
const mode_t mode)
|
||||
{
|
||||
int rv;
|
||||
string path;
|
||||
string dirname;
|
||||
fs::Path createpath;
|
||||
fs::Path existingpath;
|
||||
fs::PathVector createpath;
|
||||
fs::PathVector existingpath;
|
||||
|
||||
if(fs::path_exists(srcmounts,fusepath))
|
||||
return -EEXIST;
|
||||
|
||||
dirname = fs::dirname(fusepath);
|
||||
existingpath = searchFunc(srcmounts,dirname);
|
||||
if(existingpath.base.empty())
|
||||
searchFunc(srcmounts,dirname,existingpath);
|
||||
if(existingpath.empty())
|
||||
return -ENOENT;
|
||||
|
||||
createpath = createPathFunc(srcmounts,dirname);
|
||||
if(createpath.base != existingpath.base)
|
||||
fs::clonepath(existingpath.base,createpath.base,dirname);
|
||||
createPathFunc(srcmounts,dirname,createpath);
|
||||
if(createpath[0].base != existingpath[0].base)
|
||||
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);
|
||||
|
||||
path = fs::make_path(createpath.base,fusepath);
|
||||
path = fs::make_path(createpath[0].base,fusepath);
|
||||
|
||||
rv = ::mkdir(path.c_str(),mode);
|
||||
|
||||
|
|
@ -88,8 +88,8 @@ namespace mergerfs
|
|||
if(fusepath == config.controlfile)
|
||||
return -EEXIST;
|
||||
|
||||
return _mkdir(config.policy.search,
|
||||
config.policy.create,
|
||||
return _mkdir(*config.search,
|
||||
*config.create,
|
||||
config.srcmounts,
|
||||
fusepath,
|
||||
mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue