switch-root: don't require /mnt/ when switching root into host OS
So far, we invoked pivot_root() specifying /mnt/ as second argument, which then unmounted right-after. We'd create /mnt/ if needed. This sucks, because it means /mnt/ must strictly be pre-created on immutable images. Remove this limitation, by using pivot_root() with "." as source and target, which will result in two stacked mounts afterwards: the new one underneath, the old one ontop. We can then simply unmount the top one, and have what we want without needing any extra /mnt/ dir. Since we don't need /mnt/ anymore we can get rid of the extra unmount_old_root parameter and simply specify it as NULL if we don't want the old mount to stick around.
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot, unsigned long mountflags);
|
||||
int switch_root(const char *new_root, const char *old_root_after, unsigned long mount_flags);
|
||||
|
||||
Reference in New Issue
Block a user