From ccb22c1fbe0794801b27fff8e55f06670639467a Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Tue, 16 Jun 2015 22:12:55 -0400 Subject: [PATCH] create minfreespace option. closes #71 --- src/access.cpp | 4 +++- src/chmod.cpp | 6 +++-- src/chown.cpp | 4 +++- src/config.cpp | 1 + src/config.hpp | 2 ++ src/create.cpp | 6 +++-- src/fs.cpp | 50 ++++++++++++++++++--------------------- src/fs.hpp | 43 ++++++++++++++++++++-------------- src/getattr.cpp | 4 +++- src/getxattr.cpp | 4 +++- src/ioctl.cpp | 4 +++- src/link.cpp | 9 +++++--- src/listxattr.cpp | 7 +++--- src/mkdir.cpp | 6 +++-- src/mknod.cpp | 6 +++-- src/open.cpp | 4 +++- src/option_parser.cpp | 54 +++++++++++++++++++++++++++++++++++-------- src/readlink.cpp | 4 +++- src/removexattr.cpp | 4 +++- src/rename.cpp | 9 +++++--- src/rmdir.cpp | 4 +++- src/setxattr.cpp | 4 +++- src/symlink.cpp | 4 +++- src/truncate.cpp | 4 +++- src/unlink.cpp | 4 +++- src/utimens.cpp | 4 +++- 26 files changed, 171 insertions(+), 84 deletions(-) diff --git a/src/access.cpp b/src/access.cpp index 2760ad13..f1611310 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -47,13 +47,14 @@ static int _access(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const int mask) { int rv; fs::Paths paths; - rv = searchFunc(srcmounts,fusepath,paths,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -77,6 +78,7 @@ namespace mergerfs return _access(*config.access, config.srcmounts, + config.minfreespace, fusepath, mask); } diff --git a/src/chmod.cpp b/src/chmod.cpp index 193b7464..7109bdbb 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -41,6 +41,7 @@ static int _chmod(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const mode_t mode) { @@ -48,7 +49,7 @@ _chmod(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -73,12 +74,13 @@ namespace mergerfs mode_t mode) { const struct fuse_context *fc = fuse_get_context(); - const ugid::SetResetGuard ugid(fc->uid,fc->gid); const config::Config &config = config::get(); + const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); return _chmod(*config.chmod, config.srcmounts, + config.minfreespace, fusepath, mode); } diff --git a/src/chown.cpp b/src/chown.cpp index 40dbf721..4ff52fcb 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -42,6 +42,7 @@ static int _chown(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const uid_t uid, const gid_t gid) @@ -50,7 +51,7 @@ _chown(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -82,6 +83,7 @@ namespace mergerfs return _chown(*config.chown, config.srcmounts, + config.minfreespace, fusepath, uid, gid); diff --git a/src/config.cpp b/src/config.cpp index 88c967ee..71500606 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -46,6 +46,7 @@ namespace mergerfs : destmount(), srcmounts(), srcmountslock(), + minfreespace(UINT32_MAX), POLICYINIT(access), POLICYINIT(chmod), POLICYINIT(chown), diff --git a/src/config.hpp b/src/config.hpp index f673dc5a..9a7b2602 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -54,6 +55,7 @@ namespace mergerfs std::string destmount; std::vector srcmounts; mutable pthread_rwlock_t srcmountslock; + size_t minfreespace; public: const Policy *policies[FuseFunc::Enum::END]; diff --git a/src/create.cpp b/src/create.cpp index c85605f5..0eb9c84d 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -46,6 +46,7 @@ int _create(const fs::find::Func searchFunc, const fs::find::Func createFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const mode_t mode, const int flags, @@ -59,11 +60,11 @@ _create(const fs::find::Func searchFunc, fs::Paths existingpath; dirname = fs::dirname(fusepath); - rv = searchFunc(srcmounts,dirname,existingpath,1); + rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); if(rv == -1) return -errno; - rv = createFunc(srcmounts,dirname,createpath,1); + rv = createFunc(srcmounts,dirname,minfreespace,createpath); if(rv == -1) return -errno; @@ -101,6 +102,7 @@ namespace mergerfs return _create(*config.getattr, *config.create, config.srcmounts, + config.minfreespace, fusepath, (mode & ~fc->umask), fileinfo->flags, diff --git a/src/fs.cpp b/src/fs.cpp index db99a38a..456639c2 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -520,8 +520,8 @@ namespace fs int invalid(const vector &basepaths, const string &fusepath, - Paths &rv, - size_t count) + const size_t minfreespace, + Paths &rv) { return (errno = EINVAL,-1); } @@ -529,8 +529,8 @@ namespace fs int ff(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { errno = ENOENT; for(vector::const_iterator @@ -558,8 +558,8 @@ namespace fs int ffwp(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { Path fallback; @@ -597,8 +597,8 @@ namespace fs int newest(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { time_t newest; string npath; @@ -635,8 +635,8 @@ namespace fs int mfs(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { fsblkcnt_t mfs; size_t mfsidx; @@ -675,11 +675,11 @@ namespace fs int epmfs(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { - fsblkcnt_t existingmfs = 0; - fsblkcnt_t generalmfs = 0; + fsblkcnt_t existingmfs; + fsblkcnt_t generalmfs; string fullpath; string generalmfspath; string existingmfspath; @@ -689,6 +689,8 @@ namespace fs if(iter == eiter) return (errno = ENOENT,-1); + existingmfs = 0; + generalmfs = 0; do { int rv; @@ -736,8 +738,8 @@ namespace fs int all(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { int rv; struct stat st; @@ -745,17 +747,14 @@ namespace fs for(vector::const_iterator iter = basepaths.begin(), eiter = basepaths.end(); - iter != eiter && count; + iter != eiter; ++iter) { fullpath = fs::make_path(*iter,fusepath); rv = ::lstat(fullpath.c_str(),&st); if(rv == 0) - { - paths.push_back(Path(*iter,fullpath)); - count--; - } + paths.push_back(Path(*iter,fullpath)); } return paths.empty() ? (errno=ENOENT,-1) : 0; @@ -764,20 +763,17 @@ namespace fs int rand(const vector &basepaths, const string &fusepath, - Paths &paths, - size_t count) + const size_t minfreespace, + Paths &paths) { int rv; - rv = all(basepaths,fusepath,paths,-1); + rv = all(basepaths,fusepath,minfreespace,paths); if(rv == -1) return -1; std::random_shuffle(paths.begin(),paths.end()); - if(paths.size() > count) - paths.resize(count); - return 0; } } diff --git a/src/fs.hpp b/src/fs.hpp index 54c01c59..7f5a3ecc 100644 --- a/src/fs.hpp +++ b/src/fs.hpp @@ -39,12 +39,21 @@ namespace fs struct Path { Path() {} + + explicit Path(const string &b, const string &f) : base(b), full(f) {} + explicit + Path(const char *b, + const string &f) + : base(b), + full(f) + {} + string base; string full; }; @@ -113,40 +122,40 @@ namespace fs namespace find { - typedef int (*Func)(const vector&,const string&,Paths&,size_t); + typedef int (*Func)(const vector&,const string&,const size_t,Paths&); int invalid(const vector &basepaths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int all(const vector &basepaths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int ff(const vector &basepaths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int ffwp(const vector &paths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int newest(const vector &paths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int mfs(const vector &paths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int epmfs(const vector &paths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); int rand(const vector &paths, const string &fusepath, - Paths &path, - size_t max); + const size_t minfreespace, + Paths &path); } }; diff --git a/src/getattr.cpp b/src/getattr.cpp index 6151d951..9779894a 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -67,13 +67,14 @@ static int _getattr(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, struct stat &buf) { int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -101,6 +102,7 @@ namespace mergerfs return _getattr(*config.getattr, config.srcmounts, + config.minfreespace, fusepath, *st); } diff --git a/src/getxattr.cpp b/src/getxattr.cpp index 01f1016d..52b949dd 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -192,6 +192,7 @@ static int _getxattr(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const char *attrname, char *buf, @@ -201,7 +202,7 @@ _getxattr(const fs::find::Func searchFunc, int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -240,6 +241,7 @@ namespace mergerfs return _getxattr(*config.getxattr, config.srcmounts, + config.minfreespace, fusepath, attrname, buf, diff --git a/src/ioctl.cpp b/src/ioctl.cpp index 9c3fa97f..d3e62fee 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -84,6 +84,7 @@ static int _ioctl_dir_base(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const int cmd, void *arg, @@ -94,7 +95,7 @@ _ioctl_dir_base(const fs::find::Func searchFunc, int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -124,6 +125,7 @@ _ioctl_dir(const string &fusepath, return _ioctl_dir_base(*config.getattr, config.srcmounts, + config.minfreespace, fusepath, cmd, arg, diff --git a/src/link.cpp b/src/link.cpp index bf286942..64c991a4 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -43,6 +43,7 @@ static int _single_link(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &base, const string &oldpath, const string &newpath) @@ -58,7 +59,7 @@ _single_link(const fs::find::Func searchFunc, fs::Paths foundpath; newpathdir = fs::dirname(newpath); - rv = searchFunc(srcmounts,newpathdir,foundpath,1); + rv = searchFunc(srcmounts,newpathdir,minfreespace,foundpath); if(rv == -1) return -1; @@ -78,6 +79,7 @@ int _link(const fs::find::Func searchFunc, const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &oldpath, const string &newpath) { @@ -85,7 +87,7 @@ _link(const fs::find::Func searchFunc, int error; fs::Paths oldpaths; - rv = actionFunc(srcmounts,oldpath,oldpaths,-1); + rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths); if(rv == -1) return -errno; @@ -93,7 +95,7 @@ _link(const fs::find::Func searchFunc, for(fs::Paths::const_iterator i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i) { - rv = _single_link(searchFunc,srcmounts,i->base,oldpath,newpath); + rv = _single_link(searchFunc,srcmounts,minfreespace,i->base,oldpath,newpath); if(rv == -1) error = errno; } @@ -117,6 +119,7 @@ namespace mergerfs return _link(*config.getattr, *config.link, config.srcmounts, + config.minfreespace, from, to); } diff --git a/src/listxattr.cpp b/src/listxattr.cpp index e29b7168..dcfdb17d 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -71,6 +71,7 @@ static int _listxattr(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, char *list, const size_t size) @@ -79,7 +80,7 @@ _listxattr(const fs::find::Func searchFunc, int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -103,8 +104,7 @@ namespace mergerfs const config::Config &config = config::get(); if(fusepath == config.controlfile) - return _listxattr_controlfile(list, - size); + return _listxattr_controlfile(list,size); const struct fuse_context *fc = fuse_get_context(); const ugid::SetResetGuard ugid(fc->uid,fc->gid); @@ -112,6 +112,7 @@ namespace mergerfs return _listxattr(*config.listxattr, config.srcmounts, + config.minfreespace, fusepath, list, size); diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 6b209162..6d063a48 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -44,6 +44,7 @@ int _mkdir(const fs::find::Func searchFunc, const fs::find::Func createFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const mode_t mode) { @@ -55,11 +56,11 @@ _mkdir(const fs::find::Func searchFunc, fs::Paths existingpath; dirname = fs::dirname(fusepath); - rv = searchFunc(srcmounts,dirname,existingpath,1); + rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); if(rv == -1) return -errno; - rv = createFunc(srcmounts,dirname,createpaths,-1); + rv = createFunc(srcmounts,dirname,minfreespace,createpaths); if(rv == -1) return -errno; @@ -99,6 +100,7 @@ namespace mergerfs return _mkdir(*config.getattr, *config.mkdir, config.srcmounts, + config.minfreespace, fusepath, (mode & ~fc->umask)); } diff --git a/src/mknod.cpp b/src/mknod.cpp index 647b9720..17d4e171 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -46,6 +46,7 @@ int _mknod(const fs::find::Func searchFunc, const fs::find::Func createFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const mode_t mode, const dev_t dev) @@ -58,11 +59,11 @@ _mknod(const fs::find::Func searchFunc, fs::Paths existingpath; dirname = fs::dirname(fusepath); - rv = searchFunc(srcmounts,dirname,existingpath,1); + rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); if(rv == -1) return -errno; - rv = createFunc(srcmounts,dirname,createpaths,-1); + rv = createFunc(srcmounts,dirname,minfreespace,createpaths); if(rv == -1) return -errno; @@ -103,6 +104,7 @@ namespace mergerfs return _mknod(*config.getattr, *config.mknod, config.srcmounts, + config.minfreespace, fusepath, (mode & ~fc->umask), rdev); diff --git a/src/open.cpp b/src/open.cpp index ac632ece..b918908d 100644 --- a/src/open.cpp +++ b/src/open.cpp @@ -43,6 +43,7 @@ static int _open(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const int flags, uint64_t &fh) @@ -51,7 +52,7 @@ _open(const fs::find::Func searchFunc, int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -79,6 +80,7 @@ namespace mergerfs return _open(*config.open, config.srcmounts, + config.minfreespace, fusepath, fileinfo->flags, fileinfo->fh); diff --git a/src/option_parser.cpp b/src/option_parser.cpp index 27cb1f00..9c5c16de 100644 --- a/src/option_parser.cpp +++ b/src/option_parser.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,38 @@ set_default_options(struct fuse_args &args) set_option(args,"atomic_o_trunc"); } +static +int +parse_and_process_minfreespace(const std::string &value, + size_t &minfreespace) +{ + char *endptr; + + minfreespace = strtoll(value.c_str(),&endptr,10); + switch(*endptr) + { + case 'k': + case 'K': + minfreespace *= 1024; + break; + + case 'm': + case 'M': + minfreespace *= (1024 * 1024); + break; + + case 'b': + case 'B': + minfreespace *= (1024 * 1024 * 1024); + break; + + default: + return 1; + } + + return 0; +} + static int parse_and_process_arg(config::Config &config, @@ -121,19 +154,22 @@ parse_and_process_kv_arg(config::Config &config, const std::string &key, const std::string &value) { - int rv; + int rv = -1; std::vector keypart; str::split(keypart,key,'.'); - if(keypart.size() != 2) - return 1; - - if(keypart[0] == "func") - rv = config.set_func_policy(keypart[1],value); - else if(keypart[0] == "category") - rv = config.set_category_policy(keypart[1],value); + if(keypart.size() == 2) + { + if(keypart[0] == "func") + rv = config.set_func_policy(keypart[1],value); + else if(keypart[0] == "category") + rv = config.set_category_policy(keypart[1],value); + } else - rv = -1; + { + if(key == "minfreespace") + rv = parse_and_process_minfreespace(value,config.minfreespace); + } if(rv == -1) rv = 1; diff --git a/src/readlink.cpp b/src/readlink.cpp index d22d5f2a..223abb9f 100644 --- a/src/readlink.cpp +++ b/src/readlink.cpp @@ -43,6 +43,7 @@ static int _readlink(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, char *buf, const size_t size) @@ -50,7 +51,7 @@ _readlink(const fs::find::Func searchFunc, int rv; fs::Paths path; - rv = searchFunc(srcmounts,fusepath,path,1); + rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) return -errno; @@ -79,6 +80,7 @@ namespace mergerfs return _readlink(*config.readlink, config.srcmounts, + config.minfreespace, fusepath, buf, size); diff --git a/src/removexattr.cpp b/src/removexattr.cpp index 9066df44..4c2cc6ef 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -43,6 +43,7 @@ static int _removexattr(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const char *attrname) { @@ -51,7 +52,7 @@ _removexattr(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -89,6 +90,7 @@ namespace mergerfs return _removexattr(*config.removexattr, config.srcmounts, + config.minfreespace, fusepath, attrname); } diff --git a/src/rename.cpp b/src/rename.cpp index f1b53093..f1f6e9f8 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -43,6 +43,7 @@ static int _single_rename(const fs::find::Func searchFunc, const vector &srcmounts, + const size_t minfreespace, const fs::Path &oldpath, const string &newpath) { @@ -56,7 +57,7 @@ _single_rename(const fs::find::Func searchFunc, fs::Paths newpathdir; dirname = fs::dirname(newpath); - rv = searchFunc(srcmounts,dirname,newpathdir,1); + rv = searchFunc(srcmounts,dirname,minfreespace,newpathdir); if(rv == -1) return -1; @@ -76,6 +77,7 @@ int _rename(const fs::find::Func searchFunc, const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &oldpath, const string &newpath) { @@ -83,7 +85,7 @@ _rename(const fs::find::Func searchFunc, int error; fs::Paths oldpaths; - rv = actionFunc(srcmounts,oldpath,oldpaths,-1); + rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths); if(rv == -1) return -errno; @@ -91,7 +93,7 @@ _rename(const fs::find::Func searchFunc, for(fs::Paths::const_iterator i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i) { - rv = _single_rename(searchFunc,srcmounts,*i,newpath); + rv = _single_rename(searchFunc,srcmounts,minfreespace,*i,newpath); if(rv == -1) error = errno; } @@ -115,6 +117,7 @@ namespace mergerfs return _rename(*config.getattr, *config.rename, config.srcmounts, + config.minfreespace, oldpath, newpath); } diff --git a/src/rmdir.cpp b/src/rmdir.cpp index 2c4959fb..79558872 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -42,13 +42,14 @@ static int _rmdir(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath) { int rv; int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -78,6 +79,7 @@ namespace mergerfs return _rmdir(*config.rmdir, config.srcmounts, + config.minfreespace, fusepath); } } diff --git a/src/setxattr.cpp b/src/setxattr.cpp index 72315b05..b144d583 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -242,6 +242,7 @@ static int _setxattr(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const char *attrname, const char *attrval, @@ -253,7 +254,7 @@ _setxattr(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -302,6 +303,7 @@ namespace mergerfs return _setxattr(*config.setxattr, config.srcmounts, + config.minfreespace, fusepath, attrname, attrval, diff --git a/src/symlink.cpp b/src/symlink.cpp index 8ae96e05..b897ee32 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -41,6 +41,7 @@ static int _symlink(const fs::find::Func createFunc, const vector &srcmounts, + const size_t minfreespace, const string &oldpath, const string &newpath) { @@ -50,7 +51,7 @@ _symlink(const fs::find::Func createFunc, fs::Paths newpathdirs; newpathdir = fs::dirname(newpath); - rv = createFunc(srcmounts,newpathdir,newpathdirs,-1); + rv = createFunc(srcmounts,newpathdir,minfreespace,newpathdirs); if(rv == -1) return -errno; @@ -83,6 +84,7 @@ namespace mergerfs return _symlink(*config.symlink, config.srcmounts, + config.minfreespace, oldpath, newpath); } diff --git a/src/truncate.cpp b/src/truncate.cpp index c4ef8cbb..ab1ced6e 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -43,6 +43,7 @@ static int _truncate(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const off_t size) { @@ -50,7 +51,7 @@ _truncate(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -81,6 +82,7 @@ namespace mergerfs return _truncate(*config.truncate, config.srcmounts, + config.minfreespace, fusepath, size); } diff --git a/src/unlink.cpp b/src/unlink.cpp index a2ba191b..39aec2ce 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -42,13 +42,14 @@ static int _unlink(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath) { int rv; int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -78,6 +79,7 @@ namespace mergerfs return _unlink(*config.unlink, config.srcmounts, + config.minfreespace, fusepath); } } diff --git a/src/utimens.cpp b/src/utimens.cpp index 45b3e564..7d9185c6 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -43,6 +43,7 @@ static int _utimens(const fs::find::Func actionFunc, const vector &srcmounts, + const size_t minfreespace, const string &fusepath, const struct timespec ts[2]) { @@ -50,7 +51,7 @@ _utimens(const fs::find::Func actionFunc, int error; fs::Paths paths; - rv = actionFunc(srcmounts,fusepath,paths,-1); + rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; @@ -81,6 +82,7 @@ namespace mergerfs return _utimens(*config.utimens, config.srcmounts, + config.minfreespace, fusepath, ts); }