--- fs/proc/proc_tty.c +++ fs/proc/proc_tty.c Thu Dec 21 15:16:08 2000 @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,8 @@ int count, int *eof, void *data); static int tty_ldiscs_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); +static int real_tty_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data); /* * The /proc/tty directory inodes... @@ -128,7 +131,32 @@ } /* - * Thsi function is called by register_tty_driver() to handle + * This is the handler for /proc/tty/tty + */ +static int real_tty_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct file * zero = fcheck(0); /* of current task */ + struct tty_struct * tty = NULL; + unsigned int dev = 0; + int len = 0; + off_t begin = 0; + + if (zero) + tty = (struct tty_struct *)zero->private_data; + if (tty && tty->magic == TTY_MAGIC) + dev = kdev_t_to_nr(tty->device); + + len += sprintf(page+len, "%u\n", dev); + + if (off >= len+begin) + return 0; + *start = page + (off-begin); + return ((count < begin+len-off) ? count : begin+len-off); +} + +/* + * This function is called by register_tty_driver() to handle * registering the driver's /proc handler into /proc/tty/driver/ */ void proc_tty_register_driver(struct tty_driver *driver) @@ -178,4 +206,5 @@ create_proc_read_entry("tty/ldiscs", 0, 0, tty_ldiscs_read_proc,NULL); create_proc_read_entry("tty/drivers", 0, 0, tty_drivers_read_proc,NULL); + create_proc_read_entry("tty/tty", 0, 0, real_tty_read_proc,NULL); }