]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: do not try to read uevent file multiple times
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Jun 2021 08:28:34 +0000 (17:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 5 Jun 2021 08:58:53 +0000 (17:58 +0900)
src/libsystemd/sd-device/sd-device.c

index ecb4c429c771351d079b86d672172de79c483e2f..f31416da530247bf5cfc92db4652a3460267bf86 100644 (file)
@@ -539,22 +539,17 @@ int device_read_uevent_file(sd_device *device) {
         if (r < 0)
                 return r;
 
+        device->uevent_loaded = true;
+
         path = strjoina(syspath, "/uevent");
 
         r = read_full_virtual_file(path, &uevent, &uevent_len);
-        if (r == -EACCES) {
-                /* empty uevent files may be write-only */
-                device->uevent_loaded = true;
-                return 0;
-        }
-        if (r == -ENOENT)
-                /* some devices may not have uevent files, see device_set_syspath() */
+        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)
                 return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path);
 
-        device->uevent_loaded = true;
-
         for (size_t i = 0; i < uevent_len; i++)
                 switch (state) {
                 case PRE_KEY: