diff options
author | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2011-05-19 21:09:28 +0200 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2011-05-19 21:20:56 +0200 |
commit | 00d468be3288a8d9c8318a24b0d253193927c670 (patch) | |
tree | 793e8eaf5311798bcefd007a0f2bfa87530a969a | |
parent | 111510be1e9bd6804c0cbec5e7a52d5563011d36 (diff) |
initramfs: Allow using initramfs with empty /dev
When booting a kernel with no initramfs, there is a basic /dev hardcoded
in noinitramfs.c.
This contains a /dev/console device. Also, DEVTMPFS can be used to have
the kernel mount a tmpfs /dev and have the devices create nodes on it
when they are added.
When using an initramfs there is no embedded /dev in the kernel, and
the DEVTMPFS is mounted after the sys_open call to /dev/console in
kernel_init. Realistically, the kernel expects the initramfs to contain
a /dev/console node.
This patch reuses Digi specific TMPFSDEV which was used before the
DEVTMPFS support existed to allow for a tmpfs to be mounted in /dev with
a console and a null node so that initramfs with an empty /dev folder
can still boot.
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
-rw-r--r-- | init/main.c | 11 | ||||
-rw-r--r-- | lib/Kconfig.debug | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/init/main.c b/init/main.c index 98df0b0c5f47..923c9972ac74 100644 --- a/init/main.c +++ b/init/main.c @@ -834,11 +834,6 @@ static noinline int init_post(void) system_state = SYSTEM_RUNNING; numa_default_policy(); -#ifdef CONFIG_TMPFSDEV - sys_mount("tmpfsdev", "/dev", "tmpfs", 0, "size=64k"); - sys_mknod("/dev/console", S_IFCHR | 0600, new_encode_dev(MKDEV(5, 1))); - sys_mknod("/dev/null", S_IFCHR | 0600, new_encode_dev(MKDEV(1, 3))); -#endif current->signal->flags |= SIGNAL_UNKILLABLE; @@ -906,6 +901,12 @@ static int __init kernel_init(void * unused) do_basic_setup(); +#ifdef CONFIG_TMPFSDEV + sys_mount("tmpfsdev", "/dev", "tmpfs", 0, "size=64k"); + sys_mknod("/dev/console", S_IFCHR | 0600, new_encode_dev(MKDEV(5, 1))); + sys_mknod("/dev/null", S_IFCHR | 0600, new_encode_dev(MKDEV(1, 3))); +#endif + /* Open the /dev/console on the rootfs, this should never fail */ if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) printk(KERN_WARNING "Warning: unable to open an initial console.\n"); diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e4161a291fa9..be092e31cc49 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1119,17 +1119,19 @@ config ATOMIC64_SELFTEST config TMPFSDEV bool "Create some device nodes in tmpfs" - depends on TMPFS + depends on TMPFS && BLK_DEV_INITRD default n help This hack allows the kernel to create some needed device nodes itself - on booting. It mounts a tmpfs in /dev and creates the nodes inside. + on booting when using an initramfs which doesn't contain them. - This supports customization of root filesystems without root - privileges. + It mounts a tmpfs in /dev and creates the nodes inside. Currently created nodes: console, null. + The recommended way is to include the device nodes on the initramfs + itself. + source "samples/Kconfig" source "lib/Kconfig.kgdb" |