From: Yu Watanabe Date: Sun, 17 Apr 2022 05:59:06 +0000 (+0900) Subject: sd-device: use ERRNO_IS_DEVICE_ABSENT() at one more place X-Git-Tag: v251-rc2~108^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17761fb3bfa494c565683222a707cfa28d14b560;p=thirdparty%2Fsystemd.git sd-device: use ERRNO_IS_DEVICE_ABSENT() at one more place --- diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 6ad49c05a07..47b62e7421a 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -835,10 +835,9 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) { return r; } - /* And then read uevent file, but ignore errors, as some devices seem to return a spurious - * error on read, e.g. -ENODEV, and even if ifindex or devnum is set in the above, - * sd_device_get_ifindex() or sd_device_get_devnum() fails. See. #19788. */ - (void) device_read_uevent_file(ret); + r = device_read_uevent_file(ret); + if (r < 0) + return r; *new_device = TAKE_PTR(ret); return 0; diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 6c2d1243ac3..0c5b2a67e33 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -724,11 +724,14 @@ int device_read_uevent_file(sd_device *device) { path = strjoina(syspath, "/uevent"); r = read_full_virtual_file(path, &uevent, &uevent_len); - if (IN_SET(r, -EACCES, -ENOENT)) - /* The uevent files may be write-only, or the device may not have uevent file. */ - return 0; - if (r < 0) + if (r < 0) { + /* The uevent files may be write-only, the device may be already removed, or the device + * may not have the uevent file. */ + if (r == -EACCES || ERRNO_IS_DEVICE_ABSENT(r)) + return 0; + return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path); + } for (size_t i = 0; i < uevent_len; i++) switch (state) {