mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
rework config management
* Add standard way to do str2val and val2str conversion * Add support for a config file * Add support for reading and writing settings via ioctl
This commit is contained in:
parent
8d989777f8
commit
54c41c4994
90 changed files with 3292 additions and 2619 deletions
|
|
@ -20,7 +20,6 @@
|
|||
#include "fs_movefile.hpp"
|
||||
#include "fuse_write.hpp"
|
||||
#include "policy.hpp"
|
||||
#include "rwlock.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include <fuse.h>
|
||||
|
|
@ -61,6 +60,28 @@ namespace l
|
|||
|
||||
return fuse_buf_copy(&dst,src_,cpflags);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
move_and_write_buf(fuse_bufvec *src_,
|
||||
off_t offset_,
|
||||
FileInfo *fi_)
|
||||
{
|
||||
int rv;
|
||||
uint64_t extra;
|
||||
vector<string> paths;
|
||||
const ugid::Set ugid(0,0);
|
||||
const Config &config = Config::ro();
|
||||
|
||||
config.branches.to_paths(paths);
|
||||
|
||||
extra = fuse_buf_size(src_);
|
||||
rv = fs::movefile(paths,fi_->fusepath,extra,fi_->fd);
|
||||
if(rv == -1)
|
||||
return -ENOSPC;
|
||||
|
||||
return l::write_buf(fi_->fd,src_,offset_);
|
||||
}
|
||||
}
|
||||
|
||||
namespace FUSE
|
||||
|
|
@ -76,27 +97,7 @@ namespace FUSE
|
|||
|
||||
rv = l::write_buf(fi->fd,src_,offset_);
|
||||
if(l::out_of_space(-rv))
|
||||
{
|
||||
const fuse_context *fc = fuse_get_context();
|
||||
const Config &config = Config::get(fc);
|
||||
|
||||
if(config.moveonenospc)
|
||||
{
|
||||
size_t extra;
|
||||
vector<string> paths;
|
||||
const ugid::Set ugid(0,0);
|
||||
const rwlock::ReadGuard readlock(&config.branches_lock);
|
||||
|
||||
config.branches.to_paths(paths);
|
||||
|
||||
extra = fuse_buf_size(src_);
|
||||
rv = fs::movefile(paths,fi->fusepath,extra,fi->fd);
|
||||
if(rv == -1)
|
||||
return -ENOSPC;
|
||||
|
||||
rv = l::write_buf(fi->fd,src_,offset_);
|
||||
}
|
||||
}
|
||||
rv = l::move_and_write_buf(src_,offset_,fi);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue