From 720d75b9bde8455115561b5df1dd9fd344d493e0 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 4 Feb 2024 01:19:44 -0600 Subject: [PATCH] checkpoint --- src/func_create_ff.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/func_create_ff.cpp diff --git a/src/func_create_ff.cpp b/src/func_create_ff.cpp new file mode 100644 index 00000000..325324d2 --- /dev/null +++ b/src/func_create_ff.cpp @@ -0,0 +1,79 @@ +#include "func_create_ff.hpp" + +#include "fs_info.hpp" +#include "fs_open.hpp" +#include "ugid.hpp" + +#include + + +Func::CreateFF::CreateFF() +{ + +} + +Func::CreateFF::~CreateFF() +{ + +} + +namespace l +{ + static + int + create(Branches2 &branches_, + char const *fusepath_, + mode_t const mode_, + mode_t const umask_, + fuse_file_info_t *ffi_) + { + int rv; + fs::info_t info; + + for(auto &tier : branches_) + { + for(auto &branch : tier) + { + if(branch.mode != +Branch2::Mode::RW) + continue; + rv = fs::info(branch.path,&info); + if(rv == -1) + continue; + if(info.readonly) + continue; + if(info.spaceavail < branch.min_free_space) + continue; + + ghc::filesystem::path fullpath; + + fullpath = branch.path / fusepath_; + + rv = fs::open(fullpath,ffi_->flags,mode_); + if((rv == -1) && (errno == EROFS)) + { + branch.mode = Branch2::Mode::RO; + continue; + } + + return rv; + } + } + + return rv; + } +} + +int +Func::CreateFF::operator()(Branches2 &branches_, + char const *fusepath_, + mode_t const mode_, + fuse_file_info_t *ffi_) +{ + int rv; + fuse_context const *fc = fuse_get_context(); + ugid::Set const ugid(fc->uid,fc->gid); + + rv = l::create(branches_,fusepath_,mode_,fc->umask,ffi_); + + return rv; +}