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:
@@ -153,3 +153,10 @@ static inline bool ERRNO_IS_DEVICE_ABSENT(int r) {
|
||||
ENXIO,
|
||||
ENOENT);
|
||||
}
|
||||
|
||||
/* Quite often we want to handle cases where the backing FS doesn't support extended attributes at all and
|
||||
* where it simply doesn't have the requested xattr the same way */
|
||||
static inline bool ERRNO_IS_XATTR_ABSENT(int r) {
|
||||
return abs(r) == ENODATA ||
|
||||
ERRNO_IS_NOT_SUPPORTED(r);
|
||||
}
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ int open_extension_release(const char *root, const char *extension, char **ret_p
|
||||
/* No xattr or cannot parse it? Then skip this. */
|
||||
_cleanup_free_ char *extension_release_xattr = NULL;
|
||||
k = fgetxattr_malloc(extension_release_fd, "user.extension-release.strict", &extension_release_xattr);
|
||||
if (k < 0 && !ERRNO_IS_NOT_SUPPORTED(k) && k != -ENODATA)
|
||||
if (k < 0 && !ERRNO_IS_XATTR_ABSENT(k))
|
||||
log_debug_errno(k,
|
||||
"%s/%s: Failed to read 'user.extension-release.strict' extended attribute from file: %m",
|
||||
extension_release_dir_path, de->d_name);
|
||||
|
||||
Reference in New Issue
Block a user