diff options
author | Alan Cox <alan@redhat.com> | 2008-08-15 05:39:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-15 13:34:07 -0400 |
commit | 8c9a9dd0fa3a269d380eaae2dc1bee39e865fae1 (patch) | |
tree | c4617de83246eb6b7ed9c125c5777f05b445c975 /drivers/char/tty_io.c | |
parent | 21d3bdb1606311a2900eabccfcb5a887952e2c44 (diff) |
tty: remove resize window special case
This moves it to being a tty operation. That removes special cases and now
also means that resize can be picked up by um and other non vt consoles
which may have a resize operation.
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 | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 0e6866fe0f96..a27160ba21d7 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2496,45 +2496,25 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2496 | } | 2496 | } |
2497 | 2497 | ||
2498 | /** | 2498 | /** |
2499 | * tiocswinsz - implement window size set ioctl | 2499 | * tty_do_resize - resize event |
2500 | * @tty; tty | 2500 | * @tty: tty being resized |
2501 | * @arg: user buffer for result | 2501 | * @real_tty: real tty (if using a pty/tty pair) |
2502 | * @rows: rows (character) | ||
2503 | * @cols: cols (character) | ||
2502 | * | 2504 | * |
2503 | * Copies the user idea of the window size to the kernel. Traditionally | 2505 | * Update the termios variables and send the neccessary signals to |
2504 | * this is just advisory information but for the Linux console it | 2506 | * peform a terminal resize correctly |
2505 | * actually has driver level meaning and triggers a VC resize. | ||
2506 | * | ||
2507 | * Locking: | ||
2508 | * Called function use the console_sem is used to ensure we do | ||
2509 | * not try and resize the console twice at once. | ||
2510 | * The tty->termios_mutex is used to ensure we don't double | ||
2511 | * resize and get confused. Lock order - tty->termios_mutex before | ||
2512 | * console sem | ||
2513 | */ | 2507 | */ |
2514 | 2508 | ||
2515 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | 2509 | int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, |
2516 | struct winsize __user *arg) | 2510 | struct winsize *ws) |
2517 | { | 2511 | { |
2518 | struct winsize tmp_ws; | ||
2519 | struct pid *pgrp, *rpgrp; | 2512 | struct pid *pgrp, *rpgrp; |
2520 | unsigned long flags; | 2513 | unsigned long flags; |
2521 | 2514 | ||
2522 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | ||
2523 | return -EFAULT; | ||
2524 | |||
2525 | mutex_lock(&tty->termios_mutex); | 2515 | mutex_lock(&tty->termios_mutex); |
2526 | if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg))) | 2516 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) |
2527 | goto done; | 2517 | goto done; |
2528 | |||
2529 | #ifdef CONFIG_VT | ||
2530 | if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) { | ||
2531 | if (vc_lock_resize(tty->driver_data, tmp_ws.ws_col, | ||
2532 | tmp_ws.ws_row)) { | ||
2533 | mutex_unlock(&tty->termios_mutex); | ||
2534 | return -ENXIO; | ||
2535 | } | ||
2536 | } | ||
2537 | #endif | ||
2538 | /* Get the PID values and reference them so we can | 2518 | /* Get the PID values and reference them so we can |
2539 | avoid holding the tty ctrl lock while sending signals */ | 2519 | avoid holding the tty ctrl lock while sending signals */ |
2540 | spin_lock_irqsave(&tty->ctrl_lock, flags); | 2520 | spin_lock_irqsave(&tty->ctrl_lock, flags); |
@@ -2550,14 +2530,42 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2550 | put_pid(pgrp); | 2530 | put_pid(pgrp); |
2551 | put_pid(rpgrp); | 2531 | put_pid(rpgrp); |
2552 | 2532 | ||
2553 | tty->winsize = tmp_ws; | 2533 | tty->winsize = *ws; |
2554 | real_tty->winsize = tmp_ws; | 2534 | real_tty->winsize = *ws; |
2555 | done: | 2535 | done: |
2556 | mutex_unlock(&tty->termios_mutex); | 2536 | mutex_unlock(&tty->termios_mutex); |
2557 | return 0; | 2537 | return 0; |
2558 | } | 2538 | } |
2559 | 2539 | ||
2560 | /** | 2540 | /** |
2541 | * tiocswinsz - implement window size set ioctl | ||
2542 | * @tty; tty | ||
2543 | * @arg: user buffer for result | ||
2544 | * | ||
2545 | * Copies the user idea of the window size to the kernel. Traditionally | ||
2546 | * this is just advisory information but for the Linux console it | ||
2547 | * actually has driver level meaning and triggers a VC resize. | ||
2548 | * | ||
2549 | * Locking: | ||
2550 | * Driver dependant. The default do_resize method takes the | ||
2551 | * tty termios mutex and ctrl_lock. The console takes its own lock | ||
2552 | * then calls into the default method. | ||
2553 | */ | ||
2554 | |||
2555 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | ||
2556 | struct winsize __user *arg) | ||
2557 | { | ||
2558 | struct winsize tmp_ws; | ||
2559 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | ||
2560 | return -EFAULT; | ||
2561 | |||
2562 | if (tty->ops->resize) | ||
2563 | return tty->ops->resize(tty, real_tty, &tmp_ws); | ||
2564 | else | ||
2565 | return tty_do_resize(tty, real_tty, &tmp_ws); | ||
2566 | } | ||
2567 | |||
2568 | /** | ||
2561 | * tioccons - allow admin to move logical console | 2569 | * tioccons - allow admin to move logical console |
2562 | * @file: the file to become console | 2570 | * @file: the file to become console |
2563 | * | 2571 | * |