Browse Source

Merge pull request #139 from trapexit/setxattr-cleanup

cleanup controlfile manipulation
pull/144/head
Antonio SJ Musumeci 9 years ago
parent
commit
1cc1b1f746
  1. 37
      src/setxattr.cpp

37
src/setxattr.cpp

@ -189,7 +189,7 @@ _setxattr_minfreespace(Config &config,
static static
int int
_setxattr_controlfile_func_policy(Config &config, _setxattr_controlfile_func_policy(Config &config,
const char *funcname,
const string &funcname,
const string &attrval, const string &attrval,
const int flags) const int flags)
{ {
@ -208,7 +208,7 @@ _setxattr_controlfile_func_policy(Config &config,
static static
int int
_setxattr_controlfile_category_policy(Config &config, _setxattr_controlfile_category_policy(Config &config,
const char *categoryname,
const string &categoryname,
const string &attrval, const string &attrval,
const int flags) const int flags)
{ {
@ -227,38 +227,45 @@ _setxattr_controlfile_category_policy(Config &config,
static static
int int
_setxattr_controlfile(Config &config, _setxattr_controlfile(Config &config,
const char *attrname,
const string &attrname,
const string &attrval, const string &attrval,
const int flags) const int flags)
{ {
const char *attrbasename = &attrname[sizeof("user.mergerfs.")-1];
if(strncmp("user.mergerfs.",attrname,sizeof("user.mergerfs.")-1))
return -ENOATTR;
vector<string> attr;
if(attrval.empty())
return -EINVAL;
str::split(attr,attrname,'.');
if(!strcmp("srcmounts",attrbasename))
switch(attr.size())
{
case 3:
if(attr[2] == "srcmounts")
return _setxattr_srcmounts(config.srcmounts, return _setxattr_srcmounts(config.srcmounts,
config.srcmountslock, config.srcmountslock,
config.destmount, config.destmount,
attrval, attrval,
flags); flags);
else if(!strcmp("minfreespace",attrbasename))
else if(attr[2] == "minfreespace")
return _setxattr_minfreespace(config, return _setxattr_minfreespace(config,
attrval, attrval,
flags); flags);
else if(!strncmp("category.",attrbasename,sizeof("category.")-1))
break;
case 4:
if(attr[2] == "category")
return _setxattr_controlfile_category_policy(config, return _setxattr_controlfile_category_policy(config,
&attrbasename[sizeof("category.")-1],
attr[3],
attrval, attrval,
flags); flags);
else if(!strncmp("func.",attrbasename,sizeof("func.")-1))
else if(attr[2] == "func")
return _setxattr_controlfile_func_policy(config, return _setxattr_controlfile_func_policy(config,
&attrbasename[sizeof("func.")-1],
attr[3],
attrval, attrval,
flags); flags);
break;
default:
break;
}
return -EINVAL; return -EINVAL;
} }

Loading…
Cancel
Save