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:
Antonio SJ Musumeci 2016-12-06 16:48:52 -05:00
parent 05d81dbc23
commit 35075bb0cd
6 changed files with 53 additions and 34 deletions

View file

@ -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);