mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
return clonepath errors
currently the error is ignored and it was expected the primary call would fail. problem is it returns confusing errors as a result. (eg ENOENT vs EPERM)
This commit is contained in:
parent
05d81dbc23
commit
35075bb0cd
6 changed files with 53 additions and 34 deletions
|
|
@ -43,22 +43,24 @@ _create_core(const string &existingpath,
|
|||
const int flags,
|
||||
uint64_t &fh)
|
||||
{
|
||||
int fd;
|
||||
int rv;
|
||||
string fullpath;
|
||||
|
||||
if(createpath != existingpath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
rv = fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
fs::path::make(&createpath,fusepath,fullpath);
|
||||
|
||||
fd = fs::open(fullpath,flags,mode);
|
||||
if(fd == -1)
|
||||
rv = fs::open(fullpath,flags,mode);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
fh = reinterpret_cast<uint64_t>(new FileInfo(fd));
|
||||
fh = reinterpret_cast<uint64_t>(new FileInfo(rv));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
33
src/link.cpp
33
src/link.cpp
|
|
@ -49,7 +49,9 @@ _link_create_path_core(const string &oldbasepath,
|
|||
if(oldbasepath != newbasepath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
|
||||
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
|
||||
if(rv == -1)
|
||||
return errno;
|
||||
}
|
||||
|
||||
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
|
||||
|
|
@ -131,25 +133,18 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc,
|
|||
newfusedirpathcstr = newfusedirpath.c_str();
|
||||
|
||||
rv = createFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
|
||||
if(rv != -1)
|
||||
{
|
||||
if(oldbasepath == *newbasepath[0])
|
||||
{
|
||||
rv = searchFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
|
||||
if(rv != -1)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(*newbasepath[0],oldbasepath,newfusedirpathcstr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = -1;
|
||||
errno = EXDEV;
|
||||
}
|
||||
}
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
return rv;
|
||||
if(oldbasepath != *newbasepath[0])
|
||||
return (errno=EXDEV,-1);
|
||||
|
||||
rv = searchFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
return fs::clonepath(*newbasepath[0],oldbasepath,newfusedirpathcstr);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
|
|
@ -48,7 +48,9 @@ _mkdir_loop_core(const string &existingpath,
|
|||
if(createpath != existingpath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
rv = fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
if(rv == -1)
|
||||
return errno;
|
||||
}
|
||||
|
||||
fs::path::make(&createpath,fusepath,fullpath);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,9 @@ _mknod_loop_core(const string &existingpath,
|
|||
if(createpath != existingpath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
rv = fs::clonepath(existingpath,createpath,fusedirpath);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fs::path::make(&createpath,fusepath,fullpath);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,27 @@ _remove(const vector<string> &toremove)
|
|||
::remove(toremove[i].c_str());
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_rename(const std::string &oldbasepath,
|
||||
const std::string &oldfullpath,
|
||||
const std::string &newbasepath,
|
||||
const std::string &newfusedirpath,
|
||||
const std::string &newfullpath)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if(oldbasepath != newbasepath)
|
||||
{
|
||||
const ugid::SetRootGuard guard;
|
||||
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fs::rename(oldfullpath,newfullpath);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_rename_create_path_core(const vector<const string*> &oldbasepaths,
|
||||
|
|
@ -78,15 +99,10 @@ _rename_create_path_core(const vector<const string*> &oldbasepaths,
|
|||
ismember = member(oldbasepaths,oldbasepath);
|
||||
if(ismember)
|
||||
{
|
||||
if(oldbasepath != newbasepath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
|
||||
}
|
||||
|
||||
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
|
||||
|
||||
rv = fs::rename(oldfullpath,newfullpath);
|
||||
rv = _rename(oldbasepath,oldfullpath,
|
||||
newbasepath,newfusedirpath,newfullpath);
|
||||
error = calc_error(rv,error,errno);
|
||||
if(RENAME_FAILED(rv))
|
||||
tounlink.push_back(oldfullpath);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ _symlink_loop_core(const string &existingpath,
|
|||
if(newbasepath != existingpath)
|
||||
{
|
||||
const ugid::SetRootGuard ugidGuard;
|
||||
fs::clonepath(existingpath,newbasepath,newdirpath);
|
||||
rv = fs::clonepath(existingpath,newbasepath,newdirpath);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fs::path::make(&newbasepath,newpath,fullnewpath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue