diff --git a/src/rename.cpp b/src/rename.cpp index 5895d59d..51230d9b 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -142,6 +142,29 @@ _rename_create_path(Policy::Func::Search searchFunc, return -error; } +static +int +_clonepath(Policy::Func::Search searchFunc, + const vector &srcmounts, + const size_t minfreespace, + const string &dstbasepath, + const string &fusedirpath) +{ + int rv; + vector srcbasepath; + + rv = searchFunc(srcmounts,fusedirpath.c_str(),minfreespace,srcbasepath); + if(POLICY_FAILED(rv)) + return rv; + + { + const ugid::SetRootGuard ugidGuard; + fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath.c_str()); + } + + return POLICY_SUCCESS; +} + static int _clonepath_if_would_create(Policy::Func::Search searchFunc, @@ -163,18 +186,7 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc, return rv; if(oldbasepath == *newbasepath[0]) - { - rv = searchFunc(srcmounts,newfusedirpath.c_str(),minfreespace,newbasepath); - if(POLICY_FAILED(rv)) - return rv; - - { - const ugid::SetRootGuard ugidGuard; - fs::clonepath(*newbasepath[0],oldbasepath,newfusedirpath.c_str()); - } - - return POLICY_SUCCESS; - } + return _clonepath(searchFunc,srcmounts,minfreespace,oldbasepath,newfusedirpath); return POLICY_FAIL_ERRNO(EXDEV); }