]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: skip to check diskseq if device is not initialized
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 27 Aug 2022 21:43:30 +0000 (06:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 28 Aug 2022 01:10:44 +0000 (10:10 +0900)
src/libsystemd/sd-device/sd-device.c

index 26b9e51c937ddbf2b323801b5c0cb53961bd77a9..a7ba7dd6e980f7ed29d41fabf4bf9810c2949e7c 100644 (file)
@@ -2422,13 +2422,20 @@ _public_ int sd_device_open(sd_device *device, int flags) {
         if (FLAGS_SET(flags, O_PATH))
                 return TAKE_FD(fd);
 
-        r = device_get_property_bool(device, "ID_IGNORE_DISKSEQ");
-        if (r < 0 && r != -ENOENT)
+        /* If the device is not initialized, then we cannot determine if we should check diskseq through
+         * ID_IGNORE_DISKSEQ property. Let's skip to check diskseq in that case. */
+        r = sd_device_get_is_initialized(device);
+        if (r < 0)
                 return r;
-        if (r <= 0) {
-                r = sd_device_get_diskseq(device, &diskseq);
+        if (r > 0) {
+                r = device_get_property_bool(device, "ID_IGNORE_DISKSEQ");
                 if (r < 0 && r != -ENOENT)
                         return r;
+                if (r <= 0) {
+                        r = sd_device_get_diskseq(device, &diskseq);
+                        if (r < 0 && r != -ENOENT)
+                                return r;
+                }
         }
 
         fd2 = open(FORMAT_PROC_FD_PATH(fd), flags);