-
Notifications
You must be signed in to change notification settings - Fork 190
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
Normalize device names to find mounted slots #406
base: master
Are you sure you want to change the base?
Conversation
👍 Thanks for your submission! |
31c469b
to
213a68e
Compare
There's an issue getting the tests to work.
It's also used over a dozen times in the test code. This use doesn't work as intended because the devices, both the one used to look up a slot and the device named in the slot, do not exist. On a target, we couldn't say if they are the same or not. So the lookup fails. In actual use this behavior seems to me like it would be correct. The "is mounted?" and "was booted from?" checks should return false given a device that does not exist. It looks to me like |
03c1130
to
43c1888
Compare
6a0ae0d
to
ef102e1
Compare
Believe I have addressed all comments. I changed it to do the pathname compare first, device based compare second. The path string compare is much cheaper (no syscalls), and if the paths are the same, then the device comparison must the same too (excluding races!). So this is a faster way to get the same result as device compare first, path compare second. |
ef102e1
to
def12c7
Compare
Is there anything else left here? I believe I've made all requested changes. |
adac6a3
to
a235dee
Compare
Hi @ejoerns what is the status of this pull request, please? |
@obbardc the 'funny' thing is that it just hit me, too in a project today. There I still use a different method for solving the same issue and iirc we had a 3rd one somewhere around, too. We definitely need to face and fix this. This PR should not have been open for so long @obbardc Did you already test these patches? |
Hardcoded device names is not great, but for now what I have works. |
a235dee
to
857f08a
Compare
@ejoerns I've rebased this onto the current master, which had moved some functions to |
Codecov Report
@@ Coverage Diff @@
## master #406 +/- ##
=========================================
Coverage ? 66.34%
=========================================
Files ? 24
Lines ? 6516
Branches ? 0
=========================================
Hits ? 4323
Misses ? 2193
Partials ? 0
Continue to review full report at Codecov.
|
* etc. which we want to ignore rather than try to follow some | ||
* random symlink named "tmpfs" in the CWD. | ||
*/ | ||
if (g_unix_mount_get_device_path(m)[0] != '/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is correct for ubifs, which has device names such as ubi0:data
.
if (g_stat(devicepath, &st) == -1) { | ||
/* Virtual filesystems like devpts trigger case */ | ||
g_debug("Can't stat '%s', assuming unmountable: %s", devicepath, g_strerror(errno)); | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break support for UBIFS.
|
||
g_return_val_if_fail(slots, NULL); | ||
g_return_val_if_fail(device, NULL); | ||
|
||
obj = normalize_mountable_object(device); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we handle NULL here?
I think we can merge the first two commits as they are, though. |
This way a mounted slot can be found if the path used to mount the device is not the same as the path in the rauc configuration file. E.g., the configuration file uses a link like /dev/disk/by-partlabel/rootfs0 while the kernel's list of mounted devices uses a name like /dev/mmcblk1p2. This is a fallback after simply comparing the paths, as if the paths are the same then the devices must the same too. This avoids changing behavior in cases there the devices do not exist, for instance if rauc status before a device is online. Not being able to detect that the current rootfs is already mounted causes rauc to try to mount the slot, which will fail. Fixes rauc#388. Signed-off-by: Trent Piepho <[email protected]>
857f08a
to
8b758bf
Compare
I've merged the first two commits and rebased this PR. |
The open comments need to be solved, but the general approach seems fine. |
The open points still need to be resolved and we'd need test-cases to cover the new alternatives. Moving to the next release. |
This way a mounted slot can be found it the path used to mount the
device is not the same as the path in the rauc configuration file.
E.g., the configuration file uses a link like
/dev/disk/by-partlabel/rootfs0 while the kernel's list of mounted
devices uses a name like /dev/mmcblk1p2.
Not being able to detect that the current rootfs is already mounted
causes rauc to try to mount the slot, which will fail.
Fixes #388.
Signed-off-by: Trent Piepho [email protected]