* Re: [PATCH] Improve _tty_make_name [2.5]
@ 2002-05-04 6:52 Ishan O. Jayawardena
0 siblings, 0 replies; only message in thread
From: Ishan O. Jayawardena @ 2002-05-04 6:52 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, akpm, davej
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1787 bytes --]
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();
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1357 bytes --]
--- 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();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-05-03 18:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-04 6:52 [PATCH] Improve _tty_make_name [2.5] Ishan O. Jayawardena
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).