mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-03 21:30:11 -05:00
Further tweaks to config parsing and error reporting (#1559)
* Further tweaks to config parsing and error reporting * Fix static builds
This commit is contained in:
parent
ec16d07fba
commit
2412ae7316
12 changed files with 60 additions and 59 deletions
|
|
@ -173,6 +173,7 @@ Config::Config()
|
|||
nullrw.ro =
|
||||
pid.ro =
|
||||
pin_threads.ro =
|
||||
posix_acl.ro =
|
||||
process_thread_count.ro =
|
||||
process_thread_queue_depth.ro =
|
||||
read_thread_count.ro =
|
||||
|
|
@ -180,9 +181,9 @@ Config::Config()
|
|||
srcmounts.ro =
|
||||
version.ro =
|
||||
true;
|
||||
congestion_threshold.ro =
|
||||
congestion_threshold.display =
|
||||
gid.display =
|
||||
max_background.ro =
|
||||
max_background.display =
|
||||
threads.display =
|
||||
_mount.display =
|
||||
uid.display =
|
||||
|
|
@ -389,6 +390,7 @@ Config::get(const std::string &key_,
|
|||
|
||||
key = str::replace(key_,'_','-');
|
||||
|
||||
|
||||
i = _map.find(key);
|
||||
if(i == _map.end())
|
||||
return -ENOATTR;
|
||||
|
|
@ -434,8 +436,6 @@ Config::from_stream(std::istream &istrm_)
|
|||
{
|
||||
int rv;
|
||||
std::string line;
|
||||
std::string key;
|
||||
std::string val;
|
||||
Config::ErrVec new_errs;
|
||||
|
||||
while(std::getline(istrm_,line,'\n'))
|
||||
|
|
@ -444,13 +444,9 @@ Config::from_stream(std::istream &istrm_)
|
|||
if(line.empty() || (line[0] == '#'))
|
||||
continue;
|
||||
|
||||
str::splitkv(line,'=',&key,&val);
|
||||
key = str::trim(key);
|
||||
val = str::trim(val);
|
||||
|
||||
rv = set(key,val);
|
||||
rv = set(line);
|
||||
if(rv < 0)
|
||||
new_errs.push_back({-rv,key+'='+val});
|
||||
new_errs.push_back({-rv,line});
|
||||
}
|
||||
|
||||
rv = (new_errs.empty() ? 0 : -EINVAL);
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ _main(int argc_,
|
|||
std::string s = err.to_string();
|
||||
|
||||
SysLog::error("error: {}",s);
|
||||
fmt::println(stderr,"* ERROR: {}",s);
|
||||
fmt::println(stderr,"mergerfs: ERROR - {}",s);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -119,37 +119,19 @@ _set_default_options(fuse_args *args_)
|
|||
SysLog::notice("not auto setting allow_other since not running as root");
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_parse_and_process_kv_arg(const std::string &key_,
|
||||
const std::string &val_)
|
||||
{
|
||||
int rv;
|
||||
std::string key(key_);
|
||||
std::string val(val_);
|
||||
|
||||
if(cfg.has_key(key) == false)
|
||||
return 1;
|
||||
|
||||
rv = cfg.set(key,val);
|
||||
if(rv < 0)
|
||||
cfg.errs.push_back({-rv,key+'='+val});
|
||||
|
||||
return OPT_DISCARD;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_process_opt(const std::string &arg_)
|
||||
{
|
||||
std::string key;
|
||||
std::string val;
|
||||
int rv;
|
||||
|
||||
str::splitkv(arg_,'=',&key,&val);
|
||||
key = str::trim(key);
|
||||
val = str::trim(val);
|
||||
rv = cfg.set(arg_);
|
||||
if(rv == -ENOATTR)
|
||||
return OPT_KEEP;
|
||||
if(rv < 0)
|
||||
cfg.errs.push_back({-rv,arg_});
|
||||
|
||||
return ::_parse_and_process_kv_arg(key,val);
|
||||
return OPT_DISCARD;
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue