Skip to content

Commit

Permalink
tty: Add EXTPROC support for LINEMODE
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hyc authored and gregkh committed Aug 10, 2010
1 parent a3c8ed6 commit 26df6d1
Show file tree
Hide file tree
Showing 39 changed files with 101 additions and 10 deletions.
2 changes: 2 additions & 0 deletions arch/alpha/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
# define TIOCPKT_START 8
# define TIOCPKT_NOSTOP 16
# define TIOCPKT_DOSTOP 32
# define TIOCPKT_IOCTL 64


#define TIOCNOTTY 0x5422
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions arch/alpha/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/arm/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/avr32/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/avr32/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/cris/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/cris/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/frv/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/frv/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct ktermios {
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#define EXTPROC 0200000


/* tcflow() and TCXONC use these */
Expand Down
2 changes: 2 additions & 0 deletions arch/h8300/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/h8300/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct ktermios {
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#define EXTPROC 0200000


/* tcflow() and TCXONC use these */
Expand Down
2 changes: 2 additions & 0 deletions arch/ia64/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/ia64/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/m32r/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/m32r/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/m68k/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/m68k/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct ktermios {
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#define EXTPROC 0200000


/* tcflow() and TCXONC use these */
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions arch/mips/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions arch/mn10300/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/mn10300/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/parisc/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions arch/parisc/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/powerpc/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
# define TIOCPKT_START 8
# define TIOCPKT_NOSTOP 16
# define TIOCPKT_DOSTOP 32
# define TIOCPKT_IOCTL 64


#define TIOCNOTTY 0x5422
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/s390/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand Down
2 changes: 2 additions & 0 deletions arch/sh/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions arch/sparc/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -132,5 +133,6 @@
#define TIOCPKT_START 8
#define TIOCPKT_NOSTOP 16
#define TIOCPKT_DOSTOP 32
#define TIOCPKT_IOCTL 64

#endif /* !(_ASM_SPARC_IOCTLS_H) */
1 change: 1 addition & 0 deletions arch/sparc/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ struct ktermios {
#define FLUSHO 0x00002000
#define PENDIN 0x00004000
#define IEXTEN 0x00008000
#define EXTPROC 0x00010000

/* modem lines */
#define TIOCM_LE 0x001
Expand Down
2 changes: 2 additions & 0 deletions arch/xtensa/include/asm/ioctls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions arch/xtensa/include/asm/termbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ struct ktermios {
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#define EXTPROC 0200000

/* tcflow() and TCXONC use these */

Expand Down
Loading

0 comments on commit 26df6d1

Please sign in to comment.