]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-blkid: skip GPT dissection unless we actually have partition support 36968/head
authorLennart Poettering <lennart@poettering.net>
Fri, 14 Mar 2025 15:13:48 +0000 (16:13 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Apr 2025 08:04:03 +0000 (10:04 +0200)
src/udev/udev-builtin-blkid.c

index 363f07c24aec5bc7b1cdf976ad6b56b216e9369b..1448fa3f048b2ef7504d42bf5c42bc0e9532e0a2 100644 (file)
@@ -145,8 +145,24 @@ static int find_gpt_root(UdevEvent *event, blkid_probe pr, const char *loop_back
          * After the initrd→host transition: look at the current block device mounted at / and set the same
          * properties to its whole block device. */
 
-        if (!device_is_devtype(dev, "disk")) {
-                log_device_debug(dev, "Skipping GPT root logic on partition block device.");
+        const char *devnode;
+        r = sd_device_get_devname(dev, &devnode);
+        if (r < 0)
+                return log_device_debug_errno(dev, r, "Failed to get device node: %m");
+
+        r = block_device_is_whole_disk(dev);
+        if (r < 0)
+                return log_device_debug_errno(dev, r, "Unable to determine if device '%s' is a whole-block device: %m", devnode);
+        if (r == 0) {
+                log_device_debug(dev, "Invoked on device '%s' which is not a whole-disk block device, ignoring.", devnode);
+                return 0;
+        }
+
+        r = blockdev_partscan_enabled(dev);
+        if (r < 0)
+                return log_device_debug_errno(dev, r, "Failed to determine if block device '%s' supports partitions: %m", devnode);
+        if (r == 0) {
+                log_device_debug(dev, "Invoked on block device '%s' that lacks partition scanning, ignoring.", devnode);
                 return 0;
         }