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:
+2
-2
@@ -752,7 +752,7 @@ static void unit_remove_xattr_graceful(Unit *u, const char *cgroup_path, const c
|
||||
}
|
||||
|
||||
r = cg_remove_xattr(SYSTEMD_CGROUP_CONTROLLER, cgroup_path, name);
|
||||
if (r < 0 && r != -ENODATA)
|
||||
if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
|
||||
log_unit_debug_errno(u, r, "Failed to remove '%s' xattr flag on control group %s, ignoring: %m", name, empty_to_root(cgroup_path));
|
||||
}
|
||||
|
||||
@@ -3089,7 +3089,7 @@ int unit_check_oomd_kill(Unit *u) {
|
||||
return 0;
|
||||
|
||||
r = cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, "user.oomd_ooms", &value);
|
||||
if (r < 0 && r != -ENODATA)
|
||||
if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
|
||||
return r;
|
||||
|
||||
if (!isempty(value)) {
|
||||
|
||||
+1
-1
@@ -3254,7 +3254,7 @@ static int setup_smack(
|
||||
_cleanup_free_ char *exec_label = NULL;
|
||||
|
||||
r = mac_smack_read_fd(executable_fd, SMACK_ATTR_EXEC, &exec_label);
|
||||
if (r < 0 && !IN_SET(r, -ENODATA, -EOPNOTSUPP))
|
||||
if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
|
||||
return r;
|
||||
|
||||
r = mac_smack_apply_pid(0, exec_label ? : manager->default_smack_process_label);
|
||||
|
||||
Reference in New Issue
Block a user