mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
gpt-auto-generator: don't wait for udev
Generators run in a context where waiting for udev is not an option, simply because it's not running there yet. Hence, let's not wait for it in this case. This is generally OK to do as we are operating on the root disk only here, which should have been probed already by the time we come this far. An alternative fix might be to remove the udev dependency from image dissection again in the long run (and thus replace reliance on /dev/block/x:y somehow with something else). Fixes: #11205
This commit is contained in:
parent
2141bedb39
commit
052eaf5c93
@ -518,7 +518,7 @@ static int enumerate_partitions(dev_t devnum) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
r = dissect_image(fd, NULL, 0, DISSECT_IMAGE_GPT_ONLY, &m);
|
||||
r = dissect_image(fd, NULL, 0, DISSECT_IMAGE_GPT_ONLY|DISSECT_IMAGE_NO_UDEV, &m);
|
||||
if (r == -ENOPKG) {
|
||||
log_debug_errno(r, "No suitable partition table found, ignoring.");
|
||||
return 0;
|
||||
|
@ -145,6 +145,7 @@ static int wait_for_partitions_to_appear(
|
||||
int fd,
|
||||
sd_device *d,
|
||||
unsigned num_partitions,
|
||||
DissectImageFlags flags,
|
||||
sd_device_enumerator **ret_enumerator) {
|
||||
|
||||
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
|
||||
@ -166,9 +167,11 @@ static int wait_for_partitions_to_appear(
|
||||
if (device_is_mmc_special_partition(q))
|
||||
continue;
|
||||
|
||||
r = device_wait_for_initialization(q, "block", NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, DISSECT_IMAGE_NO_UDEV)) {
|
||||
r = device_wait_for_initialization(q, "block", NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
@ -223,18 +226,22 @@ static int loop_wait_for_partitions_to_appear(
|
||||
int fd,
|
||||
sd_device *d,
|
||||
unsigned num_partitions,
|
||||
DissectImageFlags flags,
|
||||
sd_device_enumerator **ret_enumerator) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||
int r;
|
||||
|
||||
log_debug("Waiting for device (parent + %d partitions) to appear...", num_partitions);
|
||||
|
||||
r = device_wait_for_initialization(d, "block", &device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, DISSECT_IMAGE_NO_UDEV)) {
|
||||
r = device_wait_for_initialization(d, "block", &device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else
|
||||
device = sd_device_ref(d);
|
||||
|
||||
for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) {
|
||||
r = wait_for_partitions_to_appear(fd, device, num_partitions, ret_enumerator);
|
||||
r = wait_for_partitions_to_appear(fd, device, num_partitions, flags, ret_enumerator);
|
||||
if (r != -EAGAIN)
|
||||
return r;
|
||||
}
|
||||
@ -369,7 +376,7 @@ int dissect_image(
|
||||
|
||||
m->encrypted = streq_ptr(fstype, "crypto_LUKS");
|
||||
|
||||
r = loop_wait_for_partitions_to_appear(fd, d, 0, &e);
|
||||
r = loop_wait_for_partitions_to_appear(fd, d, 0, flags, &e);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -394,7 +401,7 @@ int dissect_image(
|
||||
if (!pl)
|
||||
return -errno ?: -ENOMEM;
|
||||
|
||||
r = loop_wait_for_partitions_to_appear(fd, d, blkid_partlist_numof_partitions(pl), &e);
|
||||
r = loop_wait_for_partitions_to_appear(fd, d, blkid_partlist_numof_partitions(pl), flags, &e);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -57,6 +57,7 @@ typedef enum DissectImageFlags {
|
||||
DISSECT_IMAGE_MOUNT_ROOT_ONLY = 1 << 6, /* Mount only the root partition */
|
||||
DISSECT_IMAGE_MOUNT_NON_ROOT_ONLY = 1 << 7, /* Mount only non-root partitions */
|
||||
DISSECT_IMAGE_VALIDATE_OS = 1 << 8, /* Refuse mounting images that aren't identifyable as OS images */
|
||||
DISSECT_IMAGE_NO_UDEV = 1 << 9, /* Don't wait for udev initializing things */
|
||||
} DissectImageFlags;
|
||||
|
||||
struct DissectedImage {
|
||||
|
Loading…
Reference in New Issue
Block a user