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

@ -22,6 +22,7 @@
#include "fs_statvfs_cache.hpp"
#include "policy.hpp"
#include "policy_error.hpp"
#include "rwlock.hpp"
#include <limits>
#include <string>
@ -34,11 +35,13 @@ namespace eplus
{
static
int
create(const Branches &branches_,
const char *fusepath,
const uint64_t minfreespace,
vector<const string*> &paths)
create(const Branches &branches_,
const char *fusepath,
const uint64_t minfreespace,
vector<string> *paths)
{
rwlock::ReadGuard guard(&branches_.lock);
int rv;
int error;
uint64_t eplus;
@ -74,17 +77,19 @@ namespace eplus
if(eplusbasepath == NULL)
return (errno=error,-1);
paths.push_back(eplusbasepath);
paths->push_back(*eplusbasepath);
return 0;
}
static
int
action(const Branches &branches_,
const char *fusepath,
vector<const string*> &paths)
action(const Branches &branches_,
const char *fusepath,
vector<string> *paths)
{
rwlock::ReadGuard guard(&branches_.lock);
int rv;
int error;
uint64_t eplus;
@ -118,17 +123,19 @@ namespace eplus
if(eplusbasepath == NULL)
return (errno=error,-1);
paths.push_back(eplusbasepath);
paths->push_back(*eplusbasepath);
return 0;
}
static
int
search(const Branches &branches_,
const char *fusepath,
vector<const string*> &paths)
search(const Branches &branches_,
const char *fusepath,
vector<string> *paths)
{
rwlock::ReadGuard guard(&branches_.lock);
int rv;
uint64_t eplus;
uint64_t spaceused;
@ -156,7 +163,7 @@ namespace eplus
if(eplusbasepath == NULL)
return (errno=ENOENT,-1);
paths.push_back(eplusbasepath);
paths->push_back(*eplusbasepath);
return 0;
}
@ -167,7 +174,7 @@ Policy::Func::eplus(const Category::Enum::Type type,
const Branches &branches_,
const char *fusepath,
const uint64_t minfreespace,
vector<const string*> &paths)
vector<string> *paths)
{
switch(type)
{