diff --git a/.travis.yml b/.travis.yml index 33e63567..d949a329 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,13 +18,6 @@ matrix: dist: trusty compiler: clang sudo: required - - os: osx - compiler: clang - -before_script: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap caskroom/cask; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install osxfuse; fi script: - sudo -E make install-build-pkgs diff --git a/src/create.cpp b/src/create.cpp index 3ff02ef8..755fb548 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -87,8 +87,7 @@ _create(Policy::Func::Search searchFunc, vector createpaths; vector existingpaths; - fusedirpath = fusepath; - fs::path::dirname(fusedirpath); + fusedirpath = fs::path::dirname(fusepath); rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths); if(rv == -1) diff --git a/src/fs.cpp b/src/fs.cpp index 50097980..8f4935ce 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -27,93 +27,57 @@ #include "fs_base_realpath.hpp" #include "fs_base_stat.hpp" #include "fs_base_statvfs.hpp" +#include "fs_exists.hpp" #include "fs_path.hpp" #include "fs_xattr.hpp" #include "statvfs_util.hpp" #include "str.hpp" -#include "success_fail.hpp" using std::string; using std::vector; namespace fs { - bool - exists(const string &path, - struct stat &st) - { - int rv; - - rv = fs::lstat(path,st); - - return LSTAT_SUCCEEDED(rv); - } - - bool - exists(const string &path) - { - struct stat st; - - return exists(path,st); - } - - bool - info(const string &path, - bool &readonly, - uint64_t &spaceavail, - uint64_t &spaceused) - { - int rv; - struct statvfs st; - - rv = fs::statvfs(path,st); - if(STATVFS_SUCCEEDED(rv)) - { - readonly = StatVFS::readonly(st); - spaceavail = StatVFS::spaceavail(st); - spaceused = StatVFS::spaceused(st); - } - - return STATVFS_SUCCEEDED(rv); - } - - bool - readonly(const string &path) + int + readonly(const string *path_, + bool *readonly_) { int rv; struct statvfs st; - rv = fs::statvfs(path,st); + rv = fs::statvfs(*path_,st); + if(rv == 0) + *readonly_ = StatVFS::readonly(st); - return (STATVFS_SUCCEEDED(rv) && StatVFS::readonly(st)); + return rv; } - bool - spaceavail(const string &path, - uint64_t &spaceavail) + int + spaceavail(const string *path_, + uint64_t *spaceavail_) { int rv; struct statvfs st; - rv = fs::statvfs(path,st); - if(STATVFS_SUCCEEDED(rv)) - spaceavail = StatVFS::spaceavail(st); + rv = fs::statvfs(*path_,st); + if(rv == 0) + *spaceavail_ = StatVFS::spaceavail(st); - return STATVFS_SUCCEEDED(rv); + return rv; } - bool - spaceused(const string &path, - uint64_t &spaceused) + int + spaceused(const string *path_, + uint64_t *spaceused_) { int rv; struct statvfs st; - rv = fs::statvfs(path,st); - if(STATVFS_SUCCEEDED(rv)) - spaceused = StatVFS::spaceused(st); + rv = fs::statvfs(*path_,st); + if(rv == 0) + *spaceused_ = StatVFS::spaceused(st); - return STATVFS_SUCCEEDED(rv); + return rv; } void @@ -146,7 +110,7 @@ namespace fs struct stat st; rv = fs::fstat(fd,st); - if(FSTAT_FAILED(rv)) + if(rv == -1) return -1; dev = st.st_dev; @@ -155,7 +119,7 @@ namespace fs fs::path::make(&srcmounts[i],fusepath,fullpath); rv = fs::lstat(fullpath,st); - if(FSTAT_FAILED(rv)) + if(rv == -1) continue; if(st.st_dev != dev) @@ -204,19 +168,21 @@ namespace fs const uint64_t minfreespace, string &path) { + int rv; uint64_t mfs; + uint64_t spaceavail; + const string *basepath; const string *mfsbasepath; mfs = 0; mfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceavail; - const string &basepath = basepaths[i]; + basepath = &basepaths[i]; - if(!fs::spaceavail(basepath,spaceavail)) + rv = fs::spaceavail(basepath,&spaceavail); + if(rv == -1) continue; - if(spaceavail < minfreespace) continue; if(spaceavail <= mfs) diff --git a/src/fs.hpp b/src/fs.hpp index 864d99a6..9f785edd 100644 --- a/src/fs.hpp +++ b/src/fs.hpp @@ -27,22 +27,14 @@ namespace fs using std::string; using std::vector; - bool exists(const string &path, - struct stat &st); - bool exists(const string &path); + int readonly(const string *path_, + bool *readonly_); - bool info(const string &path, - bool &readonly, - uint64_t &spaceavail, - uint64_t &spaceused); + int spaceavail(const string *path_, + uint64_t *spaceavail_); - bool readonly(const string &path); - - bool spaceavail(const string &path, - uint64_t &spaceavail); - - bool spaceused(const string &path, - uint64_t &spaceavail); + int spaceused(const string *path_, + uint64_t *spaceavail_); void findallfiles(const vector &srcmounts, const char *fusepath, diff --git a/src/fs_acl.cpp b/src/fs_acl.cpp index 65b40bb2..f74bbc92 100644 --- a/src/fs_acl.cpp +++ b/src/fs_acl.cpp @@ -28,12 +28,12 @@ namespace fs namespace acl { bool - dir_has_defaults(const std::string &fullpath) + dir_has_defaults(const std::string &fullpath_) { int rv; - std::string dirpath = fullpath; + std::string dirpath; - fs::path::dirname(dirpath); + dirpath = fs::path::dirname(&fullpath_); rv = fs::lgetxattr(dirpath,POSIX_ACL_DEFAULT_XATTR,NULL,0); diff --git a/src/fs_base_statvfs.hpp b/src/fs_base_statvfs.hpp index 14d7dcde..2172437a 100644 --- a/src/fs_base_statvfs.hpp +++ b/src/fs_base_statvfs.hpp @@ -18,10 +18,12 @@ #pragma once -#include +#include "errno.hpp" #include +#include + namespace fs { static diff --git a/src/fs_clonepath.cpp b/src/fs_clonepath.cpp index 4062064f..85acf449 100644 --- a/src/fs_clonepath.cpp +++ b/src/fs_clonepath.cpp @@ -70,8 +70,7 @@ namespace fs if((relative == NULL) || (relative[0] == '\0')) return 0; - dirname = relative; - fs::path::dirname(dirname); + dirname = fs::path::dirname(relative); if(!dirname.empty()) { rv = fs::clonepath(fromsrc,tosrc,dirname); diff --git a/src/fs_copy_file_range_linux.icpp b/src/fs_copy_file_range_linux.icpp index f6016c10..4718649d 100644 --- a/src/fs_copy_file_range_linux.icpp +++ b/src/fs_copy_file_range_linux.icpp @@ -16,13 +16,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif #include "errno.hpp" #include -#include #include +#include #include static diff --git a/src/fs_exists.hpp b/src/fs_exists.hpp new file mode 100644 index 00000000..cc699676 --- /dev/null +++ b/src/fs_exists.hpp @@ -0,0 +1,76 @@ +/* + ISC License + + Copyright (c) 2018, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include "fs_base_stat.hpp" +#include "fs_path.hpp" + +#include + +namespace fs +{ + static + inline + bool + exists(const std::string &path_, + struct stat &st_) + { + int rv; + + rv = fs::lstat(path_,st_); + + return (rv == 0); + } + + static + inline + bool + exists(const std::string &path_) + { + struct stat st; + + return fs::exists(path_,st); + } + + + static + inline + bool + exists(const std::string &basepath_, + const char *relpath_, + struct stat &st_) + { + std::string fullpath; + + fullpath = fs::path::make(&basepath_,relpath_); + + return fs::exists(fullpath,st_); + } + + static + inline + bool + exists(const std::string &basepath_, + const char *relpath_) + { + struct stat st; + + return fs::exists(basepath_,relpath_,st); + } +} diff --git a/src/fs_info.cpp b/src/fs_info.cpp new file mode 100644 index 00000000..fc04a7be --- /dev/null +++ b/src/fs_info.cpp @@ -0,0 +1,68 @@ +/* + ISC License + + Copyright (c) 2018, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "fs_base_stat.hpp" +#include "fs_base_statvfs.hpp" +#include "fs_info_t.hpp" +#include "fs_path.hpp" +#include "statvfs_util.hpp" + +#include + +#include + +using std::string; + +namespace fs +{ + int + info(const string *path_, + fs::info_t *info_) + { + int rv; + struct statvfs st; + + rv = fs::statvfs(*path_,st); + if(rv == 0) + { + info_->readonly = StatVFS::readonly(st); + info_->spaceavail = StatVFS::spaceavail(st); + info_->spaceused = StatVFS::spaceused(st); + } + + return rv; + } + + int + info(const string *basepath_, + const char *relpath_, + fs::info_t *info_) + { + int rv; + string fullpath; + struct stat st; + + fullpath = fs::path::make(basepath_,relpath_); + + rv = fs::lstat(fullpath,st); + if(rv == -1) + return -1; + + return fs::info(basepath_,info_); + } +} diff --git a/src/fs_info.hpp b/src/fs_info.hpp new file mode 100644 index 00000000..a6d63254 --- /dev/null +++ b/src/fs_info.hpp @@ -0,0 +1,35 @@ +/* + ISC License + + Copyright (c) 2018, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include "fs_info_t.hpp" + +#include + +namespace fs +{ + int + info(const std::string *basepath_, + const char *relpath_, + fs::info_t *info_); + + int + info(const std::string *path_, + fs::info_t *info_); +} diff --git a/src/fs_info_t.hpp b/src/fs_info_t.hpp new file mode 100644 index 00000000..623617d7 --- /dev/null +++ b/src/fs_info_t.hpp @@ -0,0 +1,31 @@ +/* + ISC License + + Copyright (c) 2018, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include + +namespace fs +{ + struct info_t + { + bool readonly; + uint64_t spaceavail; + uint64_t spaceused; + }; +} diff --git a/src/fs_movefile.cpp b/src/fs_movefile.cpp index ac053087..9c3ca66e 100644 --- a/src/fs_movefile.cpp +++ b/src/fs_movefile.cpp @@ -75,8 +75,8 @@ namespace fs if(rv == -1) return -1; - fusedir = fusepath; - fs::path::dirname(fusedir); + fusedir = fs::path::dirname(&fusepath); + rv = fs::clonepath(fdin_path,fdout_path,fusedir); if(rv == -1) return -1; diff --git a/src/fs_path.cpp b/src/fs_path.cpp index e707dcb3..fb5a33ca 100644 --- a/src/fs_path.cpp +++ b/src/fs_path.cpp @@ -29,24 +29,37 @@ namespace fs { namespace path { - void - dirname(string &path) + string + dirname(const char *path_) + { + string path(path_); + + return fs::path::dirname(&path); + } + + string + dirname(const string *path_) { + string rv; string::reverse_iterator i; - string::reverse_iterator bi; + string::reverse_iterator ei; - bi = path.rend(); - i = path.rbegin(); - while(*i == '/' && i != bi) + rv = *path_; + + i = rv.rbegin(); + ei = rv.rend(); + while(*i == '/' && i != ei) i++; - while(*i != '/' && i != bi) + while(*i != '/' && i != ei) i++; - while(*i == '/' && i != bi) + while(*i == '/' && i != ei) i++; - path.erase(i.base(),path.end()); + rv.erase(i.base(),rv.end()); + + return rv; } string diff --git a/src/fs_path.hpp b/src/fs_path.hpp index a8ef0aab..bf1c5b7d 100644 --- a/src/fs_path.hpp +++ b/src/fs_path.hpp @@ -25,7 +25,8 @@ namespace fs { using std::string; - void dirname(string &path); + string dirname(const char *path_); + string dirname(const string *path_); string basename(const string &path); @@ -64,5 +65,22 @@ namespace fs output = *base; output += suffix; } + + inline + string + make(const string *base_, + const char *suffix_) + { + return (*base_ + suffix_); + } + + static + inline + string + make(const string *base_, + const string *suffix_) + { + return (*base_ + *suffix_); + } } }; diff --git a/src/link.cpp b/src/link.cpp index e521511c..fb56127e 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -97,8 +97,7 @@ _link_create_path(Policy::Func::Search searchFunc, if(rv == -1) return -errno; - newfusedirpath = newfusepath; - fs::path::dirname(newfusedirpath); + newfusedirpath = fs::path::dirname(newfusepath); rv = searchFunc(srcmounts,newfusedirpath,minfreespace,newbasepaths); if(rv == -1) @@ -123,8 +122,7 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc, string newfusedirpath; vector newbasepath; - newfusedirpath = newfusepath; - fs::path::dirname(newfusedirpath); + newfusedirpath = fs::path::dirname(newfusepath); rv = createFunc(srcmounts,newfusedirpath,minfreespace,newbasepath); if(rv == -1) diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 9ff75f4d..59c95998 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -105,8 +105,7 @@ _mkdir(Policy::Func::Search searchFunc, vector createpaths; vector existingpaths; - fusedirpath = fusepath; - fs::path::dirname(fusedirpath); + fusedirpath = fs::path::dirname(fusepath); rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths); if(rv == -1) diff --git a/src/mknod.cpp b/src/mknod.cpp index 4d602b03..60483270 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -110,8 +110,7 @@ _mknod(Policy::Func::Search searchFunc, vector createpaths; vector existingpaths; - fusedirpath = fusepath; - fs::path::dirname(fusedirpath); + fusedirpath = fs::path::dirname(fusepath); rv = searchFunc(srcmounts,fusedirpath,minfreespace,existingpaths); if(rv == -1) diff --git a/src/policy_all.cpp b/src/policy_all.cpp index 4a06df81..41ae4631 100644 --- a/src/policy_all.cpp +++ b/src/policy_all.cpp @@ -14,14 +14,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" -#include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; @@ -31,18 +32,20 @@ _all_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { + int rv; + fs::info_t info; + const string *basepath; + for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; + basepath = &basepaths[i]; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; paths.push_back(basepath); @@ -60,15 +63,13 @@ _all_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + const string *basepath; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; paths.push_back(basepath); diff --git a/src/policy_epall.cpp b/src/policy_epall.cpp index 473ce0c3..96121535 100644 --- a/src/policy_epall.cpp +++ b/src/policy_epall.cpp @@ -14,14 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; @@ -32,24 +34,20 @@ _epall_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; + fs::info_t info; + const string *basepath; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + rv = fs::info(basepath,fusepath,&info); + if(rv == -1) continue; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + if(info.readonly) continue; - if(readonly) - continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; paths.push_back(basepath); @@ -67,15 +65,13 @@ _epall_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + const string *basepath; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; paths.push_back(basepath); diff --git a/src/policy_epff.cpp b/src/policy_epff.cpp index be88cb05..a0fc3217 100644 --- a/src/policy_epff.cpp +++ b/src/policy_epff.cpp @@ -14,14 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -33,28 +35,20 @@ _epff_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; - const string *fallback; + int rv; + fs::info_t info; + const string *basepath; - fallback = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + rv = fs::info(basepath,fusepath,&info); + if(rv == -1) continue; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + if(info.readonly) continue; - if(readonly) - continue; - if(fallback == NULL) - fallback = basepath; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; paths.push_back(basepath); @@ -62,12 +56,7 @@ _epff_create(const vector &basepaths, return 0; } - if(fallback == NULL) - return (errno=ENOENT,-1); - - paths.push_back(fallback); - - return 0; + return (errno=ENOENT,-1); } static @@ -76,15 +65,13 @@ _epff_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + const string *basepath; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; paths.push_back(basepath); @@ -109,7 +96,6 @@ _epff(const Category::Enum::Type type, return _epff_other(basepaths,fusepath,paths); } - namespace mergerfs { int diff --git a/src/policy_eplfs.cpp b/src/policy_eplfs.cpp index 501f6816..9f32cf89 100644 --- a/src/policy_eplfs.cpp +++ b/src/policy_eplfs.cpp @@ -14,15 +14,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -34,33 +36,29 @@ _eplfs_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; uint64_t eplfs; + fs::info_t info; + const string *basepath; const string *eplfsbasepath; eplfs = std::numeric_limits::max(); eplfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) - continue; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,fusepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; - if(spaceavail > eplfs) + if(info.spaceavail > eplfs) continue; - eplfs = spaceavail; + eplfs = info.spaceavail; eplfsbasepath = basepath; } @@ -78,22 +76,22 @@ _eplfs_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t eplfs; + uint64_t spaceavail; + const string *basepath; const string *eplfsbasepath; eplfs = std::numeric_limits::max(); eplfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceavail; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceavail(*basepath,spaceavail)) + rv = fs::spaceavail(basepath,&spaceavail); + if(rv == -1) continue; if(spaceavail > eplfs) continue; diff --git a/src/policy_eplus.cpp b/src/policy_eplus.cpp index c0761f2b..d352ffcd 100644 --- a/src/policy_eplus.cpp +++ b/src/policy_eplus.cpp @@ -14,15 +14,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -34,33 +36,29 @@ _eplus_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; uint64_t eplus; + fs::info_t info; + const string *basepath; const string *eplusbasepath; eplus = std::numeric_limits::max(); eplusbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) - continue; - if(!fs::info(*basepath,readonly,spaceavail,spaceused)) + rv = fs::info(basepath,fusepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; - if(spaceused >= eplus) + if(info.spaceused >= eplus) continue; - eplus = spaceused; + eplus = info.spaceused; eplusbasepath = basepath; } @@ -78,22 +76,22 @@ _eplus_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t eplus; + uint64_t spaceused; + const string *basepath; const string *eplusbasepath; eplus = 0; eplusbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceused(*basepath,spaceused)) + rv = fs::spaceused(basepath,&spaceused); + if(rv == -1) continue; if(spaceused >= eplus) continue; diff --git a/src/policy_epmfs.cpp b/src/policy_epmfs.cpp index 8b54fd1e..2a53420b 100644 --- a/src/policy_epmfs.cpp +++ b/src/policy_epmfs.cpp @@ -14,15 +14,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -34,33 +36,29 @@ _epmfs_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; uint64_t epmfs; + fs::info_t info; + const string *basepath; const string *epmfsbasepath; epmfs = std::numeric_limits::min(); epmfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) - continue; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,fusepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; - if(spaceavail < epmfs) + if(info.spaceavail < epmfs) continue; - epmfs = spaceavail; + epmfs = info.spaceavail; epmfsbasepath = basepath; } @@ -78,22 +76,22 @@ _epmfs_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t epmfs; + uint64_t spaceavail; + const string *basepath; const string *epmfsbasepath; epmfs = 0; epmfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceavail; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceavail(*basepath,spaceavail)) + rv = fs::spaceavail(basepath,&spaceavail); + if(rv == -1) continue; if(spaceavail < epmfs) continue; diff --git a/src/policy_eprand.cpp b/src/policy_eprand.cpp index 010b55c5..7b739052 100644 --- a/src/policy_eprand.cpp +++ b/src/policy_eprand.cpp @@ -14,14 +14,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "errno.hpp" +#include "policy.hpp" + #include #include #include -#include "errno.hpp" -#include "policy.hpp" -#include "success_fail.hpp" - using std::string; using std::vector; diff --git a/src/policy_erofs.cpp b/src/policy_erofs.cpp index 8449f6a4..6a543033 100644 --- a/src/policy_erofs.cpp +++ b/src/policy_erofs.cpp @@ -14,12 +14,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; diff --git a/src/policy_ff.cpp b/src/policy_ff.cpp index 34e70a5a..76cb5728 100644 --- a/src/policy_ff.cpp +++ b/src/policy_ff.cpp @@ -14,14 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; @@ -31,23 +33,24 @@ _ff_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { + int rv; + fs::info_t info; + const string *basepath; const string *fallback; fallback = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; + basepath = &basepaths[i]; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; if(fallback == NULL) fallback = basepath; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; paths.push_back(basepath); @@ -69,15 +72,13 @@ _ff_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + const string *basepath; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; paths.push_back(basepath); diff --git a/src/policy_invalid.cpp b/src/policy_invalid.cpp index b56084dd..1fc49a99 100644 --- a/src/policy_invalid.cpp +++ b/src/policy_invalid.cpp @@ -14,12 +14,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; diff --git a/src/policy_lfs.cpp b/src/policy_lfs.cpp index 88049c96..f86d09ca 100644 --- a/src/policy_lfs.cpp +++ b/src/policy_lfs.cpp @@ -14,15 +14,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -33,29 +35,29 @@ _lfs_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; uint64_t lfs; + fs::info_t info; + const string *basepath; const string *lfsbasepath; lfs = std::numeric_limits::max(); lfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; + basepath = &basepaths[i]; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; - if(spaceavail > lfs) + if(info.spaceavail > lfs) continue; - lfs = spaceavail; + lfs = info.spaceavail; lfsbasepath = basepath; } @@ -73,22 +75,22 @@ _lfs_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t lfs; + uint64_t spaceavail; + const string *basepath; const string *lfsbasepath; lfs = std::numeric_limits::max(); lfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceavail; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceavail(*basepath,spaceavail)) + rv = fs::spaceavail(basepath,&spaceavail); + if(rv == -1) continue; if(spaceavail > lfs) continue; diff --git a/src/policy_lus.cpp b/src/policy_lus.cpp index 7d8c05e5..63a07327 100644 --- a/src/policy_lus.cpp +++ b/src/policy_lus.cpp @@ -14,15 +14,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -33,29 +35,29 @@ _lus_create(const vector &basepaths, const uint64_t minfreespace, vector &paths) { - string fullpath; + int rv; uint64_t lus; + fs::info_t info; + const string *basepath; const string *lusbasepath; lus = std::numeric_limits::max(); lusbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceused; - uint64_t spaceavail; - const string *basepath = &basepaths[i]; + basepath = &basepaths[i]; - if(!fs::info(*basepath,readonly,spaceavail,spaceused)) + rv = fs::info(basepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < minfreespace) + if(info.spaceavail < minfreespace) continue; - if(spaceused >= lus) + if(info.spaceused >= lus) continue; - lus = spaceused; + lus = info.spaceused; lusbasepath = basepath; } @@ -73,22 +75,22 @@ _lus_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t lus; + uint64_t spaceused; + const string *basepath; const string *lusbasepath; lus = 0; lusbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceused; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceused(*basepath,spaceused)) + rv = fs::spaceused(basepath,&spaceused); + if(rv == -1) continue; if(spaceused >= lus) continue; diff --git a/src/policy_mfs.cpp b/src/policy_mfs.cpp index ba68b5a5..05d45be2 100644 --- a/src/policy_mfs.cpp +++ b/src/policy_mfs.cpp @@ -14,14 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" +#include +#include + using std::string; using std::vector; using mergerfs::Category; @@ -31,27 +33,27 @@ int _mfs_create(const vector &basepaths, vector &paths) { - string fullpath; + int rv; uint64_t mfs; + fs::info_t info; + const string *basepath; const string *mfsbasepath; mfs = 0; mfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - bool readonly; - uint64_t spaceavail; - uint64_t _spaceused; - const string *basepath = &basepaths[i]; + basepath = &basepaths[i]; - if(!fs::info(*basepath,readonly,spaceavail,_spaceused)) + rv = fs::info(basepath,&info); + if(rv == -1) continue; - if(readonly) + if(info.readonly) continue; - if(spaceavail < mfs) + if(info.spaceavail < mfs) continue; - mfs = spaceavail; + mfs = info.spaceavail; mfsbasepath = basepath; } @@ -69,22 +71,22 @@ _mfs_other(const vector &basepaths, const char *fusepath, vector &paths) { - string fullpath; + int rv; uint64_t mfs; + uint64_t spaceavail; + const string *basepath; const string *mfsbasepath; mfs = 0; mfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - uint64_t spaceavail; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath)) + if(!fs::exists(*basepath,fusepath)) continue; - if(!fs::spaceavail(*basepath,spaceavail)) + rv = fs::spaceavail(basepath,&spaceavail); + if(rv == -1) continue; if(spaceavail < mfs) continue; diff --git a/src/policy_newest.cpp b/src/policy_newest.cpp index cc17d9e8..eee8153b 100644 --- a/src/policy_newest.cpp +++ b/src/policy_newest.cpp @@ -14,17 +14,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - -#include -#include -#include #include "errno.hpp" #include "fs.hpp" +#include "fs_exists.hpp" #include "fs_path.hpp" #include "policy.hpp" -#include "success_fail.hpp" + +#include +#include +#include + +#include using std::string; using std::vector; @@ -35,25 +36,27 @@ _newest_create(const vector &basepaths, const char *fusepath, vector &paths) { + int rv; + bool readonly; time_t newest; - string fullpath; + struct stat st; + const string *basepath; const string *newestbasepath; newest = std::numeric_limits::min(); newestbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { + basepath = &basepaths[i]; - struct stat st; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); - - if(!fs::exists(fullpath,st)) + if(!fs::exists(*basepath,fusepath,st)) continue; if(st.st_mtime < newest) continue; - if(fs::readonly(*basepath)) + rv = fs::readonly(basepath,&readonly); + if(rv == -1) + continue; + if(readonly) continue; newest = st.st_mtime; @@ -75,19 +78,17 @@ _newest_other(const vector &basepaths, vector &paths) { time_t newest; - string fullpath; + struct stat st; + const string *basepath; const string *newestbasepath; newest = std::numeric_limits::min(); newestbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { - struct stat st; - const string *basepath = &basepaths[i]; - - fs::path::make(basepath,fusepath,fullpath); + basepath = &basepaths[i]; - if(!fs::exists(fullpath,st)) + if(!fs::exists(*basepath,fusepath,st)) continue; if(st.st_mtime < newest) continue; diff --git a/src/policy_rand.cpp b/src/policy_rand.cpp index 8ef22de2..a22b9a98 100644 --- a/src/policy_rand.cpp +++ b/src/policy_rand.cpp @@ -14,14 +14,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "errno.hpp" +#include "policy.hpp" + #include #include #include -#include "errno.hpp" -#include "policy.hpp" -#include "success_fail.hpp" - using std::string; using std::vector; diff --git a/src/readdir.cpp b/src/readdir.cpp index 48d984b5..42d9748e 100644 --- a/src/readdir.cpp +++ b/src/readdir.cpp @@ -14,7 +14,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _BSD_SOURCE +#define _DEFAULT_SOURCE #include diff --git a/src/rename.cpp b/src/rename.cpp index 29073150..c64ddd5d 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -107,6 +107,7 @@ _rename_create_path(Policy::Func::Search searchFunc, { int rv; int error; + string newfusedirpath; vector toremove; vector newbasepath; vector oldbasepaths; @@ -115,8 +116,8 @@ _rename_create_path(Policy::Func::Search searchFunc, if(rv == -1) return -errno; - string newfusedirpath = newfusepath; - fs::path::dirname(newfusedirpath); + newfusedirpath = fs::path::dirname(newfusepath); + rv = searchFunc(srcmounts,newfusedirpath,minfreespace,newbasepath); if(rv == -1) return -errno; @@ -174,8 +175,8 @@ _clonepath_if_would_create(Policy::Func::Search searchFunc, string newfusedirpath; vector newbasepath; - newfusedirpath = newfusepath; - fs::path::dirname(newfusedirpath); + newfusedirpath = fs::path::dirname(newfusepath); + rv = createFunc(srcmounts,newfusedirpath,minfreespace,newbasepath); if(rv == -1) return rv; diff --git a/src/statfs.cpp b/src/statfs.cpp index eb2aa60c..34f4b9fb 100644 --- a/src/statfs.cpp +++ b/src/statfs.cpp @@ -27,7 +27,6 @@ #include "fs_base_stat.hpp" #include "fs_base_statvfs.hpp" #include "rwlock.hpp" -#include "success_fail.hpp" #include "ugid.hpp" using std::string; @@ -76,11 +75,11 @@ _statfs_core(const char *srcmount, struct statvfs fsstat; rv = fs::statvfs(srcmount,fsstat); - if(STATVFS_FAILED(rv)) + if(rv == -1) return; rv = fs::stat(srcmount,st); - if(STAT_FAILED(rv)) + if(rv == -1) return; if(fsstat.f_bsize && (min_bsize > fsstat.f_bsize)) diff --git a/src/statvfs_util.hpp b/src/statvfs_util.hpp index 246d621c..cccdcba7 100644 --- a/src/statvfs_util.hpp +++ b/src/statvfs_util.hpp @@ -16,11 +16,9 @@ #pragma once -#include - #include -#include "success_fail.hpp" +#include namespace StatVFS { diff --git a/src/strset.hpp b/src/strset.hpp index 8fcfe857..9630cfc4 100644 --- a/src/strset.hpp +++ b/src/strset.hpp @@ -18,10 +18,10 @@ #pragma once -#include - #include "khash.h" +#include + KHASH_SET_INIT_STR(strset); class StrSet @@ -36,7 +36,7 @@ public: { for(khint_t k = kh_begin(_set), ek = kh_end(_set); k != ek; k++) if(kh_exist(_set,k)) - free((char*)kh_key(_set,k)); + ::free((char*)kh_key(_set,k)); kh_destroy(strset,_set); } @@ -52,7 +52,7 @@ public: if(rv == 0) return 0; - kh_key(_set,key) = strdup(str); + kh_key(_set,key) = ::strdup(str); return rv; } diff --git a/src/success_fail.hpp b/src/success_fail.hpp deleted file mode 100644 index 83cf43c9..00000000 --- a/src/success_fail.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (c) 2016, Antonio SJ Musumeci - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#pragma once - -#define STATVFS_SUCCESS 0 -#define STATVFS_SUCCEEDED(RV) ((RV) == STATVFS_SUCCESS) -#define STATVFS_FAIL -1 -#define STATVFS_FAILED(RV) ((RV) == STATVFS_FAIL) - -#define STAT_SUCCESS 0 -#define STAT_SUCCEEDED(RV) ((RV) == STAT_SUCCESS) -#define STAT_FAIL -1 -#define STAT_FAILED(RV) ((RV) == STAT_FAIL) - -#define LSTAT_SUCCESS 0 -#define LSTAT_SUCCEEDED(RV) ((RV) == LSTAT_SUCCESS) -#define LSTAT_FAIL -1 -#define LSTAT_FAILED(RV) ((RV) == LSTAT_FAIL) - -#define FSTAT_SUCCESS 0 -#define FSTAT_SUCCEEDED(RV) ((RV) == FSTAT_SUCCESS) -#define FSTAT_FAIL -1 -#define FSTAT_FAILED(RV) ((RV) == FSTAT_FAIL) - -#define RENAME_SUCCESS 0 -#define RENAME_SUCCEEDED(RV) ((RV) == RENAME_SUCCESS) -#define RENAME_FAIL -1 -#define RENAME_FAILED(RV) ((RV) == RENAME_FAIL) -#define RENAME_FAILED_WITH(RV,ERRNO) (((RV) == RENAME_FAIL) && (errno == ERRNO)) diff --git a/src/symlink.cpp b/src/symlink.cpp index f119a69c..02915940 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -92,8 +92,7 @@ _symlink(Policy::Func::Search searchFunc, vector newbasepaths; vector existingpaths; - newdirpath = newpath; - fs::path::dirname(newdirpath); + newdirpath = fs::path::dirname(newpath); rv = searchFunc(srcmounts,newdirpath,minfreespace,existingpaths); if(rv == -1)