Hi,

I would like my kernel to create /dev/console device entry if one is not 
present on root filesystem.

I've used code from init/noinitramfs.c and copied it in init/main.c (see the 
patch). The problem is that /dev/console indeed gets created, but the system 
won't boot further.
I can verify existence of /dev/console, because I use NFS root filesystem and 
the /dev/console appears upon boot on NFS server.
Upon second boot (power cycle) the system boot fine (/dev/console exista, since 
it was created on first boot).

What am I missing here??

...
[42949376.297514] Looking up port of RPC 100003/2 on 10.0.0.1
[42949376.314490] Looking up port of RPC 100005/1 on 10.0.0.1
[42949376.398672] VFS: Mounted root (nfs filesystem).
[42949376.405593] Freeing unused kernel memory: 56k freed
[42949376.411909] Warning: unable to open an initial console.
[42949376.428129] Success creating /dev/console.
^^^^^^^^^^^
 HANG

Thank you,
Hinko

-- 
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: [EMAIL PROTECTED]
Http: www.cetrtapot.si

--- init/main.c.orig	2008-07-13 23:51:29.000000000 +0200
+++ init/main.c	2008-07-31 13:15:21.000000000 +0200
@@ -803,8 +803,25 @@
 	numa_default_policy();
 
 	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
+	{
 		printk(KERN_WARNING "Warning: unable to open an initial console.\n");
 
+		sys_mkdir("/dev", 0755);
+
+		if (sys_mknod((const char __user *) "/dev/console",
+				S_IFCHR | S_IRUSR | S_IWUSR,
+				new_encode_dev(MKDEV(5, 1))) < 0);
+		{
+			printk(KERN_WARNING "Warning: failed to create /dev/console.\n");
+			goto out;
+		}
+
+		sys_mkdir("/root", 0700);
+		printk(KERN_NOTICE "Success creating /dev/console.\n");
+	}
+
+out:
+
 	(void) sys_dup(0);
 	(void) sys_dup(0);
 
@@ -823,6 +840,7 @@
 	 * trying to recover a really broken machine.
 	 */
 	if (execute_command) {
+		printk(KERN_NOTICE "Running %s...\n", execute_command);
 		run_init_process(execute_command);
 		printk(KERN_WARNING "Failed to execute %s.  Attempting "
 					"defaults...\n", execute_command);

Reply via email to