Re: creating /dev/console

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas De Schampheleire wrote:
> Hello,
> 
> You are creating /dev/console after the system is trying to use it.
> No second attempt is made to open /dev/console, so the system stays blocked.
> 
> /dev/console should be created before the point where the warning
> currently is displayed...

Indeed - stupido me :/, I somehow missed that sys_open()..

Here is working version of patch in case someone might need similar.
Another approach that might work would be to open the /dev/console
for the second time when the device entry is created..

Thank you!

Best regards,
Hinko

-- 
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar@xxxxxxxxxxxx
Http: www.cetrtapot.si

--- init/main.c.orig	2008-07-13 23:51:29.000000000 +0200
+++ init/main.c	2008-07-31 14:42:57.000000000 +0200
@@ -796,12 +796,27 @@
  */
 static int noinline init_post(void)
 {
+	struct __old_kernel_stat stat;
+
 	free_initmem();
 	unlock_kernel();
 	mark_rodata_ro();
 	system_state = SYSTEM_RUNNING;
 	numa_default_policy();
 
+	if (sys_stat((char __user *) "/dev/console", &stat) < 0)
+	{
+		printk(KERN_WARNING "Warning: missing /dev/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");
+
+		printk(KERN_NOTICE "Info: success creating /dev/console.\n");
+	}
+
 	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
 		printk(KERN_WARNING "Warning: unable to open an initial console.\n");
 
@@ -823,6 +838,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);

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux