tty: Add EXTPROC support for LINEMODE
authorhyc@symas.com <hyc@symas.com>
Tue, 22 Jun 2010 17:14:49 +0000 (10:14 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 10 Aug 2010 20:47:39 +0000 (13:47 -0700)
This patch is against the 2.6.34 source.

Paraphrased from the 1989 BSD patch by David Borman @ cray.com:

     These are the changes needed for the kernel to support
     LINEMODE in the server.

     There is a new bit in the termios local flag word, EXTPROC.
     When this bit is set, several aspects of the terminal driver
     are disabled.  Input line editing, character echo, and mapping
     of signals are all disabled.  This allows the telnetd to turn
     off these functions when in linemode, but still keep track of
     what state the user wants the terminal to be in.

     New ioctl:
         TIOCSIG         Generate a signal to processes in the
                         current process group of the pty.

     There is a new mode for packet driver, the TIOCPKT_IOCTL bit.
     When packet mode is turned on in the pty, and the EXTPROC bit
     is set, then whenever the state of the pty is changed, the
     next read on the master side of the pty will have the TIOCPKT_IOCTL
     bit set.  This allows the process on the server side of the pty
     to know when the state of the terminal has changed; it can then
     issue the appropriate ioctl to retrieve the new state.

Since the original BSD patches accompanied the source code for telnet
I've left that reference here, but obviously the feature is useful for
any remote terminal protocol, including ssh.

The corresponding feature has existed in the BSD tty driver since 1989.
For historical reference, a good copy of the relevant files can be found
here:

http://anonsvn.mit.edu/viewvc/krb5/trunk/src/appl/telnet/?pathrev=17741

Signed-off-by: Howard Chu <hyc@symas.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
39 files changed:
arch/alpha/include/asm/ioctls.h
arch/alpha/include/asm/termbits.h
arch/arm/include/asm/ioctls.h
arch/arm/include/asm/termbits.h
arch/avr32/include/asm/ioctls.h
arch/avr32/include/asm/termbits.h
arch/cris/include/asm/ioctls.h
arch/cris/include/asm/termbits.h
arch/frv/include/asm/ioctls.h
arch/frv/include/asm/termbits.h
arch/h8300/include/asm/ioctls.h
arch/h8300/include/asm/termbits.h
arch/ia64/include/asm/ioctls.h
arch/ia64/include/asm/termbits.h
arch/m32r/include/asm/ioctls.h
arch/m32r/include/asm/termbits.h
arch/m68k/include/asm/ioctls.h
arch/m68k/include/asm/termbits.h
arch/mips/include/asm/ioctls.h
arch/mips/include/asm/termbits.h
arch/mn10300/include/asm/ioctls.h
arch/mn10300/include/asm/termbits.h
arch/parisc/include/asm/ioctls.h
arch/parisc/include/asm/termbits.h
arch/powerpc/include/asm/ioctls.h
arch/powerpc/include/asm/termbits.h
arch/s390/include/asm/ioctls.h
arch/sh/include/asm/ioctls.h
arch/sparc/include/asm/ioctls.h
arch/sparc/include/asm/termbits.h
arch/xtensa/include/asm/ioctls.h
arch/xtensa/include/asm/termbits.h
drivers/char/n_tty.c
drivers/char/pty.c
drivers/char/tty_ioctl.c
fs/compat_ioctl.c
include/asm-generic/ioctls.h
include/asm-generic/termbits.h
include/linux/tty.h

index c7b0cc61ce5b00c32bf87b6942ba5e1b474c9339..59617c3c2be6a865d40dd64dcf9ae222c3c80389 100644 (file)
@@ -80,6 +80,7 @@
 # define TIOCPKT_START          8
 # define TIOCPKT_NOSTOP                16
 # define TIOCPKT_DOSTOP                32
+# define TIOCPKT_IOCTL         64
 
 
 #define TIOCNOTTY      0x5422
@@ -91,6 +92,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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCSERCONFIG  0x5453
 #define TIOCSERGWILD   0x5454
index ad854a4a3af63061290bd0fa02a0a58dc8f16bac..879dd35899218b850e154f64c4477375ca804432 100644 (file)
@@ -180,6 +180,7 @@ struct ktermios {
 #define FLUSHO 0x00800000
 #define PENDIN 0x20000000
 #define IEXTEN 0x00000400
+#define EXTPROC        0x10000000
 
 /* Values for the ACTION argument to `tcflow'.  */
 #define        TCOOFF          0
index 7f0b6d13296a4789f0e7f55faaf59c8fb3435914..0b30894b5482a3955917d7bbc52170e876af13ad 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCGRS485      0x542E
 #define TIOCSRS485      0x542F
@@ -81,6 +82,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT   0x01    /* Transmitter physically empty */
 
index f784d11f40b5e630f50bf573c8139d16e0cf473d..704135d28d1d3a90d7d5bf32a0744bdf0c3383d9 100644 (file)
@@ -177,6 +177,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index 143dafb3997ef3afb5214b410f06bfa2c8cf7074..b7dd324b46a92d720f94c2713c7798c8364f09df 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCGRS485      0x542E
 #define TIOCSRS485      0x542F
@@ -82,6 +83,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index db2daab31fdb55d961cb2803dd90a740e55c0e97..366adc5ebb100db9924f584568327db7ab70672c 100644 (file)
@@ -175,6 +175,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index bb49142dc6abaf30b880dc3ec9da55aefdc69afc..c9129ed374430c5e7e497935cae36ca9df430a57 100644 (file)
@@ -54,6 +54,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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -85,6 +86,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index 66e1a7492a0c7aeeac549aaedaefb48e884e68a7..1c43bc874ccf2202e41800da881377f4d5b43078 100644 (file)
@@ -214,6 +214,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index d0c30e31fbda02d4898110e207af32298384eb2f..a993e3759ccf2bf926c1954c995ff462a55bfad1 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -79,6 +80,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index 5568492b50860ba04c98e247ee18535f7f8d50be..7722e19cc349b2058ac02eb065df8e8a476a61d4 100644 (file)
@@ -180,6 +180,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 
 /* tcflow() and TCXONC use these */
index 98a53d067269f60cf96e5629149da0bc9a80b910..b6b249f9f308baca0e898eda42e305f34d2ac35d 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -79,6 +80,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index 31eca81db3f711d6ee2d61407981004d77030a9d..3287a6244d74c4c5fc0644e8d57c55b961f2e07a 100644 (file)
@@ -179,6 +179,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 
 /* tcflow() and TCXONC use these */
index f0ee86c0b5f77331212a0f0569958f9beed643e7..b79c385114ef89ec7430827cc65ece50d67b0530 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -85,6 +86,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index 9f162e0089ade2f66abf0d78cfe5456e0b6d3805..c009b94e58d913b17f00325647f31e0a27fdd0bc 100644 (file)
@@ -187,6 +187,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index f4c13a52fe48683792ea69d8cf50b46d41f28c50..66288063a4c0ef8bd1b2ac08e6630c842d88433e 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450
 #define FIOCLEX                0x5451
@@ -79,6 +80,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index bc104008b55b533af1f273dd7750279753566bd7..957a3c688549f48c1981dba0d0364bc0e6471513 100644 (file)
@@ -179,6 +179,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index b8d2f4be7fd74d97b8dcf3f38aefd02b440a921b..91a57d6654601df7863941d0d5bb030fe1f344ca 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -78,6 +79,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index 8c14170996bb743da077b9dee455de66c6ad38b6..aea1e37b765a217981ca7a13b809061669698ebb 100644 (file)
@@ -179,6 +179,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 
 /* tcflow() and TCXONC use these */
index 2fb9e1693bf7edbabbd69d40cee972118c8ef5df..d87cb0465693ab03dc9a11bd2b1bda0a3df9c26f 100644 (file)
@@ -41,7 +41,7 @@
 #define         TIOCPKT_START          0x08    /* start output */
 #define         TIOCPKT_NOSTOP         0x10    /* no more ^S, ^Q */
 #define         TIOCPKT_DOSTOP         0x20    /* now do ^S ^Q */
-/* #define  TIOCPKT_IOCTL              0x40    state change of pty driver */
+#define  TIOCPKT_IOCTL         0x40    /* state change of pty driver */
 #define TIOCSWINSZ     _IOW('t', 103, struct winsize)  /* set window size */
 #define TIOCGWINSZ     _IOR('t', 104, struct winsize)  /* get window size */
 #define TIOCNOTTY      0x5471          /* void tty association */
@@ -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 TIOCSIG                _IOW('T', 0x36, int)  /* Generate signal on Pty slave */
 
 /* I hope the range from 0x5480 on is free ... */
 #define TIOCSCTTY      0x5480          /* become controlling tty */
index c83c68444e866c835af86a5f135ba1e238b9dfb8..76630b396fac3b2545fd9260b0addad0b04bd069 100644 (file)
@@ -203,6 +203,7 @@ struct ktermios {
 #define PENDIN 0040000         /* Retype pending input (state).  */
 #define TOSTOP 0100000         /* Send SIGTTOU for background output.  */
 #define ITOSTOP        TOSTOP
+#define EXTPROC        0200000         /* External processing on pty */
 
 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
index 638219a99b1e0cbab3af5c0a17813da29c54d821..cb8cf19022347892c7a3bb49c8a718ed1ad03531 100644 (file)
@@ -54,6 +54,7 @@
 #define TIOCGPTN       _IOR('T', 0x30, unsigned int) /* Get Pty Number
                                                       * (of pty-mux device) */
 #define TIOCSPTLCK     _IOW('T', 0x31, int)  /* Lock/unlock Pty */
+#define TIOCSIG                _IOW('T', 0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450
 #define FIOCLEX                0x5451
@@ -80,6 +81,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index eb2b0dc1f696fb7c5e4fe5e823c3924a452eb54c..130d42495972d3f31cb8e7b473c18313f3329cca 100644 (file)
@@ -180,6 +180,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index 6cc497e52532039a10dced5f4c825f9cc8944c0b..4e0614456bea47ecbaf26c7f0b537792b6d12b2c 100644 (file)
@@ -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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -82,6 +83,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index d8bbc73b16b7f6915e85b8108d31e5b3199d9ca2..d1ab92177a5c130212ff11b89027a229d766ccd8 100644 (file)
@@ -180,6 +180,7 @@ struct ktermios {
 #define FLUSHO  0010000
 #define PENDIN  0040000
 #define IEXTEN  0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index 1842186d872c33818d862cff49ecc882dd7347cb..851920052e087490a3b32175465f3d63ae00b757 100644 (file)
@@ -80,6 +80,7 @@
 # define TIOCPKT_START          8
 # define TIOCPKT_NOSTOP                16
 # define TIOCPKT_DOSTOP                32
+# define TIOCPKT_IOCTL         64
 
 
 #define TIOCNOTTY      0x5422
@@ -93,6 +94,7 @@
 #define TIOCSRS485     0x542f
 #define TIOCGPTN       _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TIOCSPTLCK     _IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCSERCONFIG  0x5453
 #define TIOCSERGWILD   0x5454
index 6698188ca550aabc84ecadb7b0e7019be336734d..549d700e18f24c3e1bba536902958ab609e922bc 100644 (file)
@@ -189,6 +189,7 @@ struct ktermios {
 #define FLUSHO 0x00800000
 #define PENDIN 0x20000000
 #define IEXTEN 0x00000400
+#define EXTPROC        0x10000000
 
 /* Values for the ACTION argument to `tcflow'.  */
 #define        TCOOFF          0
index 40e481b1b4613777e19a555a2814597ac7a6f7b8..2f3d8736361f0d88293ff0c65b7a9862baf4b32d 100644 (file)
@@ -60,6 +60,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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX                0x5451
@@ -86,6 +87,7 @@
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT    0x01   /* Transmitter physically empty */
 
index c212c371a4a5702634c16eee6c67483231581561..eb6c4c68797224cf365caeaf761faeacc76b6b14 100644 (file)
@@ -69,6 +69,7 @@
 # define TIOCPKT_START          8
 # define TIOCPKT_NOSTOP                16
 # define TIOCPKT_DOSTOP                32
+# define TIOCPKT_IOCTL         64
 
 
 #define TIOCNOTTY      _IO('T', 34) /* 0x5422 */
@@ -84,6 +85,7 @@
 #define TCSETSF2       _IOW('T', 45, 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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCSERCONFIG  _IO('T', 83) /* 0x5453 */
 #define TIOCSERGWILD   _IOR('T', 84,  int) /* 0x5454 */
index 1fe6855c5c1896dccae71b86d359db3dd826e5be..53f4ee009bdda24e03e732524b7a16e93fd784bd 100644 (file)
@@ -80,6 +80,7 @@
 /* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */
 #define TIOCGPTN       _IOR('t', 134, unsigned int) /* Get Pty Number */
 #define TIOCSPTLCK     _IOW('t', 135, int) /* Lock/unlock PTY */
+#define TIOCSIG                _IOW('t', 136, int) /* Generate signal on Pty slave */
 
 /* Little f */
 #define FIOCLEX                _IO('f', 1)
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #endif /* !(_ASM_SPARC_IOCTLS_H) */
index d72dfed1f9d7e6fc67106f2a17aeeba8d8662d0a..23b10ff08df2c0196b4fe1d9717faff30ddbb0d5 100644 (file)
@@ -225,6 +225,7 @@ struct ktermios {
 #define FLUSHO 0x00002000
 #define PENDIN 0x00004000
 #define IEXTEN 0x00008000
+#define EXTPROC        0x00010000
 
 /* modem lines */
 #define TIOCM_LE       0x001
index 0ffa942954b9ba445000e8d063f3e38f572ab738..ab1800012ed9090b3b4902af53d74d25f2f639b6 100644 (file)
@@ -81,6 +81,7 @@
 # define TIOCPKT_START          8
 # define TIOCPKT_NOSTOP                16
 # define TIOCPKT_DOSTOP                32
+# define TIOCPKT_IOCTL         64
 
 
 #define TIOCNOTTY      _IO('T', 34)
@@ -97,6 +98,7 @@
 #define TCSETSF2       _IOW('T', 45, 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 TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty slave */
 
 #define TIOCSERCONFIG  _IO('T', 83)
 #define TIOCSERGWILD   _IOR('T', 84,  int)
index 85aa6a3c0b6e677ca3e7c70a9374568897c28acd..0d6c8715b24f7fc4683fa5e5b0d9d3156dd8a897 100644 (file)
@@ -196,6 +196,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 
index bdae8327143c3400497829c6080817535af52eb2..428f4fe0b5f745f81ee0e076b2e20d3717115b99 100644 (file)
@@ -1102,6 +1102,11 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
        if (I_IUCLC(tty) && L_IEXTEN(tty))
                c = tolower(c);
 
+       if (L_EXTPROC(tty)) {
+               put_tty_queue(c, tty);
+               return;
+       }
+
        if (tty->stopped && !tty->flow_stopped && I_IXON(tty) &&
            I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty) &&
            c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && c != SUSP_CHAR(tty)) {
@@ -1409,7 +1414,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 
        n_tty_set_room(tty);
 
-       if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) {
+       if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||
+               L_EXTPROC(tty)) {
                kill_fasync(&tty->fasync, SIGIO, POLL_IN);
                if (waitqueue_active(&tty->read_wait))
                        wake_up_interruptible(&tty->read_wait);
@@ -1585,7 +1591,7 @@ static int n_tty_open(struct tty_struct *tty)
 static inline int input_available_p(struct tty_struct *tty, int amt)
 {
        tty_flush_to_ldisc(tty);
-       if (tty->icanon) {
+       if (tty->icanon && !L_EXTPROC(tty)) {
                if (tty->canon_data)
                        return 1;
        } else if (tty->read_cnt >= (amt ? amt : 1))
@@ -1632,6 +1638,11 @@ static int copy_from_read_buf(struct tty_struct *tty,
                spin_lock_irqsave(&tty->read_lock, flags);
                tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1);
                tty->read_cnt -= n;
+               /* Turn single EOF into zero-length read */
+               if (L_EXTPROC(tty) && tty->icanon && n == 1) {
+                       if (!tty->read_cnt && (*b)[n-1] == EOF_CHAR(tty))
+                               n--;
+               }
                spin_unlock_irqrestore(&tty->read_lock, flags);
                *b += n;
                *nr -= n;
@@ -1812,7 +1823,7 @@ do_it_again:
                        nr--;
                }
 
-               if (tty->icanon) {
+               if (tty->icanon && !L_EXTPROC(tty)) {
                        /* N.B. avoid overrun if nr == 0 */
                        while (nr && tty->read_cnt) {
                                int eol;
index d83a43130df433962d7b0764ef6fc9c59f781f81..b640ef29be1c8334883a23f1aa138312064994ad 100644 (file)
@@ -171,6 +171,23 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg)
        return 0;
 }
 
+/* Send a signal to the slave */
+static int pty_signal(struct tty_struct *tty, int sig)
+{
+       unsigned long flags;
+       struct pid *pgrp;
+
+       if (tty->link) {
+               spin_lock_irqsave(&tty->link->ctrl_lock, flags);
+               pgrp = get_pid(tty->link->pgrp);
+               spin_unlock_irqrestore(&tty->link->ctrl_lock, flags);
+
+               kill_pgrp(pgrp, sig, 1);
+               put_pid(pgrp);
+       }
+       return 0;
+}
+
 static void pty_flush_buffer(struct tty_struct *tty)
 {
        struct tty_struct *to = tty->link;
@@ -321,6 +338,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
        switch (cmd) {
        case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
                return pty_set_lock(tty, (int __user *) arg);
+       case TIOCSIG:    /* Send signal to other side of pty */
+               return pty_signal(tty, (int) arg);
        }
        return -ENOIOCTLCMD;
 }
@@ -476,6 +495,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
                return pty_set_lock(tty, (int __user *)arg);
        case TIOCGPTN: /* Get PT Number */
                return put_user(tty->index, (unsigned int __user *)arg);
+       case TIOCSIG:    /* Send signal to other side of pty */
+               return pty_signal(tty, (int) arg);
        }
 
        return -ENOIOCTLCMD;
index 6bd5f8866c74b2ed85526a7ffe6465b370d7ce4c..0c18899714593325fa4e51f3235ad5a23e9ed0c4 100644 (file)
@@ -517,19 +517,25 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
 
        /* See if packet mode change of state. */
        if (tty->link && tty->link->packet) {
+               int extproc = (old_termios.c_lflag & EXTPROC) |
+                               (tty->termios->c_lflag & EXTPROC);
                int old_flow = ((old_termios.c_iflag & IXON) &&
                                (old_termios.c_cc[VSTOP] == '\023') &&
                                (old_termios.c_cc[VSTART] == '\021'));
                int new_flow = (I_IXON(tty) &&
                                STOP_CHAR(tty) == '\023' &&
                                START_CHAR(tty) == '\021');
-               if (old_flow != new_flow) {
+               if ((old_flow != new_flow) || extproc) {
                        spin_lock_irqsave(&tty->ctrl_lock, flags);
-                       tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
-                       if (new_flow)
-                               tty->ctrl_status |= TIOCPKT_DOSTOP;
-                       else
-                               tty->ctrl_status |= TIOCPKT_NOSTOP;
+                       if (old_flow != new_flow) {
+                               tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
+                               if (new_flow)
+                                       tty->ctrl_status |= TIOCPKT_DOSTOP;
+                               else
+                                       tty->ctrl_status |= TIOCPKT_NOSTOP;
+                       }
+                       if (extproc)
+                               tty->ctrl_status |= TIOCPKT_IOCTL;
                        spin_unlock_irqrestore(&tty->ctrl_lock, flags);
                        wake_up_interruptible(&tty->link->read_wait);
                }
index 63ae85831464a7741d89f7160e3cd93512332a4a..fa4bc48810fda8519f8fb3536ed48a965f35db99 100644 (file)
@@ -969,6 +969,7 @@ COMPATIBLE_IOCTL(TIOCGPGRP)
 COMPATIBLE_IOCTL(TIOCGPTN)
 COMPATIBLE_IOCTL(TIOCSPTLCK)
 COMPATIBLE_IOCTL(TIOCSERGETLSR)
+COMPATIBLE_IOCTL(TIOCSIG)
 #ifdef TCGETS2
 COMPATIBLE_IOCTL(TCGETS2)
 COMPATIBLE_IOCTL(TCSETS2)
index 1375fa1a7a4db0232bbdc1fa2cca5951162425df..8554cb6a81b9b6f3e063d204d6da830f6ed0038a 100644 (file)
@@ -69,6 +69,7 @@
 #define TCSETX         0x5433
 #define TCSETXF                0x5434
 #define TCSETXW                0x5435
+#define TIOCSIG                _IOW('T', 0x36, int)  /* pty: generate signal */
 
 #define FIONCLEX       0x5450
 #define FIOCLEX                0x5451
 #define TIOCPKT_START           8
 #define TIOCPKT_NOSTOP         16
 #define TIOCPKT_DOSTOP         32
+#define TIOCPKT_IOCTL          64
 
 #define TIOCSER_TEMT   0x01    /* Transmitter physically empty */
 
index 1c9773d48cb021389ca3d2fbf8cc6dbb5f9d90ba..232b4781aef311f6eaf1885f0de5768a8517584e 100644 (file)
@@ -178,6 +178,7 @@ struct ktermios {
 #define FLUSHO 0010000
 #define PENDIN 0040000
 #define IEXTEN 0100000
+#define EXTPROC        0200000
 
 /* tcflow() and TCXONC use these */
 #define        TCOOFF          0
index 7802a243ee1372dfff07f1dd6c2b294abeddfb9c..2df60e4ff40e038dfad3f2dd8637542eba784aff 100644 (file)
@@ -179,6 +179,7 @@ struct tty_bufhead {
 #define L_FLUSHO(tty)  _L_FLAG((tty), FLUSHO)
 #define L_PENDIN(tty)  _L_FLAG((tty), PENDIN)
 #define L_IEXTEN(tty)  _L_FLAG((tty), IEXTEN)
+#define L_EXTPROC(tty) _L_FLAG((tty), EXTPROC)
 
 struct device;
 struct signal_struct;