Re: [PATCH v4 2/3] init/do_mounts.c: create second mount for initramfs
From: Menglong Dong <hidden>
Date: 2021-06-03 15:05:39
Also in:
linux-fsdevel
On Thu, Jun 3, 2021 at 9:30 PM Christian Brauner [off-list ref] wrote:
[...]
In fact you seem to be only using this struct you're introducing in this single place which makes me think that it's not needed at all. So what's preventing us from doing:quoted
+ + return do_mount_root(root->dev_name, + root->fs_name, + root_mountflags & ~MS_RDONLY, + root_mount_data); +}int __init prepare_mount_rootfs(void) { if (is_tmpfs_enabled()) return do_mount_root("tmpfs", "tmpfs", root_mountflags & ~MS_RDONLY, root_mount_data); return do_mount_root("ramfs", "ramfs", root_mountflags & ~MS_RDONLY, root_mount_data); }
It seems to make sense, but I just feel that it is a little hardcode. What if a new file system of rootfs arises? Am I too sensitive? [...]
This is convoluted imho. I would simply use two tiny helpers:
void __init finish_mount_rootfs(void)
{
init_mount(".", "/", NULL, MS_MOVE, NULL);
if (ramdisk_exec_exist())
init_chroot(".");
}
void __init revert_mount_rootfs(void)
{
init_chdir("/");
init_umount(".", 0);
}This looks nice. Thanks! Menglong Dong