aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 6c817398232..be49d0730bb 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2481,6 +2481,24 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int
2481 return tty->ops->tiocmset(tty, file, set, clear); 2481 return tty->ops->tiocmset(tty, file, set, clear);
2482} 2482}
2483 2483
2484struct tty_struct *tty_pair_get_tty(struct tty_struct *tty)
2485{
2486 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2487 tty->driver->subtype == PTY_TYPE_MASTER)
2488 tty = tty->link;
2489 return tty;
2490}
2491EXPORT_SYMBOL(tty_pair_get_tty);
2492
2493struct tty_struct *tty_pair_get_pty(struct tty_struct *tty)
2494{
2495 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2496 tty->driver->subtype == PTY_TYPE_MASTER)
2497 return tty;
2498 return tty->link;
2499}
2500EXPORT_SYMBOL(tty_pair_get_pty);
2501
2484/* 2502/*
2485 * Split this up, as gcc can choke on it otherwise.. 2503 * Split this up, as gcc can choke on it otherwise..
2486 */ 2504 */
@@ -2496,11 +2514,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2496 if (tty_paranoia_check(tty, inode, "tty_ioctl")) 2514 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
2497 return -EINVAL; 2515 return -EINVAL;
2498 2516
2499 real_tty = tty; 2517 real_tty = tty_pair_get_tty(tty);
2500 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2501 tty->driver->subtype == PTY_TYPE_MASTER)
2502 real_tty = tty->link;
2503
2504 2518
2505 /* 2519 /*
2506 * Factor out some common prep work 2520 * Factor out some common prep work