mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
checkpoint
This commit is contained in:
parent
df393cb1ed
commit
720d75b9bd
1 changed files with 79 additions and 0 deletions
79
src/func_create_ff.cpp
Normal file
79
src/func_create_ff.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#include "func_create_ff.hpp"
|
||||
|
||||
#include "fs_info.hpp"
|
||||
#include "fs_open.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue