config: rework global config, remove rwlock, make branches RCU like

Also added unit tests. Should have done separately but found a number of bugs.
This commit is contained in:
Antonio SJ Musumeci 2020-12-19 15:06:08 -05:00
parent 2e4c6c5fd1
commit 538467b86d
327 changed files with 6691 additions and 3036 deletions

View file

@ -24,7 +24,8 @@
#include "rwlock.hpp"
#include "ugid.hpp"
#include <fuse.h>
#include "fuse.h"
namespace FUSE
{
@ -32,25 +33,25 @@ namespace FUSE
readdir_plus(const fuse_file_info_t *ffi_,
fuse_dirents_t *buf_)
{
DirInfo *di = reinterpret_cast<DirInfo*>(ffi_->fh);
const fuse_context *fc = fuse_get_context();
const Config &config = Config::ro();
Config::Read cfg;
DirInfo *di = reinterpret_cast<DirInfo*>(ffi_->fh);
const fuse_context *fc = fuse_get_context();
const ugid::Set ugid(fc->uid,fc->gid);
switch(config.readdir)
switch(cfg->readdir)
{
case ReadDir::ENUM::LINUX:
return FUSE::readdir_plus_linux(config.branches,
return FUSE::readdir_plus_linux(cfg->branches,
di->fusepath.c_str(),
config.cache_entry,
config.cache_attr,
cfg->cache_entry,
cfg->cache_attr,
buf_);
default:
case ReadDir::ENUM::POSIX:
return FUSE::readdir_plus_posix(config.branches,
return FUSE::readdir_plus_posix(cfg->branches,
di->fusepath.c_str(),
config.cache_entry,
config.cache_attr,
cfg->cache_entry,
cfg->cache_attr,
buf_);
}
}