Re: Problem with TIOCGDEV.

Kurt Garloff <[email protected]> Mon, 7 Jul 2003 21:45:49 +0200
Newsgroups gmane.linux.suse.axp
Organization SuSE(DE), TU/e(NL)
Message-ID <[email protected]>
Hi Thomas,

On Mon, Jul 07, 2003 at 03:43:19PM +0200, Speigner Thomas wrote:
> Hi guys,
>  
> does anyone knows where to get the kernel patch for TIOCGDEV for kernel
> 2.4.21 ???

Find it attached.

PS: Your mail contains >80% of signature plus stupid disclaimer.

Regards,
-- 
Kurt Garloff  <[email protected]>                          Eindhoven, NL
GPG key: See mail header, key servers                 SuSE Labs (Head)
SuSE Linux AG, Nuernberg, DE                            SCSI, Security
TIOCGDEV (text/plain, 10.9 KB)
diff -purN linux-2.4.21/arch/ppc64/kernel/ioctl32.c linux-2.4.21.TIOCGDEV/arch/ppc64/kernel/ioctl32.c
--- linux-2.4.21/arch/ppc64/kernel/ioctl32.c	2003-06-26 14:51:21.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/arch/ppc64/kernel/ioctl32.c	2003-06-26 14:52:55.000000000 +0200
@@ -3810,6 +3810,7 @@ COMPATIBLE_IOCTL(TCSETSW),
 COMPATIBLE_IOCTL(TCSETSF),
 COMPATIBLE_IOCTL(TIOCLINUX),
 COMPATIBLE_IOCTL(TIOCSTART),
+COMPATIBLE_IOCTL(TIOCGDEV),
 /* Little t */
 COMPATIBLE_IOCTL(TIOCGETD),
 COMPATIBLE_IOCTL(TIOCSETD),
diff -purN linux-2.4.21/arch/sparc64/kernel/ioctl32.c linux-2.4.21.TIOCGDEV/arch/sparc64/kernel/ioctl32.c
--- linux-2.4.21/arch/sparc64/kernel/ioctl32.c	2003-06-26 14:51:18.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/arch/sparc64/kernel/ioctl32.c	2003-06-26 14:52:55.000000000 +0200
@@ -4345,6 +4345,7 @@ COMPATIBLE_IOCTL(TCSETSF)
 COMPATIBLE_IOCTL(TIOCLINUX)
 COMPATIBLE_IOCTL(TIOCSTART)
 COMPATIBLE_IOCTL(TIOCSTOP)
+COMPATIBLE_IOCTL(TIOCGDEV)
 /* Little t */
 COMPATIBLE_IOCTL(TIOCGETD)
 COMPATIBLE_IOCTL(TIOCSETD)
