diff options
author | Cyrill Gorcunov <gorcunov@openvz.org> | 2012-10-24 15:43:20 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-25 15:07:18 -0400 |
commit | 06026d911c31dfa602e14e635a3489b8d67cc786 (patch) | |
tree | 9e8ef5fcc3be08dc92ca955be8fd8ec8ddd18736 /drivers/tty/pty.c | |
parent | ab72fa5523866cb93681abb9f9a401d43a93b7be (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.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 4219f040adb8..df3c64272d21 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) | |||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | /* Set the packet mode on a pty */ | ||
175 | static int pty_set_pktmode(struct tty_struct *tty, int __user *arg) | ||
176 | { | ||
177 | unsigned long flags; | ||
178 | int pktmode; | ||
179 | |||
180 | if (get_user(pktmode, arg)) | ||
181 | return -EFAULT; | ||
182 | |||
183 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
184 | if (pktmode) { | ||
185 | if (!tty->packet) { | ||
186 | tty->packet = 1; | ||
187 | tty->link->ctrl_status = 0; | ||
188 | } | ||
189 | } else | ||
190 | tty->packet = 0; | ||
191 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
174 | /* Send a signal to the slave */ | 196 | /* Send a signal to the slave */ |
175 | static int pty_signal(struct tty_struct *tty, int sig) | 197 | static int pty_signal(struct tty_struct *tty, int sig) |
176 | { | 198 | { |
@@ -398,6 +420,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty, | |||
398 | switch (cmd) { | 420 | switch (cmd) { |
399 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ | 421 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ |
400 | return pty_set_lock(tty, (int __user *) arg); | 422 | return pty_set_lock(tty, (int __user *) arg); |
423 | case TIOCPKT: /* Set PT packet mode */ | ||
424 | return pty_set_pktmode(tty, (int __user *)arg); | ||
401 | case TIOCSIG: /* Send signal to other side of pty */ | 425 | case TIOCSIG: /* Send signal to other side of pty */ |
402 | return pty_signal(tty, (int) arg); | 426 | return pty_signal(tty, (int) arg); |
403 | } | 427 | } |
@@ -512,6 +536,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty, | |||
512 | switch (cmd) { | 536 | switch (cmd) { |
513 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ | 537 | case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ |
514 | return pty_set_lock(tty, (int __user *)arg); | 538 | return pty_set_lock(tty, (int __user *)arg); |
539 | case TIOCPKT: /* Set PT packet mode */ | ||
540 | return pty_set_pktmode(tty, (int __user *)arg); | ||
515 | case TIOCGPTN: /* Get PT Number */ | 541 | case TIOCGPTN: /* Get PT Number */ |
516 | return put_user(tty->index, (unsigned int __user *)arg); | 542 | return put_user(tty->index, (unsigned int __user *)arg); |
517 | case TIOCSIG: /* Send signal to other side of pty */ | 543 | case TIOCSIG: /* Send signal to other side of pty */ |