mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 06:56:27 -05:00
add user.mergerfs.allpaths and user.mergerfs.relpath to getxattr
This commit is contained in:
parent
2e95c6e78e
commit
d30cae217b
4 changed files with 78 additions and 7 deletions
|
|
@ -94,6 +94,46 @@ _getxattr_from_string(char *destbuf,
|
|||
return srcbufsize;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_getxattr_user_mergerfs_allpaths(const vector<string> &srcmounts,
|
||||
const string &fusepath,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
{
|
||||
string concated;
|
||||
vector<string> paths;
|
||||
|
||||
fs::findallfiles(srcmounts,fusepath,paths);
|
||||
|
||||
concated = str::join(paths,'\0');
|
||||
|
||||
return ::_getxattr_from_string(buf,count,concated);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_getxattr_user_mergerfs(const fs::Path &path,
|
||||
const vector<string> &srcmounts,
|
||||
const string &fusepath,
|
||||
const char *attrname,
|
||||
char *buf,
|
||||
const size_t count)
|
||||
{
|
||||
const char *attrbasename = &attrname[sizeof("user.mergerfs")];
|
||||
|
||||
if(!strcmp(attrbasename,"basepath"))
|
||||
return ::_getxattr_from_string(buf,count,path.base);
|
||||
else if(!strcmp(attrbasename,"fullpath"))
|
||||
return ::_getxattr_from_string(buf,count,path.full);
|
||||
else if(!strcmp(attrbasename,"relpath"))
|
||||
return ::_getxattr_from_string(buf,count,fusepath);
|
||||
else if(!strcmp(attrbasename,"allpaths"))
|
||||
return ::_getxattr_user_mergerfs_allpaths(srcmounts,fusepath,buf,count);
|
||||
|
||||
return (errno=ENOATTR,-1);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_getxattr(const fs::SearchFunc searchFunc,
|
||||
|
|
@ -111,11 +151,10 @@ _getxattr(const fs::SearchFunc searchFunc,
|
|||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
if(!strcmp(attrname,"user.mergerfs.basepath"))
|
||||
rv = ::_getxattr_from_string(buf,count,path.base);
|
||||
else if(!strcmp(attrname,"user.mergerfs.fullpath"))
|
||||
rv = ::_getxattr_from_string(buf,count,path.full);
|
||||
else
|
||||
if(!strncmp("user.mergerfs.",attrname,sizeof("user.mergerfs.")-1))
|
||||
rv = _getxattr_user_mergerfs(path,srcmounts,fusepath,attrname,buf,count);
|
||||
|
||||
if(rv == -1 && errno == ENOATTR)
|
||||
rv = ::lgetxattr(path.full.c_str(),attrname,buf,count);
|
||||
|
||||
return ((rv == -1) ? -errno : rv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue