init: add an init_mount helper
Like do_mount, but takes a kernel pointer for the destination path. Switch over the mounts in the init code and devtmpfs to it, which just happen to work due to the implicit set_fs(KERNEL_DS) during early init right now. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
@@ -62,7 +62,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)
|
||||
console_on_rootfs();
|
||||
/* move initrd over / and chdir/chroot in initrd root */
|
||||
ksys_chdir("/root");
|
||||
do_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||
init_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||
ksys_chroot(".");
|
||||
ksys_setsid();
|
||||
return 0;
|
||||
@@ -99,7 +99,7 @@ static void __init handle_initrd(void)
|
||||
current->flags &= ~PF_FREEZER_SKIP;
|
||||
|
||||
/* move initrd to rootfs' /old */
|
||||
do_mount("..", ".", NULL, MS_MOVE, NULL);
|
||||
init_mount("..", ".", NULL, MS_MOVE, NULL);
|
||||
/* switch root and cwd back to / of rootfs */
|
||||
ksys_chroot("..");
|
||||
|
||||
@@ -113,7 +113,7 @@ static void __init handle_initrd(void)
|
||||
mount_root();
|
||||
|
||||
printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
|
||||
error = do_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
|
||||
error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
|
||||
if (!error)
|
||||
printk("okay\n");
|
||||
else {
|
||||
|
Reference in New Issue
Block a user