Fix mount information reported to operating system

This commit is contained in:
Sebastian Messmer 2016-06-22 17:57:00 -07:00
parent e4501d51e5
commit 3db931c54d
2 changed files with 8 additions and 3 deletions

View File

@ -260,9 +260,13 @@ void Fuse::_add_fuse_option_if_not_exists(vector<char *> *argv, const string &ke
}
bool Fuse::_has_option(const vector<char *> &vec, const string &key) {
string key_with_prefix = key + "+";
auto found = std::find_if(vec.begin(), vec.end(), [&key_with_prefix](const char *entry) {
return std::strncmp(key_with_prefix.c_str(), entry, key_with_prefix.size());
// The fuse option can either be present as "-okey=value" or as "-o key=value", we have to check both.
return _has_entry_with_prefix(key + "=", vec) || _has_entry_with_prefix("-o" + key + "=", vec);
}
bool Fuse::_has_entry_with_prefix(const string &prefix, const vector<char *> &vec) {
auto found = std::find_if(vec.begin(), vec.end(), [&prefix](const char *entry) {
return 0 == std::strncmp(prefix.c_str(), entry, prefix.size());
});
return found != vec.end();
}

View File

@ -62,6 +62,7 @@ private:
static void _logUnknownException();
static char *_create_c_string(const std::string &str);
static bool _has_option(const std::vector<char *> &vec, const std::string &key);
static bool _has_entry_with_prefix(const std::string &prefix, const std::vector<char *> &vec);
std::vector<char *> _build_argv(const boost::filesystem::path &mountdir, const std::vector<std::string> &fuseOptions);
void _add_fuse_option_if_not_exists(std::vector<char *> *argv, const std::string &key, const std::string &value);