Browse Source

Merge pull request #340 from trapexit/clonepath-errors

return clonepath errors
pull/348/head
Antonio SJ Musumeci 8 years ago
committed by GitHub
parent
commit
aa71116928
  1. 12
      src/create.cpp
  2. 33
      src/link.cpp
  3. 4
      src/mkdir.cpp
  4. 4
      src/mknod.cpp
  5. 30
      src/rename.cpp
  6. 4
      src/symlink.cpp

12
src/create.cpp

@ -43,22 +43,24 @@ _create_core(const string &existingpath,
const int flags, const int flags,
uint64_t &fh) uint64_t &fh)
{ {
int fd;
int rv;
string fullpath; string fullpath;
if(createpath != existingpath) if(createpath != existingpath)
{ {
const ugid::SetRootGuard ugidGuard; 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); 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; return -errno;
fh = reinterpret_cast<uint64_t>(new FileInfo(fd));
fh = reinterpret_cast<uint64_t>(new FileInfo(rv));
return 0; return 0;
} }

33
src/link.cpp

@ -49,7 +49,9 @@ _link_create_path_core(const string &oldbasepath,
if(oldbasepath != newbasepath) if(oldbasepath != newbasepath)
{ {
const ugid::SetRootGuard ugidGuard; 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); fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
@ -131,25 +133,18 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc,
newfusedirpathcstr = newfusedirpath.c_str(); newfusedirpathcstr = newfusedirpath.c_str();
rv = createFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath); 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;
if(oldbasepath != *newbasepath[0])
return (errno=EXDEV,-1);
rv = searchFunc(srcmounts,newfusedirpathcstr,minfreespace,newbasepath);
if(rv == -1)
return -1;
return rv;
const ugid::SetRootGuard ugidGuard;
return fs::clonepath(*newbasepath[0],oldbasepath,newfusedirpathcstr);
} }
static static

4
src/mkdir.cpp

@ -48,7 +48,9 @@ _mkdir_loop_core(const string &existingpath,
if(createpath != existingpath) if(createpath != existingpath)
{ {
const ugid::SetRootGuard ugidGuard; 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); fs::path::make(&createpath,fusepath,fullpath);

4
src/mknod.cpp

@ -48,7 +48,9 @@ _mknod_loop_core(const string &existingpath,
if(createpath != existingpath) if(createpath != existingpath)
{ {
const ugid::SetRootGuard ugidGuard; 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); fs::path::make(&createpath,fusepath,fullpath);

30
src/rename.cpp

@ -57,6 +57,27 @@ _remove(const vector<string> &toremove)
::remove(toremove[i].c_str()); ::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 static
void void
_rename_create_path_core(const vector<const string*> &oldbasepaths, _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); ismember = member(oldbasepaths,oldbasepath);
if(ismember) if(ismember)
{ {
if(oldbasepath != newbasepath)
{
const ugid::SetRootGuard ugidGuard;
fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
}
fs::path::make(&oldbasepath,oldfusepath,oldfullpath); fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
rv = fs::rename(oldfullpath,newfullpath);
rv = _rename(oldbasepath,oldfullpath,
newbasepath,newfusedirpath,newfullpath);
error = calc_error(rv,error,errno); error = calc_error(rv,error,errno);
if(RENAME_FAILED(rv)) if(RENAME_FAILED(rv))
tounlink.push_back(oldfullpath); tounlink.push_back(oldfullpath);

4
src/symlink.cpp

@ -49,7 +49,9 @@ _symlink_loop_core(const string &existingpath,
if(newbasepath != existingpath) if(newbasepath != existingpath)
{ {
const ugid::SetRootGuard ugidGuard; 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); fs::path::make(&newbasepath,newpath,fullnewpath);

Loading…
Cancel
Save