mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-22 16:26:33 +08:00
commit
47bf58eae9
@ -84,19 +84,17 @@ _create(Policy::Func::Search searchFunc,
|
||||
int rv;
|
||||
string fullpath;
|
||||
string fusedirpath;
|
||||
const char *fusedirpathcstr;
|
||||
vector<const string*> createpaths;
|
||||
vector<const string*> existingpaths;
|
||||
|
||||
fusedirpath = fusepath;
|
||||
fs::path::dirname(fusedirpath);
|
||||
fusedirpathcstr = fusedirpath.c_str();
|
||||
|
||||
rv = searchFunc(srcmounts,fusedirpathcstr,minfreespace,existingpaths);
|
||||
rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
rv = createFunc(srcmounts,fusedirpathcstr,minfreespace,createpaths);
|
||||
rv = createFunc(srcmounts,fusedirpath,minfreespace,createpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
|
@ -18,29 +18,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "xattr.hpp"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace fs
|
||||
{
|
||||
static
|
||||
inline
|
||||
int
|
||||
lsetxattr(const std::string &path,
|
||||
const char *name,
|
||||
const void *value,
|
||||
const size_t size,
|
||||
const int flags)
|
||||
lsetxattr(const char *path_,
|
||||
const char *name_,
|
||||
const void *value_,
|
||||
const size_t size_,
|
||||
const int flags_)
|
||||
{
|
||||
#ifdef USE_XATTR
|
||||
return ::lsetxattr(path.c_str(),name,value,size,flags);
|
||||
return ::lsetxattr(path_,name_,value_,size_,flags_);
|
||||
#else
|
||||
return (errno=ENOTSUP,-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
lsetxattr(const std::string &path_,
|
||||
const std::string &name_,
|
||||
const void *value_,
|
||||
const size_t size_,
|
||||
const int flags_)
|
||||
{
|
||||
return fs::lsetxattr(path_.c_str(),
|
||||
name_.c_str(),
|
||||
value_,
|
||||
size_,
|
||||
flags_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
|
@ -295,8 +295,8 @@ namespace fs
|
||||
const string &value,
|
||||
const int flags)
|
||||
{
|
||||
return fs::lsetxattr(path.c_str(),
|
||||
key.c_str(),
|
||||
return fs::lsetxattr(path,
|
||||
key,
|
||||
value.data(),
|
||||
value.size(),
|
||||
flags);
|
||||
|
11
src/link.cpp
11
src/link.cpp
@ -99,7 +99,8 @@ _link_create_path(Policy::Func::Search searchFunc,
|
||||
|
||||
newfusedirpath = newfusepath;
|
||||
fs::path::dirname(newfusedirpath);
|
||||
rv = searchFunc(srcmounts,newfusedirpath.c_str(),minfreespace,newbasepaths);
|
||||
|
||||
rv = searchFunc(srcmounts,newfusedirpath,minfreespace,newbasepaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
@ -120,25 +121,23 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc,
|
||||
{
|
||||
int rv;
|
||||
string newfusedirpath;
|
||||
const char *newfusedirpathcstr;
|
||||
vector<const string*> newbasepath;
|
||||
|
||||
newfusedirpath = newfusepath;
|
||||
fs::path::dirname(newfusedirpath);
|
||||
newfusedirpathcstr = newfusedirpath.c_str();
|
||||
|
||||
rv = createFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
|
||||
rv = createFunc(srcmounts,newfusedirpath,minfreespace,newbasepath);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
if(oldbasepath != *newbasepath[0])
|
||||
return (errno=EXDEV,-1);
|
||||
|
||||
rv = searchFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
|
||||
rv = searchFunc(srcmounts,newfusedirpath,minfreespace,newbasepath);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
return fs::clonepath_as_root(*newbasepath[0],oldbasepath,newfusedirpathcstr);
|
||||
return fs::clonepath_as_root(*newbasepath[0],oldbasepath,newfusedirpath);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -68,7 +68,7 @@ int
|
||||
_mkdir_loop(const string &existingpath,
|
||||
const vector<const string*> &createpaths,
|
||||
const char *fusepath,
|
||||
const char *fusedirpath,
|
||||
const string &fusedirpath,
|
||||
const mode_t mode,
|
||||
const mode_t umask)
|
||||
{
|
||||
@ -102,24 +102,22 @@ _mkdir(Policy::Func::Search searchFunc,
|
||||
{
|
||||
int rv;
|
||||
string fusedirpath;
|
||||
const char *fusedirpathcstr;
|
||||
vector<const string*> createpaths;
|
||||
vector<const string*> existingpaths;
|
||||
|
||||
fusedirpath = fusepath;
|
||||
fs::path::dirname(fusedirpath);
|
||||
fusedirpathcstr = fusedirpath.c_str();
|
||||
|
||||
rv = searchFunc(srcmounts,fusedirpathcstr,minfreespace,existingpaths);
|
||||
rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
rv = createFunc(srcmounts,fusedirpathcstr,minfreespace,createpaths);
|
||||
rv = createFunc(srcmounts,fusedirpath,minfreespace,createpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
return _mkdir_loop(*existingpaths[0],createpaths,
|
||||
fusepath,fusedirpathcstr,mode,umask);
|
||||
fusepath,fusedirpath,mode,umask);
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -71,7 +71,7 @@ int
|
||||
_mknod_loop(const string &existingpath,
|
||||
const vector<const string*> &createpaths,
|
||||
const char *fusepath,
|
||||
const char *fusedirpath,
|
||||
const string &fusedirpath,
|
||||
const mode_t mode,
|
||||
const mode_t umask,
|
||||
const dev_t dev)
|
||||
@ -107,24 +107,22 @@ _mknod(Policy::Func::Search searchFunc,
|
||||
{
|
||||
int rv;
|
||||
string fusedirpath;
|
||||
const char *fusedirpathcstr;
|
||||
vector<const string*> createpaths;
|
||||
vector<const string*> existingpaths;
|
||||
|
||||
fusedirpath = fusepath;
|
||||
fs::path::dirname(fusedirpath);
|
||||
fusedirpathcstr = fusedirpath.c_str();
|
||||
|
||||
rv = searchFunc(srcmounts,fusedirpathcstr,minfreespace,existingpaths);
|
||||
rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
rv = createFunc(srcmounts,fusedirpathcstr,minfreespace,createpaths);
|
||||
rv = createFunc(srcmounts,fusedirpath,minfreespace,createpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
return _mknod_loop(*existingpaths[0],createpaths,
|
||||
fusepath,fusedirpathcstr,
|
||||
fusepath,fusedirpath,
|
||||
mode,umask,dev);
|
||||
}
|
||||
|
||||
|
@ -16,19 +16,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "category.hpp"
|
||||
#include "fs.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "fs.hpp"
|
||||
#include "category.hpp"
|
||||
|
||||
#define POLICY_SUCCESS 0
|
||||
#define POLICY_FAIL -1
|
||||
#define POLICY_SUCCEEDED(RV) ((RV) == POLICY_SUCCESS)
|
||||
#define POLICY_FAILED(RV) ((RV) == POLICY_FAIL)
|
||||
#define POLICY_FAIL_ERRNO(ERRNO) (errno=ERRNO,POLICY_FAIL)
|
||||
#define POLICY_FAIL_ENOENT POLICY_FAIL_ERRNO(ENOENT)
|
||||
|
||||
namespace mergerfs
|
||||
{
|
||||
@ -88,6 +81,12 @@ namespace mergerfs
|
||||
return func(T,b,c,d,e);
|
||||
}
|
||||
|
||||
int
|
||||
operator()(cstrvec &b,const string &c,cuint64_t d,cstrptrvec &e)
|
||||
{
|
||||
return func(T,b,c.c_str(),d,e);
|
||||
}
|
||||
|
||||
private:
|
||||
const Ptr func;
|
||||
};
|
||||
|
@ -49,9 +49,9 @@ _all_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(paths.empty())
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -75,9 +75,9 @@ _all_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(paths.empty())
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -56,9 +56,9 @@ _epall_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(paths.empty())
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -82,9 +82,9 @@ _epall_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(paths.empty())
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -59,15 +59,15 @@ _epff_create(const vector<string> &basepaths,
|
||||
|
||||
paths.push_back(basepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(fallback == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(fallback);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -89,10 +89,10 @@ _epff_other(const vector<string> &basepaths,
|
||||
|
||||
paths.push_back(basepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
}
|
||||
|
||||
static
|
||||
@ -122,7 +122,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _epff(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::ff(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -65,11 +65,11 @@ _eplfs_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(eplfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(eplfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -103,11 +103,11 @@ _eplfs_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(eplfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(eplfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -136,7 +136,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _eplfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::lfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -65,11 +65,11 @@ _eplus_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(eplusbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(eplusbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -103,11 +103,11 @@ _eplus_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(eplusbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(eplusbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -136,7 +136,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _eplus(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::lus(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -65,11 +65,11 @@ _epmfs_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(epmfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(epmfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -103,11 +103,11 @@ _epmfs_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(epmfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(epmfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -136,7 +136,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _epmfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -37,7 +37,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = Policy::Func::epall(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_SUCCEEDED(rv))
|
||||
if(rv == 0)
|
||||
std::random_shuffle(paths.begin(),paths.end());
|
||||
|
||||
return rv;
|
||||
|
@ -32,6 +32,6 @@ namespace mergerfs
|
||||
const uint64_t minfreespace,
|
||||
vector<const string*> &paths)
|
||||
{
|
||||
return POLICY_FAIL_ERRNO(EROFS);
|
||||
return (errno=EROFS,-1);
|
||||
}
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ _ff_create(const vector<string> &basepaths,
|
||||
|
||||
paths.push_back(basepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(fallback == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(fallback);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -82,10 +82,10 @@ _ff_other(const vector<string> &basepaths,
|
||||
|
||||
paths.push_back(basepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -32,6 +32,6 @@ namespace mergerfs
|
||||
const uint64_t minfreespace,
|
||||
vector<const string*> &paths)
|
||||
{
|
||||
return POLICY_FAIL_ERRNO(EINVAL);
|
||||
return (errno=EINVAL,-1);
|
||||
}
|
||||
}
|
||||
|
@ -60,11 +60,11 @@ _lfs_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(lfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(lfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -98,11 +98,11 @@ _lfs_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(lfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(lfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -132,7 +132,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _lfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -60,11 +60,11 @@ _lus_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(lusbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(lusbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -98,11 +98,11 @@ _lus_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(lusbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(lusbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -131,7 +131,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _lus(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -56,11 +56,11 @@ _mfs_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(mfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(mfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -94,11 +94,11 @@ _mfs_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(mfsbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(mfsbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -126,7 +126,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = _mfs(type,basepaths,fusepath,paths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
rv = Policy::Func::ff(type,basepaths,fusepath,minfreespace,paths);
|
||||
|
||||
return rv;
|
||||
|
@ -61,11 +61,11 @@ _newest_create(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(newestbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(newestbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -97,11 +97,11 @@ _newest_other(const vector<string> &basepaths,
|
||||
}
|
||||
|
||||
if(newestbasepath == NULL)
|
||||
return POLICY_FAIL_ENOENT;
|
||||
return (errno=ENOENT,-1);
|
||||
|
||||
paths.push_back(newestbasepath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
@ -37,7 +37,7 @@ namespace mergerfs
|
||||
int rv;
|
||||
|
||||
rv = Policy::Func::all(type,basepaths,fusepath,minfreespace,paths);
|
||||
if(POLICY_SUCCEEDED(rv))
|
||||
if(rv == 0)
|
||||
std::random_shuffle(paths.begin(),paths.end());
|
||||
|
||||
return rv;
|
||||
|
@ -112,13 +112,13 @@ _rename_create_path(Policy::Func::Search searchFunc,
|
||||
vector<const string*> oldbasepaths;
|
||||
|
||||
rv = actionFunc(srcmounts,oldfusepath,minfreespace,oldbasepaths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
string newfusedirpath = newfusepath;
|
||||
fs::path::dirname(newfusedirpath);
|
||||
rv = searchFunc(srcmounts,newfusedirpath.c_str(),minfreespace,newbasepath);
|
||||
if(POLICY_FAILED(rv))
|
||||
rv = searchFunc(srcmounts,newfusedirpath,minfreespace,newbasepath);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
error = -1;
|
||||
@ -151,13 +151,13 @@ _clonepath(Policy::Func::Search searchFunc,
|
||||
int rv;
|
||||
vector<const string*> srcbasepath;
|
||||
|
||||
rv = searchFunc(srcmounts,fusedirpath.c_str(),minfreespace,srcbasepath);
|
||||
if(POLICY_FAILED(rv))
|
||||
rv = searchFunc(srcmounts,fusedirpath,minfreespace,srcbasepath);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
fs::clonepath_as_root(*srcbasepath[0],dstbasepath,fusedirpath);
|
||||
|
||||
return POLICY_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@ -176,14 +176,14 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc,
|
||||
|
||||
newfusedirpath = newfusepath;
|
||||
fs::path::dirname(newfusedirpath);
|
||||
rv = createFunc(srcmounts,newfusedirpath.c_str(),minfreespace,newbasepath);
|
||||
if(POLICY_FAILED(rv))
|
||||
rv = createFunc(srcmounts,newfusedirpath,minfreespace,newbasepath);
|
||||
if(rv == -1)
|
||||
return rv;
|
||||
|
||||
if(oldbasepath == *newbasepath[0])
|
||||
return _clonepath(searchFunc,srcmounts,minfreespace,oldbasepath,newfusedirpath);
|
||||
|
||||
return POLICY_FAIL_ERRNO(EXDEV);
|
||||
return (errno=EXDEV,-1);
|
||||
}
|
||||
|
||||
static
|
||||
@ -218,7 +218,7 @@ _rename_preserve_path_core(Policy::Func::Search searchFunc,
|
||||
rv = _clonepath_if_would_create(searchFunc,createFunc,
|
||||
srcmounts,minfreespace,
|
||||
oldbasepath,oldfusepath,newfusepath);
|
||||
if(POLICY_SUCCEEDED(rv))
|
||||
if(rv == 0)
|
||||
rv = fs::rename(oldfullpath,newfullpath);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ _rename_preserve_path(Policy::Func::Search searchFunc,
|
||||
vector<const string*> oldbasepaths;
|
||||
|
||||
rv = actionFunc(srcmounts,oldfusepath,minfreespace,oldbasepaths);
|
||||
if(POLICY_FAILED(rv))
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
error = -1;
|
||||
|
@ -57,7 +57,7 @@ _symlink_loop(const string &existingpath,
|
||||
const vector<const string*> newbasepaths,
|
||||
const char *oldpath,
|
||||
const char *newpath,
|
||||
const char *newdirpath)
|
||||
const string &newdirpath)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
@ -89,24 +89,22 @@ _symlink(Policy::Func::Search searchFunc,
|
||||
{
|
||||
int rv;
|
||||
string newdirpath;
|
||||
const char *newdirpathcstr;
|
||||
vector<const string*> newbasepaths;
|
||||
vector<const string*> existingpaths;
|
||||
|
||||
newdirpath = newpath;
|
||||
fs::path::dirname(newdirpath);
|
||||
newdirpathcstr = newdirpath.c_str();
|
||||
|
||||
rv = searchFunc(srcmounts,newdirpathcstr,minfreespace,existingpaths);
|
||||
rv = searchFunc(srcmounts,newdirpath,minfreespace,existingpaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
rv = createFunc(srcmounts,newdirpathcstr,minfreespace,newbasepaths);
|
||||
rv = createFunc(srcmounts,newdirpath,minfreespace,newbasepaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
return _symlink_loop(*existingpaths[0],newbasepaths,
|
||||
oldpath,newpath,newdirpathcstr);
|
||||
oldpath,newpath,newdirpath);
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
Loading…
x
Reference in New Issue
Block a user