src/slot: fix mount point detection for symlinks #1722
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In multiple use cases, it is desirable to use a symlink to a device in the
device=/dev/<device>
attribute of a slot insystem.conf
instead of the actual path of the device:One might want to identify the slots using attributes such as the disk id or path by using udev-provided symlinks such as
/dev/disk/by-id/...
or/dev/disk/by-path
.Or, on devices that support booting from multiple media, dynamically create a symlink such as
/dev/disk/rootfs-0
that points to the appropriate partition on the currently-active boot device.This currently makes the mount point detection fail because RAUC cannot identify that such a device is actually mounted to a slot. (
rauc status
does not identify such a slot asmounted: /<mountpoint>
.)The reason seems to be the way that
update_external_mount_points()
matches mount points with slots:To get the currently-mounted devices,
g_unix_mounts_get()
is used and returns the real paths of all mounted devices.Then,
find_config_slot_by_device()
is used and callsr_slot_find_by_device()
to match active mounts with config entries.This iterates over all slots and checks whether the
slot->device
is equal to the givendevice
name. In the symlink case, this will fail because the path of theslot->device
is never resolved. This MR adds handling for the symlink case tor_slot_find_by_device()
by usingrealpath
to resolve the slot's device path.I could imagine two alternative approaches:
realpath()
instead of only when the direct comparison fails. This would introduce a small additional cost in the regular case.Also, it would make the function not identify a slot as mounted if the
slot->device
does not point to an existing file that is listed as a mount point nonetheless - which is relevant at least in one of thebootchooser
unit tests (but most likely not in real-world use-cases because non-existing devices should not be returned byg_unix_mounts_get()
).