Browse Source

getxattr for user.mergerfs.{base,full}path returns the source paths. closes #23

pull/30/head
Antonio SJ Musumeci 10 years ago
parent
commit
b82db46e29
  1. 26
      src/getxattr.cpp

26
src/getxattr.cpp

@ -74,6 +74,25 @@ _getxattr_controlfile(const Config &config,
return (int)len; return (int)len;
} }
static
int
_getxattr_from_string(char *destbuf,
const size_t destbufsize,
const string &src)
{
const size_t srcbufsize = src.size();
if(destbufsize == 0)
return srcbufsize;
if(srcbufsize > destbufsize)
return (errno = ERANGE, -1);
memcpy(destbuf,src.data(),srcbufsize);
return srcbufsize;
}
static static
int int
_getxattr(const fs::SearchFunc searchFunc, _getxattr(const fs::SearchFunc searchFunc,
@ -91,7 +110,12 @@ _getxattr(const fs::SearchFunc searchFunc,
if(paths.empty()) if(paths.empty())
return -ENOENT; return -ENOENT;
rv = ::lgetxattr(paths[0].full.c_str(),attrname,buf,count);
if(!strcmp(attrname,"user.mergerfs.basepath"))
rv = ::_getxattr_from_string(buf,count,paths[0].base);
else if(!strcmp(attrname,"user.mergerfs.fullpath"))
rv = ::_getxattr_from_string(buf,count,paths[0].full);
else
rv = ::lgetxattr(paths[0].full.c_str(),attrname,buf,count);
return ((rv == -1) ? -errno : rv); return ((rv == -1) ? -errno : rv);
#else #else

Loading…
Cancel
Save