Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639903

[PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT

From Rob Landley <rob@landley.net>
Newsgroups linux.kernel
Subject [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT
Date 2017-05-11 19:10 +0200
Message-ID <tFZLc-KD-9@gated-at.bofh.it> (permalink)
References <tDwaC-tB-5@gated-at.bofh.it> <tFl1n-7qN-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rob Landley <rob@landley.net>

Make initramfs honor CONFIG_DEVTMPFS_MOUNT, move /dev/console
open after devtmpfs mount, and update help text.

Signed-off-by: Rob Landley <rob@landley.net>
---

 drivers/base/Kconfig |   14 ++++----------
 init/main.c          |   15 +++++++++------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d718ae4..74779ee 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -48,16 +48,10 @@ config DEVTMPFS_MOUNT
 	bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs"
 	depends on DEVTMPFS
 	help
-	  This will instruct the kernel to automatically mount the
-	  devtmpfs filesystem at /dev, directly after the kernel has
-	  mounted the root filesystem. The behavior can be overridden
-	  with the commandline parameter: devtmpfs.mount=0|1.
-	  This option does not affect initramfs based booting, here
-	  the devtmpfs filesystem always needs to be mounted manually
-	  after the rootfs is mounted.
-	  With this option enabled, it allows to bring up a system in
-	  rescue mode with init=/bin/sh, even when the /dev directory
-	  on the rootfs is completely empty.
+	  Automatically mount devtmpfs at /dev on the root filesystem, which
+	  lets the system come up in rescue mode with [rd]init=/bin/sh.
+	  Override with devtmpfs.mount=0 on the commandline. Initramfs can
+	  create a /dev dir as needed, other rootfs needs the mount point.
 
 config STANDALONE
 	bool "Select only drivers that don't need compile-time external firmware"
diff --git a/init/main.c b/init/main.c
index f866510..9ec09ff 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1038,12 +1038,6 @@ static noinline void __init kernel_init_freeable(void)
 
 	do_basic_setup();
 
-	/* Open the /dev/console on the rootfs, this should never fail */
-	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
-		pr_err("Warning: unable to open an initial console.\n");
-
-	(void) sys_dup(0);
-	(void) sys_dup(0);
 	/*
 	 * check if there is an early userspace init.  If yes, let it do all
 	 * the work
@@ -1055,8 +1049,17 @@ static noinline void __init kernel_init_freeable(void)
 	if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
 		ramdisk_execute_command = NULL;
 		prepare_namespace();
+	} else if (IS_ENABLED(CONFIG_DEVTMPFS_MOUNT)) {
+		sys_mkdir("/dev", 0755);
+		devtmpfs_mount("/dev");
 	}
 
+	/* Open the /dev/console on the rootfs, this should never fail */
+	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
+		pr_err("Warning: unable to open an initial console.\n");
+	(void) sys_dup(0);
+	(void) sys_dup(0);
+
 	/*
 	 * Ok, we have completed the initial bootup, and
 	 * we're essentially up and running. Get rid of the

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Rob Landley <rob@landley.net> - 2017-05-04 23:10 +0200
  Re: [PATCH] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Kees Cook <keescook@chromium.org> - 2017-05-05 01:40 +0200
  Re: [PATCH] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Andrew Morton <akpm@linux-foundation.org> - 2017-05-09 23:40 +0200
    Re: [PATCH] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Rob Landley <rob@landley.net> - 2017-05-11 19:10 +0200
    [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Rob Landley <rob@landley.net> - 2017-05-11 19:10 +0200
      Re: [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Rob Landley <rob@landley.net> - 2017-05-14 23:40 +0200
        Re: [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Michael Ellerman <mpe@ellerman.id.au> - 2017-05-17 06:00 +0200
          Re: [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT Rob Landley <rob@landley.net> - 2017-05-17 23:20 +0200

csiph-web