aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt/selection.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2012-03-02 10:00:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 14:11:39 -0500
commit5289475d1375017ab4288b276383e9684280876d (patch)
tree9efb9bfccfb9b008bc1c9f2e5c89af8b26d57fc8 /drivers/tty/vt/selection.c
parent99cceb4e50cb67720e779f6611476bcb611af6b8 (diff)
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>
Diffstat (limited to 'drivers/tty/vt/selection.c')
-rw-r--r--drivers/tty/vt/selection.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 2a509167092..8e9b4be97a2 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -62,10 +62,14 @@ sel_pos(int n)
62 use_unicode); 62 use_unicode);
63} 63}
64 64
65/* remove the current selection highlight, if any, 65/**
66 from the console holding the selection. */ 66 * clear_selection - remove current selection
67void 67 *
68clear_selection(void) { 68 * Remove the current selection highlight, if any from the console
69 * holding the selection. The caller must hold the console lock.
70 */
71void clear_selection(void)
72{
69 highlight_pointer(-1); /* hide the pointer */ 73 highlight_pointer(-1); /* hide the pointer */
70 if (sel_start != -1) { 74 if (sel_start != -1) {
71 highlight(sel_start, sel_end); 75 highlight(sel_start, sel_end);
@@ -75,7 +79,7 @@ clear_selection(void) {
75 79
76/* 80/*
77 * User settable table: what characters are to be considered alphabetic? 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 */
80static u32 inwordLut[8]={ 84static u32 inwordLut[8]={
81 0x00000000, /* control chars */ 85 0x00000000, /* control chars */
@@ -92,10 +96,20 @@ static inline int inword(const u16 c) {
92 return c > 0xff || (( inwordLut[c>>5] >> (c & 0x1F) ) & 1); 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 */
96int sel_loadlut(char __user *p) 106int 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/* does screen address p correspond to character at LH/RH edge of screen? */ 115/* does screen address p correspond to character at LH/RH edge of screen? */
@@ -131,7 +145,16 @@ static int store_utf8(u16 c, char *p)
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 */
135int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty) 158int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty)
136{ 159{
137 struct vc_data *vc = vc_cons[fg_console].d; 160 struct vc_data *vc = vc_cons[fg_console].d;