Subject: tiocgdev ioctl Patch-mainline: never, lkml guys don't like it From: kraxel@suse.de add tty ioctl to figure physical device of the console. drivers/char/tty_io.c | 15 +++++++++++++++ fs/compat_ioctl.c | 1 + include/asm-alpha/ioctls.h | 1 + include/asm-arm/ioctls.h | 1 + include/asm-i386/ioctls.h | 1 + include/asm-ia64/ioctls.h | 1 + include/asm-m68k/ioctls.h | 1 + include/asm-mips/ioctls.h | 1 + include/asm-powerpc/ioctls.h | 1 + include/asm-s390/ioctls.h | 1 + include/asm-sh/ioctls.h | 1 + include/asm-sparc/ioctls.h | 1 + include/asm-sparc64/ioctls.h | 1 + include/asm-x86_64/ioctls.h | 1 + 14 files changed, 28 insertions(+) --- a/drivers/char/tty_io.c 2007-07-08 19:32:17.000000000 -0400 +++ b/drivers/char/tty_io.c 2007-08-27 14:02:21.000000000 -0400 @@ -3354,6 +3354,21 @@ int tty_ioctl(struct inode * inode, stru return tioclinux(tty, arg); #endif /* + * Without the real device to which /dev/console is connected, + * blogd can not work. + * blogd spawns a pty/tty pair, + * set /dev/console to the tty of that pair (ioctl TIOCCONS), + * then reads in all input from the current /dev/console, + * buffer or write the readed data to /var/log/boot.msg + * _and_ to the original real device. + */ + case TIOCGDEV: + { + unsigned int ret = new_encode_dev(tty_devnum(real_tty)); + return put_user(ret, (unsigned int __user *)p); + } + + /* * Break handling */ case TIOCSBRK: /* Turn break on, unconditionally */ --- a/fs/compat_ioctl.c 2007-07-08 19:32:17.000000000 -0400 +++ b/fs/compat_ioctl.c 2007-08-27 14:01:21.000000000 -0400 @@ -2451,6 +2451,7 @@ COMPATIBLE_IOCTL(TCSETSW) COMPATIBLE_IOCTL(TCSETSF) COMPATIBLE_IOCTL(TIOCLINUX) COMPATIBLE_IOCTL(TIOCSBRK) +COMPATIBLE_IOCTL(TIOCGDEV) COMPATIBLE_IOCTL(TIOCCBRK) ULONG_IOCTL(TIOCMIWAIT) COMPATIBLE_IOCTL(TIOCGICOUNT) --- a/include/asm-alpha/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-alpha/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -91,6 +91,7 @@ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define TIOCSERCONFIG 0x5453 #define TIOCSERGWILD 0x5454 --- a/include/asm-arm/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-arm/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -52,6 +52,7 @@ #define TCSETSF2 _IOW('T',0x2D, struct termios2) #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 --- a/include/asm-i386/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-i386/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -53,6 +53,7 @@ #define TCSETSF2 _IOW('T',0x2D, struct termios2) #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 #define FIOCLEX 0x5451 --- a/include/asm-ia64/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-ia64/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -55,6 +55,7 @@ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 --- a/include/asm-m68k/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-m68k/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -48,6 +48,7 @@ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 --- a/include/asm-mips/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-mips/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -79,6 +79,7 @@ #define TIOCGSID 0x7416 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ /* I hope the range from 0x5480 on is free ... */ #define TIOCSCTTY 0x5480 /* become controlling tty */ --- a/include/asm-powerpc/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-powerpc/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -91,6 +91,7 @@ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define TIOCSERCONFIG 0x5453 #define TIOCSERGWILD 0x5454 --- a/include/asm-s390/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-s390/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -56,6 +56,7 @@ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 --- a/include/asm-sh/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-sh/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -80,6 +80,7 @@ #define TIOCGSID _IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */ #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */ #define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */ --- a/include/asm-sparc/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-sparc/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -15,6 +15,7 @@ #define TCSETS _IOW('T', 9, struct termios) #define TCSETSW _IOW('T', 10, struct termios) #define TCSETSF _IOW('T', 11, struct termios) +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ /* Note that all the ioctls that are not available in Linux have a * double underscore on the front to: a) avoid some programs to --- a/include/asm-sparc64/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-sparc64/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -16,6 +16,7 @@ #define TCSETS _IOW('T', 9, struct termios) #define TCSETSW _IOW('T', 10, struct termios) #define TCSETSF _IOW('T', 11, struct termios) +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ /* Note that all the ioctls that are not available in Linux have a * double underscore on the front to: a) avoid some programs to --- a/include/asm-x86_64/ioctls.h 2007-07-08 19:32:17.000000000 -0400 +++ b/include/asm-x86_64/ioctls.h 2007-08-27 14:01:21.000000000 -0400 @@ -52,6 +52,7 @@ #define TCSETSF2 _IOW('T',0x2D, struct termios2) #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451