-
Notifications
You must be signed in to change notification settings - Fork 231
src/slot: fix mount point detection for symlinks #1722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
It may be desirable to specify the device of a slot not as the real device path, but as a symlink to it (e.g. by using a udev-provided symlink such as /dev/disk/by-id/... instead of /dev/mmcblk...). The slot mount point detection failed in these cases because the device passed to r_slot_find_by_device() is always the real path of the device. Fix this by checking the realpath() of each slot device in addition to the specified path. Signed-off-by: Andreas Mützel <andreas.muetzel@emlix.com>
Hmm. I would have thought that we already have something like this... We could resolve the path during config loading and store it in a new field of Resolving during config loading would rely on the assumption that the symlinks don't change at runtime, but I think that's reasonable. If |
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (66.66%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1722 +/- ##
==========================================
- Coverage 84.50% 84.49% -0.01%
==========================================
Files 76 76
Lines 22381 22387 +6
==========================================
+ Hits 18913 18917 +4
- Misses 3468 3470 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is somewhat similar to #406, which was supposed to fix #388 but never got finished. The major difference seems to be that #406 also normalizes the path of the mounted device (not just of the mount point specified in the config). That might indeed lead to somewhat strange behaviour if a symlink called like a special filesystem exists in the current RAUC working directory. For example (not tested, just deduced from the related discussions):
This whole situation is avoided in this PR because only the mount point specified in the config is resolved/normalized, not the mount point returned by Resolving this at load time and storing it as an additional field ( Pro:
Con:
I think the last point is the most important point. Are such use-cases relevant? IMHO, this is mostly an architectural decision - if you prefer, I could adapt this MR to the alternative approach. |
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()
).