Browse Source

Further tweaks to config parsing and error reporting

pull/1559/head
Antonio SJ Musumeci 2 weeks ago
parent
commit
95d472b045
  1. 2
      libfuse/lib/fuse_lowlevel.cpp
  2. 16
      src/config.cpp
  3. 2
      src/mergerfs.cpp
  4. 28
      src/option_parser.cpp

2
libfuse/lib/fuse_lowlevel.cpp

@ -1863,7 +1863,7 @@ fuse_ll_opt_proc(void *data_,
int key_,
struct fuse_args *outargs_)
{
fmt::print(stderr, "* ERROR: unknown option '{}'\n", arg_);
fmt::print(stderr, "fuse: ERROR - unknown option - '{}'\n", arg_);
return -1;
}

16
src/config.cpp

@ -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);

2
src/mergerfs.cpp

@ -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;

28
src/option_parser.cpp

@ -121,37 +121,19 @@ _set_default_options(fuse_args *args_)
static
int
_parse_and_process_kv_arg(const std::string &key_,
const std::string &val_)
_process_opt(const std::string &arg_)
{
int rv;
std::string key(key_);
std::string val(val_);
if(cfg.has_key(key) == false)
return 1;
rv = cfg.set(key,val);
rv = cfg.set(arg_);
if(rv == -ENOATTR)
return OPT_KEEP;
if(rv < 0)
cfg.errs.push_back({-rv,key+'='+val});
cfg.errs.push_back({-rv,arg_});
return OPT_DISCARD;
}
static
int
_process_opt(const std::string &arg_)
{
std::string key;
std::string val;
str::splitkv(arg_,'=',&key,&val);
key = str::trim(key);
val = str::trim(val);
return ::_parse_and_process_kv_arg(key,val);
}
static
void
_usage(void)

Loading…
Cancel
Save