|
@ -44,23 +44,23 @@ namespace fs |
|
|
{ |
|
|
{ |
|
|
#ifndef WITHOUT_XATTR
|
|
|
#ifndef WITHOUT_XATTR
|
|
|
ssize_t rv; |
|
|
ssize_t rv; |
|
|
ssize_t size; |
|
|
|
|
|
|
|
|
|
|
|
rv = -1; |
|
|
rv = -1; |
|
|
errno = ERANGE; |
|
|
errno = ERANGE; |
|
|
while(rv == -1 && errno == ERANGE) |
|
|
|
|
|
|
|
|
while((rv == -1) && (errno == ERANGE)) |
|
|
{ |
|
|
{ |
|
|
size = ::flistxattr(fd,NULL,0); |
|
|
|
|
|
attrs.resize(size); |
|
|
|
|
|
if(size == 0) |
|
|
|
|
|
return 0; |
|
|
|
|
|
rv = ::flistxattr(fd,&attrs[0],size); |
|
|
|
|
|
|
|
|
rv = ::flistxattr(fd,NULL,0); |
|
|
|
|
|
if(rv <= 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
attrs.resize(rv); |
|
|
|
|
|
|
|
|
|
|
|
rv = ::flistxattr(fd,&attrs[0],rv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rv; |
|
|
return rv; |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -69,24 +69,24 @@ namespace fs |
|
|
vector<char> &attrs) |
|
|
vector<char> &attrs) |
|
|
{ |
|
|
{ |
|
|
#ifndef WITHOUT_XATTR
|
|
|
#ifndef WITHOUT_XATTR
|
|
|
int rv; |
|
|
|
|
|
int size; |
|
|
|
|
|
|
|
|
ssize_t rv; |
|
|
|
|
|
|
|
|
rv = -1; |
|
|
rv = -1; |
|
|
errno = ERANGE; |
|
|
errno = ERANGE; |
|
|
while(rv == -1 && errno == ERANGE) |
|
|
|
|
|
|
|
|
while((rv == -1) && (errno == ERANGE)) |
|
|
{ |
|
|
{ |
|
|
size = ::listxattr(path.c_str(),NULL,0); |
|
|
|
|
|
attrs.resize(size); |
|
|
|
|
|
if(size == 0) |
|
|
|
|
|
return 0; |
|
|
|
|
|
rv = ::listxattr(path.c_str(),&attrs[0],size); |
|
|
|
|
|
|
|
|
rv = ::llistxattr(path.c_str(),NULL,0); |
|
|
|
|
|
if(rv <= 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
attrs.resize(rv); |
|
|
|
|
|
|
|
|
|
|
|
rv = ::llistxattr(path.c_str(),&attrs[0],rv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rv; |
|
|
return rv; |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -126,7 +126,7 @@ namespace fs |
|
|
|
|
|
|
|
|
int |
|
|
int |
|
|
list(const int fd, |
|
|
list(const int fd, |
|
|
string &attrstr) |
|
|
|
|
|
|
|
|
string &attrstr) |
|
|
{ |
|
|
{ |
|
|
int rv; |
|
|
int rv; |
|
|
vector<char> attrs; |
|
|
vector<char> attrs; |
|
@ -158,24 +158,24 @@ namespace fs |
|
|
vector<char> &value) |
|
|
vector<char> &value) |
|
|
{ |
|
|
{ |
|
|
#ifndef WITHOUT_XATTR
|
|
|
#ifndef WITHOUT_XATTR
|
|
|
int rv; |
|
|
|
|
|
int size; |
|
|
|
|
|
|
|
|
ssize_t rv; |
|
|
|
|
|
|
|
|
rv = -1; |
|
|
rv = -1; |
|
|
errno = ERANGE; |
|
|
errno = ERANGE; |
|
|
while(rv == -1 && errno == ERANGE) |
|
|
|
|
|
|
|
|
while((rv == -1) && (errno == ERANGE)) |
|
|
{ |
|
|
{ |
|
|
size = ::fgetxattr(fd,attr.c_str(),NULL,0); |
|
|
|
|
|
value.resize(size); |
|
|
|
|
|
if(size == 0) |
|
|
|
|
|
return 0; |
|
|
|
|
|
rv = ::fgetxattr(fd,attr.c_str(),&value[0],size); |
|
|
|
|
|
|
|
|
rv = ::fgetxattr(fd,attr.c_str(),NULL,0); |
|
|
|
|
|
if(rv <= 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
value.resize(rv); |
|
|
|
|
|
|
|
|
|
|
|
rv = ::fgetxattr(fd,attr.c_str(),&value[0],rv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rv; |
|
|
return rv; |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -185,24 +185,24 @@ namespace fs |
|
|
vector<char> &value) |
|
|
vector<char> &value) |
|
|
{ |
|
|
{ |
|
|
#ifndef WITHOUT_XATTR
|
|
|
#ifndef WITHOUT_XATTR
|
|
|
int rv; |
|
|
|
|
|
int size; |
|
|
|
|
|
|
|
|
ssize_t rv; |
|
|
|
|
|
|
|
|
rv = -1; |
|
|
rv = -1; |
|
|
errno = ERANGE; |
|
|
errno = ERANGE; |
|
|
while(rv == -1 && errno == ERANGE) |
|
|
|
|
|
|
|
|
while((rv == -1) && (errno == ERANGE)) |
|
|
{ |
|
|
{ |
|
|
size = ::getxattr(path.c_str(),attr.c_str(),NULL,0); |
|
|
|
|
|
value.resize(size); |
|
|
|
|
|
if(size == 0) |
|
|
|
|
|
return 0; |
|
|
|
|
|
rv = ::getxattr(path.c_str(),attr.c_str(),&value[0],size); |
|
|
|
|
|
|
|
|
rv = ::lgetxattr(path.c_str(),attr.c_str(),NULL,0); |
|
|
|
|
|
if(rv <= 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
value.resize(rv); |
|
|
|
|
|
|
|
|
|
|
|
rv = ::lgetxattr(path.c_str(),attr.c_str(),&value[0],rv); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rv; |
|
|
return rv; |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -305,8 +305,7 @@ namespace fs |
|
|
value.size(), |
|
|
value.size(), |
|
|
flags); |
|
|
flags); |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -317,14 +316,13 @@ namespace fs |
|
|
const int flags) |
|
|
const int flags) |
|
|
{ |
|
|
{ |
|
|
#ifndef WITHOUT_XATTR
|
|
|
#ifndef WITHOUT_XATTR
|
|
|
return ::setxattr(path.c_str(), |
|
|
|
|
|
key.c_str(), |
|
|
|
|
|
value.data(), |
|
|
|
|
|
value.size(), |
|
|
|
|
|
flags); |
|
|
|
|
|
|
|
|
return ::lsetxattr(path.c_str(), |
|
|
|
|
|
key.c_str(), |
|
|
|
|
|
value.data(), |
|
|
|
|
|
value.size(), |
|
|
|
|
|
flags); |
|
|
#else
|
|
|
#else
|
|
|
errno = ENOTSUP; |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return (errno=ENOTSUP,-1); |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|