Re: [PATCH] Improve _tty_make_name [2.5]

From: Ishan O. Jayawardena (ioshadij@hotmail.com)
Date: Sat May 04 2002 - 01:52:02 EST


Hi,
        This is a version of my previous patch re-diffed against
2.5.12. Without this or an equivalent fix, users wouldn't be able to
differentiate between certain devices (the serial device - console.c - is
one). As it currently is, tty_name() will print "ttyS" regardless of the
real device, be it ttyS0, ttyS2, etc.; assuming no devfs.
        More sanity checks are possible, but would be superflous...

Best Regards,
Ishan Oshadi Jayawardena

-----------------------------------------
--- linux/drivers/char/tty_io.c.1 Sat May 4 00:27:04 2002
+++ linux/drivers/char/tty_io.c Sat May 4 00:36:25 2002
@@ -189,10 +189,20 @@ _tty_make_name(struct tty_struct *tty, c
 
         if (!tty) /* Hmm. NULL pointer. That's fun. */
                 strcpy(buf, "NULL tty");
- else
- sprintf(buf, name,
- idx + tty->driver.name_base);
-
+ else {
+ if (strchr(name, '%')) {
+ /*
+ * Assuming printf() style
+ * format strings are present...
+ */
+ sprintf(buf, name,
+ idx + tty->driver.name_base);
+ } else { /* Old style... */
+ sprintf(buf, "%s%d", name,
+ idx + tty->driver.name_base);
+ }
+ }
+
         return buf;
 }
 
@@ -2305,14 +2315,22 @@ void __init tty_init(void)
         
 #ifdef CONFIG_VT
         dev_console_driver = dev_tty_driver;
+#ifdef CONFIG_DEVFS_FS
         dev_console_driver.driver_name = "/dev/vc/0";
+#else
+ dev_console_driver.driver_name = "/dev/tty0";
+#endif
         dev_console_driver.name = dev_console_driver.driver_name + 5;
         dev_console_driver.major = TTY_MAJOR;
         dev_console_driver.type = TTY_DRIVER_TYPE_SYSTEM;
         dev_console_driver.subtype = SYSTEM_TYPE_CONSOLE;
 
         if (tty_register_driver(&dev_console_driver))
+#ifdef CONFIG_DEVFS_FS
+ panic("Couldn't register /dev/vc/0 driver");
+#else
                 panic("Couldn't register /dev/tty0 driver\n");
+#endif
 
         vcs_init();
         kbd_init();



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 07 2002 - 22:00:20 EST