Blob Blame History Raw
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-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/ioctls.h     |    1 +
 13 files changed, 27 insertions(+)

--- linux-2.6.24.orig/drivers/char/tty_io.c
+++ linux-2.6.24/drivers/char/tty_io.c
@@ -3406,6 +3406,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 */
--- linux-2.6.24.orig/fs/compat_ioctl.c
+++ linux-2.6.24/fs/compat_ioctl.c
@@ -1929,6 +1929,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)
--- linux-2.6.24.orig/include/asm-alpha/ioctls.h
+++ linux-2.6.24/include/asm-alpha/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-arm/ioctls.h
+++ linux-2.6.24/include/asm-arm/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-x86/ioctls.h
+++ linux-2.6.24/include/asm-x86/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-ia64/ioctls.h
+++ linux-2.6.24/include/asm-ia64/ioctls.h
@@ -59,6 +59,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
--- linux-2.6.24.orig/include/asm-m68k/ioctls.h
+++ linux-2.6.24/include/asm-m68k/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-mips/ioctls.h
+++ linux-2.6.24/include/asm-mips/ioctls.h
@@ -83,6 +83,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 */
 
 /* I hope the range from 0x5480 on is free ... */
 #define TIOCSCTTY	0x5480		/* become controlling tty */
--- linux-2.6.24.orig/include/asm-powerpc/ioctls.h
+++ linux-2.6.24/include/asm-powerpc/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-s390/ioctls.h
+++ linux-2.6.24/include/asm-s390/ioctls.h
@@ -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
--- linux-2.6.24.orig/include/asm-sh/ioctls.h
+++ linux-2.6.24/include/asm-sh/ioctls.h
@@ -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 */
--- linux-2.6.24.orig/include/asm-sparc/ioctls.h
+++ linux-2.6.24/include/asm-sparc/ioctls.h
@@ -19,6 +19,7 @@
 #define TCSETS2		_IOW('T', 13, struct termios2)
 #define TCSETSW2	_IOW('T', 14, struct termios2)
 #define TCSETSF2	_IOW('T', 15, struct termios2)
+#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
--- linux-2.6.24.orig/include/asm-sparc64/ioctls.h
+++ linux-2.6.24/include/asm-sparc64/ioctls.h
@@ -20,6 +20,7 @@
 #define TCSETS2		_IOW('T', 13, struct termios2)
 #define TCSETSW2	_IOW('T', 14, struct termios2)
 #define TCSETSF2	_IOW('T', 15, struct termios2)
+#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