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:
Antonio SJ Musumeci 2019-09-24 10:27:46 -04:00
parent 8d989777f8
commit 54c41c4994
90 changed files with 3292 additions and 2619 deletions

View file

@ -19,7 +19,6 @@
#include "fs_base_stat.hpp"
#include "fs_base_statvfs.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "statvfs_util.hpp"
#include "ugid.hpp"
@ -70,22 +69,22 @@ namespace l
static
bool
should_ignore(const StatFSIgnore::Enum ignore_,
const Branch *branch_,
const bool readonly_)
should_ignore(const StatFSIgnore ignore_,
const Branch *branch_,
const bool readonly_)
{
return ((((ignore_ == StatFSIgnore::RO) || readonly_) &&
return ((((ignore_ == StatFSIgnore::ENUM::RO) || readonly_) &&
(branch_->ro_or_nc())) ||
((ignore_ == StatFSIgnore::NC) && (branch_->nc())));
((ignore_ == StatFSIgnore::ENUM::NC) && (branch_->nc())));
}
static
int
statfs(const Branches &branches_,
const char *fusepath_,
const StatFS::Enum mode_,
const StatFSIgnore::Enum ignore_,
struct statvfs *fsstat_)
statfs(const Branches &branches_,
const char *fusepath_,
const StatFS mode_,
const StatFSIgnore ignore_,
struct statvfs *fsstat_)
{
int rv;
string fullpath;
@ -101,7 +100,7 @@ namespace l
min_namemax = std::numeric_limits<unsigned long>::max();
for(size_t i = 0, ei = branches_.size(); i < ei; i++)
{
fullpath = ((mode_ == StatFS::FULL) ?
fullpath = ((mode_ == StatFS::ENUM::FULL) ?
fs::path::make(&branches_[i].path,fusepath_) :
branches_[i].path);
@ -153,10 +152,9 @@ namespace FUSE
statfs(const char *fusepath_,
struct statvfs *st_)
{
const fuse_context *fc = fuse_get_context();
const Config &config = Config::get(fc);
const ugid::Set ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.branches_lock);
const fuse_context *fc = fuse_get_context();
const Config &config = Config::ro();
const ugid::Set ugid(fc->uid,fc->gid);
return l::statfs(config.branches,
fusepath_,