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 | |
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>
-rw-r--r-- | drivers/tty/pty.c | 26 | ||||
-rw-r--r-- | drivers/tty/tty_ioctl.c | 21 |
2 files changed, 26 insertions, 21 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 */ |
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 12b1fa0f4f86..8481b29d5b3a 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c | |||
@@ -1118,7 +1118,6 @@ EXPORT_SYMBOL_GPL(tty_perform_flush); | |||
1118 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | 1118 | int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, |
1119 | unsigned int cmd, unsigned long arg) | 1119 | unsigned int cmd, unsigned long arg) |
1120 | { | 1120 | { |
1121 | unsigned long flags; | ||
1122 | int retval; | 1121 | int retval; |
1123 | 1122 | ||
1124 | switch (cmd) { | 1123 | switch (cmd) { |
@@ -1153,26 +1152,6 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | |||
1153 | return 0; | 1152 | return 0; |
1154 | case TCFLSH: | 1153 | case TCFLSH: |
1155 | return tty_perform_flush(tty, arg); | 1154 | return tty_perform_flush(tty, arg); |
1156 | case TIOCPKT: | ||
1157 | { | ||
1158 | int pktmode; | ||
1159 | |||
1160 | if (tty->driver->type != TTY_DRIVER_TYPE_PTY || | ||
1161 | tty->driver->subtype != PTY_TYPE_MASTER) | ||
1162 | return -ENOTTY; | ||
1163 | if (get_user(pktmode, (int __user *) arg)) | ||
1164 | return -EFAULT; | ||
1165 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
1166 | if (pktmode) { | ||
1167 | if (!tty->packet) { | ||
1168 | tty->packet = 1; | ||
1169 | tty->link->ctrl_status = 0; | ||
1170 | } | ||
1171 | } else | ||
1172 | tty->packet = 0; | ||
1173 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
1174 | return 0; | ||
1175 | } | ||
1176 | default: | 1155 | default: |
1177 | /* Try the mode commands */ | 1156 | /* Try the mode commands */ |
1178 | return tty_mode_ioctl(tty, file, cmd, arg); | 1157 | return tty_mode_ioctl(tty, file, cmd, arg); |