summaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2012-10-24 23:43:20 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-25 12:07:18 -0700
commit06026d911c31dfa602e14e635a3489b8d67cc786 (patch)
tree9e8ef5fcc3be08dc92ca955be8fd8ec8ddd18736 /drivers/tty/pty.c
parentab72fa5523866cb93681abb9f9a401d43a93b7be (diff)
tty: pty - Move TIOCPKT handling into pty.c
Since this ioctl is for pty devices only move it to pty.c. v2: - drop PTY_TYPE_MASTER test since it's master peer ioctl anyway (by jslaby@) Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> CC: "H. Peter Anvin" <hpa@zytor.com> CC: Pavel Emelyanov <xemul@parallels.com> CC: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 4219f040adb..df3c64272d2 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -171,6 +171,28 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg)
return 0;
}
+/* Set the packet mode on a pty */
+static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
+{
+ unsigned long flags;
+ int pktmode;
+
+ if (get_user(pktmode, arg))
+ return -EFAULT;
+
+ spin_lock_irqsave(&tty->ctrl_lock, flags);
+ if (pktmode) {
+ if (!tty->packet) {
+ tty->packet = 1;
+ tty->link->ctrl_status = 0;
+ }
+ } else
+ tty->packet = 0;
+ spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+
+ return 0;
+}
+
/* Send a signal to the slave */
static int pty_signal(struct tty_struct *tty, int sig)
{
@@ -398,6 +420,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty,
switch (cmd) {
case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
return pty_set_lock(tty, (int __user *) arg);
+ case TIOCPKT: /* Set PT packet mode */
+ return pty_set_pktmode(tty, (int __user *)arg);
case TIOCSIG: /* Send signal to other side of pty */
return pty_signal(tty, (int) arg);
}
@@ -512,6 +536,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
switch (cmd) {
case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
return pty_set_lock(tty, (int __user *)arg);
+ case TIOCPKT: /* Set PT packet mode */
+ return pty_set_pktmode(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 */