support runtime setting of srcmounts. closes #12

This commit is contained in:
Antonio SJ Musumeci 2014-08-03 15:50:28 -04:00
parent 992e05e897
commit 7e9ccd0317
34 changed files with 538 additions and 149 deletions

View file

@ -34,8 +34,9 @@
#include "config.hpp"
#include "fs.hpp"
#include "ugid.hpp"
#include "assert.hpp"
#include "rwlock.hpp"
#include "xattr.hpp"
#include "str.hpp"
using std::string;
using std::vector;
@ -57,6 +58,8 @@ _getxattr_controlfile(const Config &config,
attrvalue = (std::string)*config.create;
else if(attrname == "user.mergerfs.search")
attrvalue = (std::string)*config.search;
else if(attrname == "user.mergerfs.srcmounts")
attrvalue = str::join(config.srcmounts,':');
if(attrvalue.empty())
return -ENOATTR;
@ -133,9 +136,7 @@ namespace mergerfs
char *buf,
size_t count)
{
const struct fuse_context *fc = fuse_get_context();
const config::Config &config = config::get();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const config::Config &config = config::get();
if(fusepath == config.controlfile)
return _getxattr_controlfile(config,
@ -143,6 +144,10 @@ namespace mergerfs
buf,
count);
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _getxattr(*config.search,
config.srcmounts,
fusepath,