mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
use {get,list,set}xattr to modify runtime
This commit is contained in:
parent
428dd8c877
commit
97ce6f5f21
4 changed files with 138 additions and 4 deletions
|
|
@ -37,6 +37,65 @@
|
|||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
using namespace mergerfs;
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr_controlfile(config::Config &config,
|
||||
const string attrname,
|
||||
const string attrval,
|
||||
const size_t attrvalsize,
|
||||
const int flags)
|
||||
{
|
||||
#ifndef WITHOUT_XATTR
|
||||
if(attrname == "user.mergerfs.action")
|
||||
{
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
if(Policy::Action::fromString(attrval) != -1)
|
||||
config.policy.action = attrval;
|
||||
else
|
||||
return -ENOSPC;
|
||||
}
|
||||
else if(attrname == "user.mergerfs.create")
|
||||
{
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
if(Policy::Create::fromString(attrval) != -1)
|
||||
config.policy.create = attrval;
|
||||
else
|
||||
return -ENOSPC;
|
||||
}
|
||||
else if(attrname == "user.mergerfs.search")
|
||||
{
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
if(Policy::Search::fromString(attrval) != -1)
|
||||
config.policy.search = attrval;
|
||||
else
|
||||
return -ENOSPC;
|
||||
}
|
||||
else if(attrname == "user.mergerfs.statfs")
|
||||
{
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
if(Policy::StatFS::fromString(attrval) != -1)
|
||||
config.policy.statfs = attrval;
|
||||
else
|
||||
return -ENOSPC;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ENOATTR;
|
||||
}
|
||||
|
||||
config.updateReadStr();
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
|
|
@ -87,7 +146,11 @@ namespace mergerfs
|
|||
const config::Config &config = config::get();
|
||||
|
||||
if(fusepath == config.controlfile)
|
||||
return -ENOTSUP;
|
||||
return _setxattr_controlfile(config::get_writable(),
|
||||
attrname,
|
||||
string(attrval,attrvalsize),
|
||||
attrvalsize,
|
||||
flags);
|
||||
|
||||
return _setxattr(config.policy.action,
|
||||
config.srcmounts,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue