udev-builtin-blkid: skip GPT dissection unless we actually have partition support

This commit is contained in:
Lennart Poettering
2025-03-14 16:13:48 +01:00
parent 5d3243bd46
commit e71f60476b

View 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;
}