Browse Source

Fix loading readonly / write once options from file

pull/1156/head
Antonio SJ Musumeci 2 years ago
parent
commit
1c5b0f2f5f
  1. 18
      src/config.cpp
  2. 7
      src/config.hpp
  3. 5
      src/option_parser.cpp

18
src/config.cpp

@ -63,10 +63,13 @@ namespace l
IFERT("mount"); IFERT("mount");
IFERT("nullrw"); IFERT("nullrw");
IFERT("pid"); IFERT("pid");
IFERT("pin-threads");
IFERT("process-thread-count");
IFERT("read-thread-count");
IFERT("readdirplus"); IFERT("readdirplus");
IFERT("scheduling-priority");
IFERT("threads"); IFERT("threads");
IFERT("version"); IFERT("version");
IFERT("scheduling-priority");
return false; return false;
} }
@ -118,9 +121,11 @@ Config::Config()
symlinkify_timeout(3600), symlinkify_timeout(3600),
fuse_read_thread_count(-1), fuse_read_thread_count(-1),
fuse_process_thread_count(-1), fuse_process_thread_count(-1),
fuse_pin_threads("false"),
version(MERGERFS_VERSION), version(MERGERFS_VERSION),
writeback_cache(false), writeback_cache(false),
xattr(XAttr::ENUM::PASSTHROUGH)
xattr(XAttr::ENUM::PASSTHROUGH),
_initialized(false)
{ {
_map["async_read"] = &async_read; _map["async_read"] = &async_read;
_map["auto_cache"] = &auto_cache; _map["auto_cache"] = &auto_cache;
@ -176,6 +181,7 @@ Config::Config()
_map["nfsopenhack"] = &nfsopenhack; _map["nfsopenhack"] = &nfsopenhack;
_map["nullrw"] = &nullrw; _map["nullrw"] = &nullrw;
_map["pid"] = &pid; _map["pid"] = &pid;
_map["pin-threads"] = &fuse_pin_threads;
_map["posix_acl"] = &posix_acl; _map["posix_acl"] = &posix_acl;
_map["readahead"] = &readahead; _map["readahead"] = &readahead;
// _map["readdir"] = &readdir; // _map["readdir"] = &readdir;
@ -287,7 +293,7 @@ int
Config::set(const std::string &key_, Config::set(const std::string &key_,
const std::string &value_) const std::string &value_)
{ {
if(l::readonly(key_))
if(_initialized && l::readonly(key_))
return -EROFS; return -EROFS;
return set_raw(key_,value_); return set_raw(key_,value_);
@ -362,6 +368,12 @@ Config::from_file(const std::string &filepath_,
return rv; return rv;
} }
void
Config::finish_initializing()
{
_initialized = true;
}
std::ostream& std::ostream&
operator<<(std::ostream &os_, operator<<(std::ostream &os_,
const Config &c_) const Config &c_)

7
src/config.hpp

@ -146,11 +146,18 @@ public:
ConfigUINT64 symlinkify_timeout; ConfigUINT64 symlinkify_timeout;
ConfigINT fuse_read_thread_count; ConfigINT fuse_read_thread_count;
ConfigINT fuse_process_thread_count; ConfigINT fuse_process_thread_count;
ConfigSTR fuse_pin_threads;
ConfigSTR version; ConfigSTR version;
ConfigBOOL writeback_cache; ConfigBOOL writeback_cache;
XAttr xattr; XAttr xattr;
private:
bool _initialized;
public:
void finish_initializing();
public: public:
friend std::ostream& operator<<(std::ostream &s, friend std::ostream& operator<<(std::ostream &s,
const Config &c); const Config &c);

5
src/option_parser.cpp

@ -82,6 +82,7 @@ set_fuse_threads(Config::Write &cfg_,
{ {
set_kv_option("read-thread-count",cfg_->fuse_read_thread_count.to_string(),args_); set_kv_option("read-thread-count",cfg_->fuse_read_thread_count.to_string(),args_);
set_kv_option("process-thread-count",cfg_->fuse_process_thread_count.to_string(),args_); set_kv_option("process-thread-count",cfg_->fuse_process_thread_count.to_string(),args_);
set_kv_option("pin-threads",cfg_->fuse_pin_threads.to_string(),args_);
} }
static static
@ -135,7 +136,7 @@ should_ignore(const std::string &key_)
"splice_move", "splice_move",
"splice_read", "splice_read",
"splice_write", "splice_write",
"use_ino"
"use_ino",
}; };
return (IGNORED_KEYS.find(key_) != IGNORED_KEYS.end()); return (IGNORED_KEYS.find(key_) != IGNORED_KEYS.end());
@ -431,5 +432,7 @@ namespace options
set_fsname(cfg,args_); set_fsname(cfg,args_);
set_subtype(args_); set_subtype(args_);
set_fuse_threads(cfg,args_); set_fuse_threads(cfg,args_);
cfg->finish_initializing();
} }
} }
Loading…
Cancel
Save