diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 08:43:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:36 -0500 |
commit | fc6f6238226e6d1248e1967eae2bf556eaf3ac17 (patch) | |
tree | 07cef0fafd30bd622dac1db4751e10734773c863 /drivers/char/tty_io.c | |
parent | a47d545f5782cbde871b50bdf4a83379ed2da222 (diff) |
pty: simplify resize
We have special case logic for resizing pty/tty pairs. We also have a per
driver resize method so for the pty case we should use it.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 2a15af65dd11..d33e5ab06177 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2048,7 +2048,6 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2048 | /** | 2048 | /** |
2049 | * tty_do_resize - resize event | 2049 | * tty_do_resize - resize event |
2050 | * @tty: tty being resized | 2050 | * @tty: tty being resized |
2051 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) | ||
2052 | * @rows: rows (character) | 2051 | * @rows: rows (character) |
2053 | * @cols: cols (character) | 2052 | * @cols: cols (character) |
2054 | * | 2053 | * |
@@ -2056,41 +2055,34 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2056 | * peform a terminal resize correctly | 2055 | * peform a terminal resize correctly |
2057 | */ | 2056 | */ |
2058 | 2057 | ||
2059 | int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | 2058 | int tty_do_resize(struct tty_struct *tty, struct winsize *ws) |
2060 | struct winsize *ws) | ||
2061 | { | 2059 | { |
2062 | struct pid *pgrp, *rpgrp; | 2060 | struct pid *pgrp; |
2063 | unsigned long flags; | 2061 | unsigned long flags; |
2064 | 2062 | ||
2065 | /* For a PTY we need to lock the tty side */ | 2063 | /* Lock the tty */ |
2066 | mutex_lock(&real_tty->termios_mutex); | 2064 | mutex_lock(&tty->termios_mutex); |
2067 | if (!memcmp(ws, &real_tty->winsize, sizeof(*ws))) | 2065 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) |
2068 | goto done; | 2066 | goto done; |
2069 | /* Get the PID values and reference them so we can | 2067 | /* Get the PID values and reference them so we can |
2070 | avoid holding the tty ctrl lock while sending signals */ | 2068 | avoid holding the tty ctrl lock while sending signals */ |
2071 | spin_lock_irqsave(&tty->ctrl_lock, flags); | 2069 | spin_lock_irqsave(&tty->ctrl_lock, flags); |
2072 | pgrp = get_pid(tty->pgrp); | 2070 | pgrp = get_pid(tty->pgrp); |
2073 | rpgrp = get_pid(real_tty->pgrp); | ||
2074 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 2071 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
2075 | 2072 | ||
2076 | if (pgrp) | 2073 | if (pgrp) |
2077 | kill_pgrp(pgrp, SIGWINCH, 1); | 2074 | kill_pgrp(pgrp, SIGWINCH, 1); |
2078 | if (rpgrp != pgrp && rpgrp) | ||
2079 | kill_pgrp(rpgrp, SIGWINCH, 1); | ||
2080 | |||
2081 | put_pid(pgrp); | 2075 | put_pid(pgrp); |
2082 | put_pid(rpgrp); | ||
2083 | 2076 | ||
2084 | tty->winsize = *ws; | 2077 | tty->winsize = *ws; |
2085 | real_tty->winsize = *ws; | ||
2086 | done: | 2078 | done: |
2087 | mutex_unlock(&real_tty->termios_mutex); | 2079 | mutex_unlock(&tty->termios_mutex); |
2088 | return 0; | 2080 | return 0; |
2089 | } | 2081 | } |
2090 | 2082 | ||
2091 | /** | 2083 | /** |
2092 | * tiocswinsz - implement window size set ioctl | 2084 | * tiocswinsz - implement window size set ioctl |
2093 | * @tty; tty | 2085 | * @tty; tty side of tty |
2094 | * @arg: user buffer for result | 2086 | * @arg: user buffer for result |
2095 | * | 2087 | * |
2096 | * Copies the user idea of the window size to the kernel. Traditionally | 2088 | * Copies the user idea of the window size to the kernel. Traditionally |
@@ -2103,17 +2095,16 @@ done: | |||
2103 | * then calls into the default method. | 2095 | * then calls into the default method. |
2104 | */ | 2096 | */ |
2105 | 2097 | ||
2106 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | 2098 | static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg) |
2107 | struct winsize __user *arg) | ||
2108 | { | 2099 | { |
2109 | struct winsize tmp_ws; | 2100 | struct winsize tmp_ws; |
2110 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | 2101 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) |
2111 | return -EFAULT; | 2102 | return -EFAULT; |
2112 | 2103 | ||
2113 | if (tty->ops->resize) | 2104 | if (tty->ops->resize) |
2114 | return tty->ops->resize(tty, real_tty, &tmp_ws); | 2105 | return tty->ops->resize(tty, &tmp_ws); |
2115 | else | 2106 | else |
2116 | return tty_do_resize(tty, real_tty, &tmp_ws); | 2107 | return tty_do_resize(tty, &tmp_ws); |
2117 | } | 2108 | } |
2118 | 2109 | ||
2119 | /** | 2110 | /** |
@@ -2538,7 +2529,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2538 | case TIOCGWINSZ: | 2529 | case TIOCGWINSZ: |
2539 | return tiocgwinsz(real_tty, p); | 2530 | return tiocgwinsz(real_tty, p); |
2540 | case TIOCSWINSZ: | 2531 | case TIOCSWINSZ: |
2541 | return tiocswinsz(tty, real_tty, p); | 2532 | return tiocswinsz(real_tty, p); |
2542 | case TIOCCONS: | 2533 | case TIOCCONS: |
2543 | return real_tty != tty ? -EINVAL : tioccons(file); | 2534 | return real_tty != tty ? -EINVAL : tioccons(file); |
2544 | case FIONBIO: | 2535 | case FIONBIO: |