switch-root: automatically make target switch root dir a mount point
Let's make sure implicitly that the target directory is a mount point, instead of doing so manually beforehand. This allows us to drop this step from the transition into the /run/initramfs/ dir at shutdown. During the initrd→host transition the switch root operations so far where towards pre-existing mount points, but there are cetrainly usecases where it might make sense to siwtch into arbitrary subdirectories, too.
This commit is contained in:
@@ -66,6 +66,11 @@ int switch_root(const char *new_root,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Make the new root directory a mount point if it isn't */
|
||||
r = fd_make_mount_point(new_root_fd);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to make new root directory a mount point: %m");
|
||||
|
||||
if (FLAGS_SET(flags, SWITCH_ROOT_DESTROY_OLD_ROOT)) {
|
||||
istmp = fd_is_temporary_fs(old_root_fd);
|
||||
if (istmp < 0)
|
||||
|
||||
Reference in New Issue
Block a user