Subject: [patch] tiocgdev add tiocgdev ioctl support for suse's blogd Signed-off-by: Gerd Knorr --- arch/x86_64/ia32/ia32_ioctl.c | 20 -------------------- drivers/char/tty_io.c | 15 +++++++++++++++ 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-ppc/ioctls.h | 1 + include/asm-ppc64/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 + include/linux/compat_ioctl.h | 1 + 16 files changed, 29 insertions(+), 20 deletions(-) Index: linux-2.6.12-rc3/arch/x86_64/ia32/ia32_ioctl.c =================================================================== --- linux-2.6.12-rc3.orig/arch/x86_64/ia32/ia32_ioctl.c 2005-03-07 10:14:05.000000000 +0100 +++ linux-2.6.12-rc3/arch/x86_64/ia32/ia32_ioctl.c 2005-04-26 13:13:48.000000000 +0200 @@ -18,25 +18,6 @@ #define CODE #include "compat_ioctl.c" -#ifndef TIOCGDEV -#define TIOCGDEV _IOR('T',0x32, unsigned int) -#endif -static int tiocgdev(unsigned fd, unsigned cmd, unsigned int __user *ptr) -{ - - struct file *file = fget(fd); - struct tty_struct *real_tty; - - if (!file) - return -EBADF; - if (file->f_op->ioctl != tty_ioctl) - return -EINVAL; - real_tty = (struct tty_struct *)file->private_data; - if (!real_tty) - return -EINVAL; - return put_user(new_encode_dev(tty_devnum(real_tty)), ptr); -} - #define RTC_IRQP_READ32 _IOR('p', 0x0b, unsigned int) /* Read IRQ rate */ #define RTC_IRQP_SET32 _IOW('p', 0x0c, unsigned int) /* Set IRQ rate */ #define RTC_EPOCH_READ32 _IOR('p', 0x0d, unsigned) /* Read epoch */ @@ -176,7 +157,6 @@ COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - COMPATIBLE_IOCTL(FIOQSIZE) /* And these ioctls need translation */ -HANDLE_IOCTL(TIOCGDEV, tiocgdev) /* realtime device */ HANDLE_IOCTL(RTC_IRQP_READ, rtc32_ioctl) HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl) Index: linux-2.6.12-rc3/drivers/char/tty_io.c =================================================================== --- linux-2.6.12-rc3.orig/drivers/char/tty_io.c 2005-04-26 12:18:54.000000000 +0200 +++ linux-2.6.12-rc3/drivers/char/tty_io.c 2005-04-26 13:13:48.000000000 +0200 @@ -2367,6 +2367,21 @@ int tty_ioctl(struct inode * inode, stru case TIOCMBIC: case TIOCMBIS: return tty_tiocmset(tty, file, cmd, p); + /* + * 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); + } + } if (tty->driver->ioctl) { retval = (tty->driver->ioctl)(tty, file, cmd, arg); Index: linux-2.6.12-rc3/include/asm-alpha/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-alpha/ioctls.h 2005-03-07 10:14:47.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-alpha/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-arm/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-arm/ioctls.h 2005-03-07 10:13:49.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-arm/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-i386/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-i386/ioctls.h 2005-03-07 10:12:46.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-i386/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -49,6 +49,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 #define FIOCLEX 0x5451 Index: linux-2.6.12-rc3/include/asm-ia64/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-ia64/ioctls.h 2005-03-07 10:12:52.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-ia64/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-m68k/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-m68k/ioctls.h 2005-03-07 10:14:32.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-m68k/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-mips/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-mips/ioctls.h 2005-03-07 10:15:10.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-mips/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 */ Index: linux-2.6.12-rc3/include/asm-ppc/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-ppc/ioctls.h 2005-03-07 10:14:59.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-ppc/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -88,6 +88,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 Index: linux-2.6.12-rc3/include/asm-ppc64/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-ppc64/ioctls.h 2005-03-07 10:12:24.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-ppc64/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -95,6 +95,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 Index: linux-2.6.12-rc3/include/asm-s390/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-s390/ioctls.h 2005-03-07 10:14:12.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-s390/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-sh/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-sh/ioctls.h 2005-03-07 10:14:29.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-sh/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 */ Index: linux-2.6.12-rc3/include/asm-sparc/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-sparc/ioctls.h 2005-03-07 10:13:48.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-sparc/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-sparc64/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-sparc64/ioctls.h 2005-03-07 10:14:05.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-sparc64/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/asm-x86_64/ioctls.h =================================================================== --- linux-2.6.12-rc3.orig/include/asm-x86_64/ioctls.h 2005-03-07 10:15:44.000000000 +0100 +++ linux-2.6.12-rc3/include/asm-x86_64/ioctls.h 2005-04-26 13:13:48.000000000 +0200 @@ -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 Index: linux-2.6.12-rc3/include/linux/compat_ioctl.h =================================================================== --- linux-2.6.12-rc3.orig/include/linux/compat_ioctl.h 2005-04-26 12:19:08.000000000 +0200 +++ linux-2.6.12-rc3/include/linux/compat_ioctl.h 2005-04-26 13:13:48.000000000 +0200 @@ -28,6 +28,7 @@ COMPATIBLE_IOCTL(TIOCSBRK) COMPATIBLE_IOCTL(TIOCCBRK) ULONG_IOCTL(TIOCMIWAIT) COMPATIBLE_IOCTL(TIOCGICOUNT) +COMPATIBLE_IOCTL(TIOCGDEV) /* Little t */ COMPATIBLE_IOCTL(TIOCGETD) COMPATIBLE_IOCTL(TIOCSETD)