]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/mount-util.h
mount-util: simplify mount_switch_root() a bit
authorLennart Poettering <lennart@poettering.net>
Wed, 3 May 2023 15:17:35 +0000 (17:17 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 3 May 2023 19:52:19 +0000 (20:52 +0100)
commitea0f3289a288affd5f13c83849b984c8fad63e90
treef8e8d64a945e5525053e4fc650b91310f4ab6c72
parent64ff6ad494477e4ad87fb02335db5ff17bd21d07
mount-util: simplify mount_switch_root() a bit

There's no need to fchdir() out of the rootfs and back into it around
the umount2(), hence don't.

This brings the logic closer to what the pivot_root() man page suggests.

While we are at it, always operate based on fds, once we opened the
original dir, and pass the path string along only for generating
messages (i.e. as "decoration").

Add tests for both code paths: the pivot_root() one and the MS_MOUNT.
src/shared/mount-util.c
src/shared/mount-util.h
src/test/test-mount-util.c