diff -purN linux-2.4.21/drivers/char/tty_io.c linux-2.4.21.TIOCGDEV/drivers/char/tty_io.c
--- linux-2.4.21/drivers/char/tty_io.c	2003-06-26 14:51:20.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/drivers/char/tty_io.c	2003-06-26 15:06:45.000000000 +0200
@@ -1842,6 +1842,18 @@ int tty_ioctl(struct inode * inode, stru
 		case TIOCTTYGSTRUCT:
 			return tiocttygstruct(tty, (struct tty_struct *) arg);
 
+			/*
+			 * 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:
+			return put_user (kdev_t_to_nr (real_tty->device), (unsigned int*) arg);
+
 		/*
 		 * Break handling
 		 */
diff -purN linux-2.4.21/include/asm-alpha/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-alpha/ioctls.h
--- linux-2.4.21/include/asm-alpha/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-alpha/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -94,6 +94,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
diff -purN linux-2.4.21/include/asm-arm/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-arm/ioctls.h
--- linux-2.4.21/include/asm-arm/ioctls.h	2001-02-09 01:32:44.000000000 +0100
+++ linux-2.4.21.TIOCGDEV/include/asm-arm/ioctls.h	2003-06-26 14:52:55.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  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
diff -purN linux-2.4.21/include/asm-i386/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-i386/ioctls.h
--- linux-2.4.21/include/asm-i386/ioctls.h	2003-06-26 14:51:17.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-i386/ioctls.h	2003-06-26 14:52:55.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  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
diff -purN linux-2.4.21/include/asm-ia64/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-ia64/ioctls.h
--- linux-2.4.21/include/asm-ia64/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-ia64/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -54,6 +54,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
diff -purN linux-2.4.21/include/asm-m68k/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-m68k/ioctls.h
--- linux-2.4.21/include/asm-m68k/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-m68k/ioctls.h	2003-06-26 14:52:55.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  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
diff -purN linux-2.4.21/include/asm-mips/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-mips/ioctls.h
--- linux-2.4.21/include/asm-mips/ioctls.h	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.21.TIOCGDEV/include/asm-mips/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -89,6 +89,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 */
 
 #define TIOCSERCONFIG	0x5488
 #define TIOCSERGWILD	0x5489
diff -purN linux-2.4.21/include/asm-mips64/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-mips64/ioctls.h
--- linux-2.4.21/include/asm-mips64/ioctls.h	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.21.TIOCGDEV/include/asm-mips64/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -89,6 +89,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 */
 
 #define TIOCSERCONFIG	0x5488
 #define TIOCSERGWILD	0x5489
diff -purN linux-2.4.21/include/asm-ppc/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-ppc/ioctls.h
--- linux-2.4.21/include/asm-ppc/ioctls.h	2003-06-13 16:51:38.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-ppc/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -89,6 +89,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
diff -purN linux-2.4.21/include/asm-ppc64/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-ppc64/ioctls.h
--- linux-2.4.21/include/asm-ppc64/ioctls.h	2003-06-13 16:51:38.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-ppc64/ioctls.h	2003-06-26 14:53:53.000000000 +0200
@@ -96,7 +96,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 TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
 
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
diff -purN linux-2.4.21/include/asm-s390/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-s390/ioctls.h
--- linux-2.4.21/include/asm-s390/ioctls.h	2001-02-13 23:13:44.000000000 +0100
+++ linux-2.4.21.TIOCGDEV/include/asm-s390/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -57,6 +57,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
diff -purN linux-2.4.21/include/asm-s390x/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-s390x/ioctls.h
--- linux-2.4.21/include/asm-s390x/ioctls.h	2001-02-13 23:13:44.000000000 +0100
+++ linux-2.4.21.TIOCGDEV/include/asm-s390x/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -57,6 +57,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
diff -purN linux-2.4.21/include/asm-sh/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-sh/ioctls.h
--- linux-2.4.21/include/asm-sh/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-sh/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -81,6 +81,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 */
diff -purN linux-2.4.21/include/asm-sparc/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-sparc/ioctls.h
--- linux-2.4.21/include/asm-sparc/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-sparc/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -100,6 +100,7 @@
 #define TIOCSSERIAL	0x541F
 #define TCSBRKP		0x5425
 #define TIOCTTYGSTRUCT	0x5426
+#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
 #define TIOCSERSWILD	0x5455
diff -purN linux-2.4.21/include/asm-sparc64/ioctls.h linux-2.4.21.TIOCGDEV/include/asm-sparc64/ioctls.h
--- linux-2.4.21/include/asm-sparc64/ioctls.h	2003-06-26 14:51:16.000000000 +0200
+++ linux-2.4.21.TIOCGDEV/include/asm-sparc64/ioctls.h	2003-06-26 14:52:55.000000000 +0200
@@ -101,6 +101,7 @@
 #define TIOCSSERIAL	0x541F
 #define TCSBRKP		0x5425
 #define TIOCTTYGSTRUCT	0x5426
+#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
 #define TIOCSERSWILD	0x5455
unimap_set (text/plain, 1.3 KB)
diff -urN linux-2.4.4.tmp/drivers/char/vt.c linux-2.4.4.SuSE/drivers/char/vt.c
--- linux-2.4.4.tmp/drivers/char/vt.c	Fri Feb  9 20:30:22 2001
+++ linux-2.4.4.SuSE/drivers/char/vt.c	Mon May  7 17:49:59 2001
@@ -392,7 +392,7 @@
 }
 
 static inline int 
-do_unimap_ioctl(int cmd, struct unimapdesc *user_ud,int perm)
+do_unimap_ioctl(int cmd, struct unimapdesc *user_ud, int perm, unsigned int console)
 {
 	struct unimapdesc tmp;
 	int i = 0; 
@@ -408,9 +408,11 @@
 	case PIO_UNIMAP:
 		if (!perm)
 			return -EPERM;
-		return con_set_unimap(fg_console, tmp.entry_ct, tmp.entries);
+		return con_set_unimap(console, tmp.entry_ct, tmp.entries);
 	case GIO_UNIMAP:
-		return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
+		if (!perm && fg_console != console)
+			return -EPERM;
+		return con_get_unimap(console, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
 	}
 	return 0;
 }
@@ -1029,13 +1031,13 @@
 			return -EPERM;
 		i = copy_from_user(&ui, (void *)arg, sizeof(struct unimapinit));
 		if (i) return -EFAULT;
-		con_clear_unimap(fg_console, &ui);
+		con_clear_unimap(console, &ui);
 		return 0;
 	      }
 
 	case PIO_UNIMAP:
 	case GIO_UNIMAP:
-		return do_unimap_ioctl(cmd, (struct unimapdesc *)arg, perm);
+		return do_unimap_ioctl(cmd, (struct unimapdesc *)arg, perm, console);
 
 	case VT_LOCKSWITCH:
 		if (!suser())
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE/Cc3sxmLh6hyYd04RAiZUAJ4qRqT67Cv9fdnLKnXcrbu8gMmyZwCgqvpS
HDZYZDQnjfFC7s5DDvXJqsM=
=XTkV
-----END PGP SIGNATURE-----