]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: use ERRNO_IS_DEVICE_ABSENT() at one more place
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 Apr 2022 05:59:06 +0000 (14:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 Apr 2022 19:34:14 +0000 (04:34 +0900)
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/sd-device.c

index 6ad49c05a0751bb7c95d148cbe0ecbe7bd85229f..47b62e7421a15c876ef969c77881aecd1e8f426c 100644 (file)
@@ -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;
index 6c2d1243ac398bd08c538aacfc4bc94ef5119dbe..0c5b2a67e33447e759b756430d77d824fdcac743 100644 (file)
@@ -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) {