|
|
@ -52,6 +52,17 @@ enum |
|
|
|
MERGERFS_OPT_VERSION |
|
|
|
}; |
|
|
|
|
|
|
|
struct KV |
|
|
|
{ |
|
|
|
std::string key; |
|
|
|
std::string val; |
|
|
|
}; |
|
|
|
|
|
|
|
struct OptData |
|
|
|
{ |
|
|
|
std::vector<KV> opts; |
|
|
|
Config::ErrVec *errs; |
|
|
|
}; |
|
|
|
|
|
|
|
static |
|
|
|
void |
|
|
@ -113,39 +124,9 @@ _set_default_options(fuse_args *args_) |
|
|
|
SysLog::notice("not auto setting allow_other since not running as root"); |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
bool |
|
|
|
_should_ignore(const std::string &key_) |
|
|
|
{ |
|
|
|
constexpr const std::array<std::string_view,13> ignored_keys = |
|
|
|
{ |
|
|
|
"atomic_o_trunc", |
|
|
|
"big_writes", |
|
|
|
"cache.open", |
|
|
|
"defaults", |
|
|
|
"hard_remove", |
|
|
|
"no_splice_move", |
|
|
|
"no_splice_read", |
|
|
|
"no_splice_write", |
|
|
|
"nonempty", |
|
|
|
"splice_move", |
|
|
|
"splice_read", |
|
|
|
"splice_write", |
|
|
|
"use_ino", |
|
|
|
}; |
|
|
|
|
|
|
|
for(const auto &key : ignored_keys) |
|
|
|
{ |
|
|
|
if(key == key_) |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
int |
|
|
|
_parse_and_process_kv_arg(Config::ErrVec *errs_, |
|
|
|
_parse_and_process_kv_arg(OptData *optdata_, |
|
|
|
const std::string &key_, |
|
|
|
const std::string &val_) |
|
|
|
{ |
|
|
@ -155,7 +136,7 @@ _parse_and_process_kv_arg(Config::ErrVec *errs_, |
|
|
|
|
|
|
|
rv = 0; |
|
|
|
if(key == "config") |
|
|
|
return ((cfg.from_file(val_,errs_) < 0) ? 1 : 0); |
|
|
|
return ((cfg.from_file(val_,optdata_->errs) < 0) ? 1 : 0); |
|
|
|
ef(key == "attr_timeout") |
|
|
|
key = "cache.attr"; |
|
|
|
ef(key == "entry_timeout") |
|
|
@ -174,22 +155,20 @@ _parse_and_process_kv_arg(Config::ErrVec *errs_, |
|
|
|
{key = "async_read", val = "false";} |
|
|
|
ef(key == "noforget" && val.empty()) |
|
|
|
{key = "remember-nodes", val = "-1";} |
|
|
|
ef(::_should_ignore(key_)) |
|
|
|
return 0; |
|
|
|
|
|
|
|
if(cfg.has_key(key) == false) |
|
|
|
return 1; |
|
|
|
|
|
|
|
rv = cfg.set(key,val); |
|
|
|
if(rv) |
|
|
|
errs_->push_back({rv,key+'='+val}); |
|
|
|
optdata_->errs->push_back({rv,key+'='+val}); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
int |
|
|
|
_process_opt(Config::ErrVec *errs_, |
|
|
|
_process_opt(OptData *optdata_, |
|
|
|
const std::string &arg_) |
|
|
|
{ |
|
|
|
std::string key; |
|
|
@ -199,7 +178,7 @@ _process_opt(Config::ErrVec *errs_, |
|
|
|
key = str::trim(key); |
|
|
|
val = str::trim(val); |
|
|
|
|
|
|
|
return ::_parse_and_process_kv_arg(errs_,key,val); |
|
|
|
return ::_parse_and_process_kv_arg(optdata_,key,val); |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
@ -277,18 +256,18 @@ _option_processor(void *data_, |
|
|
|
int key_, |
|
|
|
fuse_args *outargs_) |
|
|
|
{ |
|
|
|
Config::ErrVec *errs = (Config::ErrVec*)data_; |
|
|
|
OptData &optdata = *(OptData*)data_; |
|
|
|
|
|
|
|
switch(key_) |
|
|
|
{ |
|
|
|
case FUSE_OPT_KEY_OPT: |
|
|
|
return ::_process_opt(errs,arg_); |
|
|
|
return ::_process_opt(&optdata,arg_); |
|
|
|
|
|
|
|
case FUSE_OPT_KEY_NONOPT: |
|
|
|
if(cfg.branches->empty()) |
|
|
|
return ::_process_branches(errs,arg_); |
|
|
|
return ::_process_branches(optdata.errs,arg_); |
|
|
|
else |
|
|
|
return ::_process_mount(errs,arg_); |
|
|
|
return ::_process_mount(optdata.errs,arg_); |
|
|
|
|
|
|
|
case MERGERFS_OPT_HELP: |
|
|
|
::_usage(); |
|
|
@ -398,6 +377,7 @@ namespace options |
|
|
|
parse(fuse_args *args_, |
|
|
|
Config::ErrVec *errs_) |
|
|
|
{ |
|
|
|
OptData optdata; |
|
|
|
const struct fuse_opt opts[] = |
|
|
|
{ |
|
|
|
FUSE_OPT_KEY("-h",MERGERFS_OPT_HELP), |
|
|
@ -408,8 +388,9 @@ namespace options |
|
|
|
{NULL,-1U,0} |
|
|
|
}; |
|
|
|
|
|
|
|
optdata.errs = errs_; |
|
|
|
fuse_opt_parse(args_, |
|
|
|
errs_, |
|
|
|
&optdata, |
|
|
|
opts, |
|
|
|
::_option_processor); |
|
|
|
|
|
|
|