diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-11-30 17:17:20 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-12-01 11:32:30 +0100 |
commit | 73d88b806b92efa0738bb6bcccbf105441f6d8cb (patch) | |
tree | 95f3d63d9301ca7d79d6f319878fe05e7737bed1 /src/gpt-auto-generator/gpt-auto-generator.c | |
parent | terminal-util: Set OPOST when setting ONLCR (diff) | |
download | systemd-73d88b806b92efa0738bb6bcccbf105441f6d8cb.tar.xz systemd-73d88b806b92efa0738bb6bcccbf105441f6d8cb.zip |
dissect: rework DISSECT_IMAGE_ADD_PARTITION_DEVICES + DISSECT_IMAGE_OPEN_PARTITION_DEVICES
Curently, these two flags were implied by dissect_loop_device(), but
that's not right, because this means systemd-gpt-auto-generator will
dissect the root block device with these flags set and that's not
desirable: the generator should not cause the partition devices to be
created (we don't intend to use them right-away after all, but expect
udev to find/probe them first, and then mount them though .mount units).
And there's no point in opening the partition devices, since we do not
intend to mount them via fds either.
Hence, rework this: instead of implying the flags, specify them
explicitly.
While we are at it, let's also rename the flags to make them more
descriptive:
DISSECT_IMAGE_MANAGE_PARTITION_DEVICES becomes
DISSECT_IMAGE_ADD_PARTITION_DEVICES, since that's really all this does:
add the partition devices via BLKPG.
DISSECT_IMAGE_OPEN_PARTITION_DEVICES becomes
DISSECT_IMAGE_PIN_PARTITION_DEVICES, since we not only open the devices,
but keep the devices open continously (i.e. we "pin" them).
Also, drop the DISSECT_IMAGE_BLOCK_DEVICE combination flag, since it is
misleading, i.e. it suggests it was appropriate to specify on all
dissected blocking devices, but that's precisely not the case, see the
systemd-gpt-auto-generator case. My guess is that the confusion around
this was actually the cause for this bug we are addressing here.
Fixes: #25528
Diffstat (limited to 'src/gpt-auto-generator/gpt-auto-generator.c')
-rw-r--r-- | src/gpt-auto-generator/gpt-auto-generator.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index f939b2e8c2..23a215231c 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -665,6 +665,11 @@ static int enumerate_partitions(dev_t devnum) { NULL, NULL, DISSECT_IMAGE_GPT_ONLY| DISSECT_IMAGE_USR_NO_ROOT, + /* NB! Unlike most other places where we dissect block devices we do not use + * DISSECT_IMAGE_ADD_PARTITION_DEVICES here: we want that the kernel finds the + * devices, and udev probes them before we mount them via .mount units much later + * on. And thus we also don't set DISSECT_IMAGE_PIN_PARTITION_DEVICES here, because + * we don't actually mount anything immediately. */ &m); if (r == -ENOPKG) { log_debug_errno(r, "No suitable partition table found, ignoring."); |