Browse Source

fix setting of fsname

pull/615/head
Antonio SJ Musumeci 6 years ago
parent
commit
e052446713
  1. 1
      src/config.hpp
  2. 46
      src/option_parser.cpp

1
src/config.hpp

@ -61,6 +61,7 @@ public:
const std::string &policy_); const std::string &policy_);
public: public:
std::string fsname;
std::string destmount; std::string destmount;
Branches branches; Branches branches;
mutable pthread_rwlock_t branches_lock; mutable pthread_rwlock_t branches_lock;

46
src/option_parser.cpp

@ -46,6 +46,7 @@ enum
MERGERFS_OPT_VERSION MERGERFS_OPT_VERSION
}; };
static static
void void
set_option(fuse_args *args, set_option(fuse_args *args,
@ -71,21 +72,20 @@ set_kv_option(fuse_args *args,
static static
void void
set_fsname(fuse_args *args,
const Branches &branches_)
set_fsname(fuse_args *args_,
Config *config_)
{ {
vector<string> branches;
branches_.to_paths(branches);
if(branches.size() > 0)
if(config_->fsname.empty())
{ {
std::string fsname;
vector<string> branches;
fsname = str::remove_common_prefix_and_join(branches,':');
config_->branches.to_paths(branches);
set_kv_option(args,"fsname",fsname);
if(branches.size() > 0)
config_->fsname = str::remove_common_prefix_and_join(branches,':');
} }
set_kv_option(args_,"fsname",config_->fsname);
} }
static static
@ -147,6 +147,16 @@ parse_and_process(const std::string &value,
return 0; return 0;
} }
static
int
parse_and_process(const std::string &value_,
std::string &str_)
{
str_ = value_;
return 0;
}
static static
int int
parse_and_process_errno(const std::string &value_, parse_and_process_errno(const std::string &value_,
@ -293,6 +303,8 @@ parse_and_process_kv_arg(Config &config,
rv = parse_and_process_statfs(value,config.statfs); rv = parse_and_process_statfs(value,config.statfs);
else if(key == "statfs_ignore") else if(key == "statfs_ignore")
rv = parse_and_process_statfsignore(value,config.statfs_ignore); rv = parse_and_process_statfsignore(value,config.statfs_ignore);
else if(key == "fsname")
rv = parse_and_process(value,config.fsname);
} }
if(rv == -1) if(rv == -1)
@ -470,8 +482,8 @@ option_processor(void *data,
namespace options namespace options
{ {
void void
parse(fuse_args *args,
Config *config)
parse(fuse_args *args_,
Config *config_)
{ {
const struct fuse_opt opts[] = const struct fuse_opt opts[] =
{ {
@ -483,13 +495,13 @@ namespace options
{NULL,-1U,0} {NULL,-1U,0}
}; };
fuse_opt_parse(args,
config,
fuse_opt_parse(args_,
config_,
opts, opts,
::option_processor); ::option_processor);
set_default_options(args);
set_fsname(args,config->branches);
set_subtype(args);
set_default_options(args_);
set_fsname(args_,config_);
set_subtype(args_);
} }
} }
Loading…
Cancel
Save