Commit 5289475d1375017ab4288b276383e9684280876d
Committed by
Greg Kroah-Hartman
1 parent
99cceb4e50
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
vt: tackle the main part of the selection logic
We leave the existing paste mess alone and just fix up the vt side of things. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 2 changed files with 33 additions and 8 deletions Side-by-side Diff
drivers/tty/vt/selection.c
... | ... | @@ -62,10 +62,14 @@ |
62 | 62 | use_unicode); |
63 | 63 | } |
64 | 64 | |
65 | -/* remove the current selection highlight, if any, | |
66 | - from the console holding the selection. */ | |
67 | -void | |
68 | -clear_selection(void) { | |
65 | +/** | |
66 | + * clear_selection - remove current selection | |
67 | + * | |
68 | + * Remove the current selection highlight, if any from the console | |
69 | + * holding the selection. The caller must hold the console lock. | |
70 | + */ | |
71 | +void clear_selection(void) | |
72 | +{ | |
69 | 73 | highlight_pointer(-1); /* hide the pointer */ |
70 | 74 | if (sel_start != -1) { |
71 | 75 | highlight(sel_start, sel_end); |
... | ... | @@ -75,7 +79,7 @@ |
75 | 79 | |
76 | 80 | /* |
77 | 81 | * User settable table: what characters are to be considered alphabetic? |
78 | - * 256 bits. FIXME: Needs a locking model. | |
82 | + * 256 bits. Locked by the console lock. | |
79 | 83 | */ |
80 | 84 | static u32 inwordLut[8]={ |
81 | 85 | 0x00000000, /* control chars */ |
82 | 86 | |
... | ... | @@ -92,10 +96,20 @@ |
92 | 96 | return c > 0xff || (( inwordLut[c>>5] >> (c & 0x1F) ) & 1); |
93 | 97 | } |
94 | 98 | |
95 | -/* set inwordLut contents. Invoked by ioctl(). */ | |
99 | +/** | |
100 | + * set loadlut - load the LUT table | |
101 | + * @p: user table | |
102 | + * | |
103 | + * Load the LUT table from user space. The caller must hold the console | |
104 | + * lock. Make a temporary copy so a partial update doesn't make a mess. | |
105 | + */ | |
96 | 106 | int sel_loadlut(char __user *p) |
97 | 107 | { |
98 | - return copy_from_user(inwordLut, (u32 __user *)(p+4), 32) ? -EFAULT : 0; | |
108 | + u32 tmplut[8]; | |
109 | + if (copy_from_user(tmplut, (u32 __user *)(p+4), 32)) | |
110 | + return -EFAULT; | |
111 | + memcpy(inwordLut, tmplut, 32); | |
112 | + return 0; | |
99 | 113 | } |
100 | 114 | |
101 | 115 | /* does screen address p correspond to character at LH/RH edge of screen? */ |
... | ... | @@ -131,7 +145,16 @@ |
131 | 145 | } |
132 | 146 | } |
133 | 147 | |
134 | -/* set the current selection. Invoked by ioctl() or by kernel code. */ | |
148 | +/** | |
149 | + * set_selection - set the current selection. | |
150 | + * @sel: user selection info | |
151 | + * @tty: the console tty | |
152 | + * | |
153 | + * Invoked by the ioctl handle for the vt layer. | |
154 | + * | |
155 | + * The entire selection process is managed under the console_lock. It's | |
156 | + * a lot under the lock but its hardly a performance path | |
157 | + */ | |
135 | 158 | int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty) |
136 | 159 | { |
137 | 160 | struct vc_data *vc = vc_cons[fg_console].d; |
drivers/tty/vt/vt.c