Messages in this thread Patches in this message | | | Date | Wed, 1 May 2002 10:14:55 -0600 (GMT+6) | From | "Ishan O. Jayawardena" <> | Subject | [PATCH] Improve _tty_make_name |
| |
_tty_make_name() isn't consistent wrt to devfs because the non-devfs name of many drivers don't have printf() style format strings embedded, while their respective devfs names do. Some time ago a thread was born here under the topic "Serial Driver Name Question (kernels 2.4.x)", but apparently, nothing came out of it. This way, if a device name has format strings ambedded, then so be it. If not, the behaviour of the 2.2.x tty_name() is assumed. The patch #2 attached remedies this, and some trivia. Patch #1 is a trivial fix for pty devices. Diffed against 2.4.19-pre7-ac2. Should apply to the mainline tree without hassle.
Please CC me: ioshadij@hotmail.com
Cheerio!
Ishan Oshadi Jayawardena
------------------------------------------- Patch #2: --- linux/drivers/char/tty_io.c.1 Sun Apr 28 11:28:07 2002 +++ linux/drivers/char/tty_io.c Wed May 1 08:58:02 2002 @@ -195,9 +195,16 @@ _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 + sprintf(buf, "%s%d", name, idx + tty->driver.name_base); + } return buf; } @@ -2320,15 +2327,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 kbd_init(); #endif ------------------ Patch #1: --- linux/drivers/char/pty.c.1 Sun Apr 28 12:22:59 2002 +++ linux/drivers/char/pty.c Wed May 1 08:54:55 2002 @@ -458,11 +458,7 @@ int __init pty_init(void) init_waitqueue_head(&ptm_state[i][j].open_wait); pts_driver[i] = pty_slave_driver; -#ifdef CONFIG_DEVFS_FS pts_driver[i].name = "pts/%d"; -#else - pts_driver[i].name = "pts"; -#endif pts_driver[i].proc_entry = 0; pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i; pts_driver[i].minor_start = 0; --- linux/drivers/char/pty.c.1 Sun Apr 28 12:22:59 2002 +++ linux/drivers/char/pty.c Wed May 1 08:54:55 2002 @@ -458,11 +458,7 @@ int __init pty_init(void) init_waitqueue_head(&ptm_state[i][j].open_wait); pts_driver[i] = pty_slave_driver; -#ifdef CONFIG_DEVFS_FS pts_driver[i].name = "pts/%d"; -#else - pts_driver[i].name = "pts"; -#endif pts_driver[i].proc_entry = 0; pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i; pts_driver[i].minor_start = 0;--- linux/drivers/char/tty_io.c.1 Sun Apr 28 11:28:07 2002 +++ linux/drivers/char/tty_io.c Wed May 1 08:58:02 2002 @@ -195,9 +195,16 @@ _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 + sprintf(buf, "%s%d", name, idx + tty->driver.name_base); + } return buf; } @@ -2320,15 +2327,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 kbd_init(); #endif
| |