tree-wide: add ERRNO_IS_XATTR_ABSENT() helper
We check the same list of error codes on various xattr operations, and we should on some more. Add a common helper for this purpose.
This commit is contained in:
@@ -32,10 +32,8 @@ static const uint8_t default_acl[] = {
|
||||
static bool has_xattr(const char *p) {
|
||||
char buffer[sizeof(acl) * 4];
|
||||
|
||||
if (lgetxattr(p, "system.posix_acl_access", buffer, sizeof(buffer)) < 0) {
|
||||
if (IN_SET(errno, EOPNOTSUPP, ENOTTY, ENODATA, ENOSYS))
|
||||
return false;
|
||||
}
|
||||
if (lgetxattr(p, "system.posix_acl_access", buffer, sizeof(buffer)) < 0)
|
||||
return !ERRNO_IS_XATTR_ABSENT(errno);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST(getxattr_at_malloc) {
|
||||
fd = open("/", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOCTTY);
|
||||
assert_se(fd >= 0);
|
||||
r = getxattr_at_malloc(fd, "usr", "user.idontexist", 0, &value);
|
||||
assert_se(r == -ENODATA || ERRNO_IS_NOT_SUPPORTED(r));
|
||||
assert_se(r < 0 && ERRNO_IS_XATTR_ABSENT(r));
|
||||
|
||||
safe_close(fd);
|
||||
fd = open(x, O_PATH|O_CLOEXEC);
|
||||
|
||||
Reference in New Issue
Block a user