diff options
author | hyc@symas.com <hyc@symas.com> | 2010-06-22 13:14:49 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:39 -0400 |
commit | 26df6d13406d1a53b0bda08bd712f1924affd7cd (patch) | |
tree | db17328acbd7cac9dc20bc854509527c1c89ca01 /drivers/char/pty.c | |
parent | a3c8ed693da9782f924223f65da9261da796e49b (diff) |
tty: Add EXTPROC support for LINEMODE
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>
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r-- | drivers/char/pty.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index d83a43130df4..b640ef29be1c 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
@@ -171,6 +171,23 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg) | |||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | /* Send a signal to the slave */ | ||
175 | static int pty_signal(struct tty_struct *tty, int sig) | ||
176 | { | ||
177 | unsigned long flags; | ||
178 | struct pid *pgrp; | ||
179 | |||
180 | if (tty->link) { | ||
181 | spin_lock_irqsave(&tty->link->ctrl_lock, flags); | ||
182 | pgrp = get_pid(tty->link->pgrp); | ||
183 | spin_unlock_irqrestore(&tty->link->ctrl_lock, flags); | ||
184 | |||
185 | kill_pgrp(pgrp, sig, 1); | ||
186 | put_pid(pgrp); | ||
187 | } | ||
188 | return 0; | ||
189 | } | ||
190 | |||
174 | static void pty_flush_buffer(struct tty_struct *tty) | 191 | static void pty_flush_buffer(struct tty_struct *tty) |
175 | { | 192 | { |
176 | struct tty_struct *to = tty->link; | 193 | struct tty_struct *to = tty->link; |
@@ -321,6 +338,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file, | |||
321 | switch (cmd) { | 338 | switch (cmd) { |
322 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ | 339 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ |
323 | return pty_set_lock(tty, (int __user *) arg); | 340 | return pty_set_lock(tty, (int __user *) arg); |
341 | case TIOCSIG: /* Send signal to other side of pty */ | ||
342 | return pty_signal(tty, (int) arg); | ||
324 | } | 343 | } |
325 | return -ENOIOCTLCMD; | 344 | return -ENOIOCTLCMD; |
326 | } | 345 | } |
@@ -476,6 +495,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file, | |||
476 | return pty_set_lock(tty, (int __user *)arg); | 495 | return pty_set_lock(tty, (int __user *)arg); |
477 | case TIOCGPTN: /* Get PT Number */ | 496 | case TIOCGPTN: /* Get PT Number */ |
478 | return put_user(tty->index, (unsigned int __user *)arg); | 497 | return put_user(tty->index, (unsigned int __user *)arg); |
498 | case TIOCSIG: /* Send signal to other side of pty */ | ||
499 | return pty_signal(tty, (int) arg); | ||
479 | } | 500 | } |
480 | 501 | ||
481 | return -ENOIOCTLCMD; | 502 | return -ENOIOCTLCMD; |