From dfa1c1ad6f0f74f1972263794c428695115e48b2 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Wed, 12 Dec 2018 15:53:53 -0500 Subject: [PATCH] check minfreespace on newest policy create --- src/policy_newest.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/policy_newest.cpp b/src/policy_newest.cpp index 6bac8c84..80931b9d 100644 --- a/src/policy_newest.cpp +++ b/src/policy_newest.cpp @@ -17,6 +17,7 @@ #include "errno.hpp" #include "fs.hpp" #include "fs_exists.hpp" +#include "fs_info.hpp" #include "fs_path.hpp" #include "policy.hpp" #include "policy_error.hpp" @@ -36,13 +37,14 @@ namespace newest int create(const Branches &branches_, const char *fusepath, + const uint64_t minfreespace, vector &paths) { int rv; int error; - bool readonly; time_t newest; struct stat st; + fs::info_t info; const Branch *branch; const string *newestbasepath; @@ -59,11 +61,13 @@ namespace newest error_and_continue(error,EROFS); if(st.st_mtime < newest) continue; - rv = fs::readonly(&branch->path,&readonly); + rv = fs::info(&branch->path,&info); if(rv == -1) error_and_continue(error,ENOENT); - if(readonly) + if(info.readonly) error_and_continue(error,EROFS); + if(info.spaceavail < minfreespace) + error_and_continue(error,ENOSPC); newest = st.st_mtime; newestbasepath = &branch->path; @@ -169,7 +173,7 @@ namespace mergerfs switch(type) { case Category::Enum::create: - return newest::create(branches_,fusepath,paths); + return newest::create(branches_,fusepath,minfreespace,paths); case Category::Enum::action: return newest::action(branches_,fusepath,paths); case Category::Enum::search: