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.
This commit is contained in:
committed by
Luca Boccassi
parent
64ff6ad494
commit
ea0f3289a2
@@ -21,7 +21,10 @@ static inline int bind_remount_recursive(const char *prefix, unsigned long new_f
|
||||
|
||||
int bind_remount_one_with_mountinfo(const char *path, unsigned long new_flags, unsigned long flags_mask, FILE *proc_self_mountinfo);
|
||||
|
||||
int mount_switch_root(const char *path, unsigned long mount_propagation_flag);
|
||||
int mount_switch_root_full(const char *path, unsigned long mount_propagation_flag, bool force_ms_move);
|
||||
static inline int mount_switch_root(const char *path, unsigned long mount_propagation_flag) {
|
||||
return mount_switch_root_full(path, mount_propagation_flag, false);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, endmntent, NULL);
|
||||
#define _cleanup_endmntent_ _cleanup_(endmntentp)
|
||||
|
||||
Reference in New Issue
Block a user