]> nv-tegra.nvidia Code Review - linux-4.9.git/commitdiff
init: modify mount process on diag
authorFrank Chueh <fchueh@nvidia.com>
Fri, 19 Oct 2018 10:49:44 +0000 (18:49 +0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Sun, 4 Nov 2018 03:11:45 +0000 (20:11 -0700)
When the system-as-root feature is enabled, kernel
uses ramdisk in system partition, it causes Diag
ramdisk (factory_ramdisk) doesn't be mounted.
The change modify kernel mount process to use original
ramdisk when compiling the Diag kerenl.

Bug 200449814

Change-Id: Ibdeead4df720a539b517c3fa95a384c244a514bb
Signed-off-by: Frank Chueh <fchueh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1930595
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Ian Chang <ianc@nvidia.com>
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-by: Daniel Fu <danifu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
init/Kconfig
init/do_mounts.c
init/initramfs.c
init/main.c

index 0d6f1ba6434a6b1886497b03b072a55908e2adce..a71368fe332ad302c6c284f6da9e1d11d91ca4f4 100644 (file)
@@ -2280,4 +2280,14 @@ config ASN1
          inform it as to what tags are to be expected in a stream and what
          functions to call on what tags.
 
+config DIAG_KERNEL
+       bool "Diag kernel"
+       default n
+       help
+         Mount boot image to /root for diag image booting when the system-as-root
+         feature is enabled. This config should only be enabled when building Diag
+         kernel.
+
+         If unsure, say N.
+
 source "kernel/Kconfig.locks"
index 1902a1c808319f6e84aa13944ba44ede13a9b02e..d4d96f6c15d42b35dc36b986f153f5132b861149 100644 (file)
@@ -549,6 +549,9 @@ void __init mount_root(void)
 void __init prepare_namespace(void)
 {
        int is_floppy;
+#ifdef CONFIG_DIAG_KERNEL
+       int err;
+#endif
 
        if (root_delay) {
                printk(KERN_INFO "Waiting %d sec before mounting root device...\n",
@@ -601,8 +604,17 @@ void __init prepare_namespace(void)
        mount_root();
 out:
        devtmpfs_mount("dev");
+#ifndef CONFIG_DIAG_KERNEL
        sys_mount(".", "/", NULL, MS_MOVE, NULL);
        sys_chroot(".");
+#else
+       /* Mount root to /system_root for Diag image */
+       sys_mount(".", "/system_root", NULL, MS_MOVE, NULL);
+       err = sys_mount("/system_root/system", "/system", NULL, MS_BIND, NULL);
+       pr_info("Diag: bind mount /system, err=%d\n", err);
+       sys_chroot("/");
+       sys_chdir("/");
+#endif
 }
 
 static bool is_tmpfs;
index bf903182cbbb0b29250b020243e15ffbe91e9397..993c754ccfbcd6051e1408fc8b1511e70c4cc246 100644 (file)
@@ -622,6 +622,11 @@ static int __init populate_rootfs(void)
 {
        char *err;
 
+#ifdef CONFIG_DIAG_KERNEL
+       pr_info("Skip init ramfs on Diag image\n");
+       do_skip_initramfs = 0;
+#endif
+
        if (do_skip_initramfs)
                return default_rootfs();
 
index 46ca3e013314d1a821a899dc0067a8a540d14929..0e03698f6056845bcda0215eb0b0e5f5c7d10b51 100644 (file)
@@ -1030,7 +1030,7 @@ static noinline void __init kernel_init_freeable(void)
         * check if there is an early userspace init.  If yes, let it do all
         * the work
         */
-
+#ifndef CONFIG_DIAG_KERNEL
        if (!ramdisk_execute_command)
                ramdisk_execute_command = "/init";
 
@@ -1038,6 +1038,10 @@ static noinline void __init kernel_init_freeable(void)
                ramdisk_execute_command = NULL;
                prepare_namespace();
        }
+#else
+       pr_info("kernel-init: Diag: It's diag image, start diag kernel init.\n");
+       prepare_namespace();
+#endif
 
        /*
         * Ok, we have completed the initial bootup, and