]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/dissect-image.c
dissect-image: rework how we wait for partitions
authorLennart Poettering <lennart@poettering.net>
Tue, 29 Sep 2020 18:56:50 +0000 (20:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Oct 2020 12:58:27 +0000 (14:58 +0200)
commit4ba86848c92cf4d2d5466f43b4a42ae4ceddb8b0
tree3687f76f19ae7d11fc6ced655124d57622551e6c
parent6c544d14d977f5b70951ff7f55498d0368f5dfd4
dissect-image: rework how we wait for partitions

Previously, we'd just wait for the first moment where the kernel exposes
the same numbre of partitions as libblkid tells us. After that point we
enumerate kernel partitions and look for matching libblkid partitions.

With this change we'll instead enumerate with libblkid only, and then
wait for each kernel partition to show up with the exact parameters we
expect them to show up. Once that happens we are happy.

Care is taken to use the udev device notification messages only as hint
to recheck what the kernel actually says. That's because we are
otherwise subject to a race: we might see udev events from an earlier
use of a loopback device. After all these devices are heavily recycled.
Under the assumption that we'll get udev events for *at least* all
partitions we care about (but possibly more) we can fix the race
entirely with one more fix coming in a later commit: if we make sure
that a loopback block device has zero kernel partitions when we take
possession of it, it doesn't matter anymore if we get spurious udev
events from a previous use. All we have to do is notice when the devices
we need all popped up.
src/shared/dissect-image.c