diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-08-27 22:17:07 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-08-27 22:17:07 -0400 |
commit | b30a72a7edfc64c8929104d5c2178aca489aa559 (patch) | |
tree | 2b26c155c318d08d946bd2d70cf815dcdb29a243 /drivers/char/vt.c | |
parent | f1c5d30e1d79bbfb60eaf189db862d3cb2bcac92 (diff) | |
parent | c1b362e3b4d331a63915b268a33207311a439d60 (diff) |
Merge branch 'x86/urgent' into x86/cpu
Conflicts:
arch/x86/kernel/cpu/cyrix.c
Diffstat (limited to 'drivers/char/vt.c')
-rw-r--r-- | drivers/char/vt.c | 82 |
1 files changed, 62 insertions, 20 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 1bc00c9d860d..60359c360912 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -803,7 +803,25 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, | |||
803 | */ | 803 | */ |
804 | #define VC_RESIZE_MAXCOL (32767) | 804 | #define VC_RESIZE_MAXCOL (32767) |
805 | #define VC_RESIZE_MAXROW (32767) | 805 | #define VC_RESIZE_MAXROW (32767) |
806 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | 806 | |
807 | /** | ||
808 | * vc_do_resize - resizing method for the tty | ||
809 | * @tty: tty being resized | ||
810 | * @real_tty: real tty (different to tty if a pty/tty pair) | ||
811 | * @vc: virtual console private data | ||
812 | * @cols: columns | ||
813 | * @lines: lines | ||
814 | * | ||
815 | * Resize a virtual console, clipping according to the actual constraints. | ||
816 | * If the caller passes a tty structure then update the termios winsize | ||
817 | * information and perform any neccessary signal handling. | ||
818 | * | ||
819 | * Caller must hold the console semaphore. Takes the termios mutex and | ||
820 | * ctrl_lock of the tty IFF a tty is passed. | ||
821 | */ | ||
822 | |||
823 | static int vc_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | ||
824 | struct vc_data *vc, unsigned int cols, unsigned int lines) | ||
807 | { | 825 | { |
808 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; | 826 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; |
809 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; | 827 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; |
@@ -907,24 +925,15 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
907 | gotoxy(vc, vc->vc_x, vc->vc_y); | 925 | gotoxy(vc, vc->vc_x, vc->vc_y); |
908 | save_cur(vc); | 926 | save_cur(vc); |
909 | 927 | ||
910 | if (vc->vc_tty) { | 928 | if (tty) { |
911 | struct winsize ws, *cws = &vc->vc_tty->winsize; | 929 | /* Rewrite the requested winsize data with the actual |
912 | struct pid *pgrp = NULL; | 930 | resulting sizes */ |
913 | 931 | struct winsize ws; | |
914 | memset(&ws, 0, sizeof(ws)); | 932 | memset(&ws, 0, sizeof(ws)); |
915 | ws.ws_row = vc->vc_rows; | 933 | ws.ws_row = vc->vc_rows; |
916 | ws.ws_col = vc->vc_cols; | 934 | ws.ws_col = vc->vc_cols; |
917 | ws.ws_ypixel = vc->vc_scan_lines; | 935 | ws.ws_ypixel = vc->vc_scan_lines; |
918 | 936 | tty_do_resize(tty, real_tty, &ws); | |
919 | spin_lock_irq(&vc->vc_tty->ctrl_lock); | ||
920 | if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col)) | ||
921 | pgrp = get_pid(vc->vc_tty->pgrp); | ||
922 | spin_unlock_irq(&vc->vc_tty->ctrl_lock); | ||
923 | if (pgrp) { | ||
924 | kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1); | ||
925 | put_pid(pgrp); | ||
926 | } | ||
927 | *cws = ws; | ||
928 | } | 937 | } |
929 | 938 | ||
930 | if (CON_IS_VISIBLE(vc)) | 939 | if (CON_IS_VISIBLE(vc)) |
@@ -932,14 +941,47 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
932 | return err; | 941 | return err; |
933 | } | 942 | } |
934 | 943 | ||
935 | int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | 944 | /** |
945 | * vc_resize - resize a VT | ||
946 | * @vc: virtual console | ||
947 | * @cols: columns | ||
948 | * @rows: rows | ||
949 | * | ||
950 | * Resize a virtual console as seen from the console end of things. We | ||
951 | * use the common vc_do_resize methods to update the structures. The | ||
952 | * caller must hold the console sem to protect console internals and | ||
953 | * vc->vc_tty | ||
954 | */ | ||
955 | |||
956 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) | ||
957 | { | ||
958 | return vc_do_resize(vc->vc_tty, vc->vc_tty, vc, cols, rows); | ||
959 | } | ||
960 | |||
961 | /** | ||
962 | * vt_resize - resize a VT | ||
963 | * @tty: tty to resize | ||
964 | * @real_tty: tty if a pty/tty pair | ||
965 | * @ws: winsize attributes | ||
966 | * | ||
967 | * Resize a virtual terminal. This is called by the tty layer as we | ||
968 | * register our own handler for resizing. The mutual helper does all | ||
969 | * the actual work. | ||
970 | * | ||
971 | * Takes the console sem and the called methods then take the tty | ||
972 | * termios_mutex and the tty ctrl_lock in that order. | ||
973 | */ | ||
974 | |||
975 | int vt_resize(struct tty_struct *tty, struct tty_struct *real_tty, | ||
976 | struct winsize *ws) | ||
936 | { | 977 | { |
937 | int rc; | 978 | struct vc_data *vc = tty->driver_data; |
979 | int ret; | ||
938 | 980 | ||
939 | acquire_console_sem(); | 981 | acquire_console_sem(); |
940 | rc = vc_resize(vc, cols, lines); | 982 | ret = vc_do_resize(tty, real_tty, vc, ws->ws_col, ws->ws_row); |
941 | release_console_sem(); | 983 | release_console_sem(); |
942 | return rc; | 984 | return ret; |
943 | } | 985 | } |
944 | 986 | ||
945 | void vc_deallocate(unsigned int currcons) | 987 | void vc_deallocate(unsigned int currcons) |
@@ -2907,6 +2949,7 @@ static const struct tty_operations con_ops = { | |||
2907 | .start = con_start, | 2949 | .start = con_start, |
2908 | .throttle = con_throttle, | 2950 | .throttle = con_throttle, |
2909 | .unthrottle = con_unthrottle, | 2951 | .unthrottle = con_unthrottle, |
2952 | .resize = vt_resize, | ||
2910 | }; | 2953 | }; |
2911 | 2954 | ||
2912 | int __init vty_init(void) | 2955 | int __init vty_init(void) |
@@ -4061,7 +4104,6 @@ EXPORT_SYMBOL(default_blu); | |||
4061 | EXPORT_SYMBOL(update_region); | 4104 | EXPORT_SYMBOL(update_region); |
4062 | EXPORT_SYMBOL(redraw_screen); | 4105 | EXPORT_SYMBOL(redraw_screen); |
4063 | EXPORT_SYMBOL(vc_resize); | 4106 | EXPORT_SYMBOL(vc_resize); |
4064 | EXPORT_SYMBOL(vc_lock_resize); | ||
4065 | EXPORT_SYMBOL(fg_console); | 4107 | EXPORT_SYMBOL(fg_console); |
4066 | EXPORT_SYMBOL(console_blank_hook); | 4108 | EXPORT_SYMBOL(console_blank_hook); |
4067 | EXPORT_SYMBOL(console_blanked); | 4109 | EXPORT_SYMBOL(console_blanked); |