From: 我超厉害 <524413304@qq.com> Date: Thu, 14 May 2026 17:51:29 +0000 (+0800) Subject: sd-device: use ERRNO_IS_NEG_DEVICE_ABSENT() for device-id load failures (#41764) X-Git-Tag: v261-rc1~168 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a03f3af3e3816da18b677cf2de585ec0cac452ab;p=thirdparty%2Fsystemd.git sd-device: use ERRNO_IS_NEG_DEVICE_ABSENT() for device-id load failures (#41764) Device enumeration may encounter transient errors such as ENXIO when devices appear or disappear concurrently. These conditions represent expected "device absent" races and should be treated uniformly across the enumeration logic. This change replaces the ENODEV-specific check with ERRNO_IS_NEG_DEVICE_ABSENT(), ensuring that all expected disappearance conditions are handled consistently. Unexpected errors are still propagated, while expected races are ignored without aborting the enumeration. --- diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index d1a48defe90..6c1e79edd58 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -9,6 +9,7 @@ #include "device-filter.h" #include "device-util.h" #include "dirent-util.h" +#include "errno-util.h" #include "fd-util.h" #include "log.h" #include "path-util.h" @@ -741,7 +742,7 @@ static int enumerator_scan_dir_and_add_devices( k = sd_device_new_from_syspath(&device, syspath); if (k < 0) { - if (k != -ENODEV) + if (!ERRNO_IS_NEG_DEVICE_ABSENT(k)) /* this is necessarily racey, so ignore missing devices */ r = k; @@ -836,7 +837,7 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c k = sd_device_new_from_device_id(&device, de->d_name); if (k < 0) { - if (k != -ENODEV) + if (!ERRNO_IS_NEG_DEVICE_ABSENT(k)) /* this is necessarily racy, so ignore missing devices */ r = k; @@ -882,7 +883,7 @@ static int parent_add_child(sd_device_enumerator *enumerator, const char *path, int r; r = sd_device_new_from_syspath(&device, path); - if (r == -ENODEV) + if (ERRNO_IS_NEG_DEVICE_ABSENT(r)) /* this is necessarily racy, so ignore missing devices */ return 0; else if (r < 0)