diff options
author | Arthur Taylor <art@ified.ca> | 2011-02-04 16:55:50 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-17 14:12:40 -0500 |
commit | 9fc3de9c83565fcaa23df74c2fc414bb6e7efb0a (patch) | |
tree | 8d5fb1f8b90fb9a4f194aee8971859a45283d88c | |
parent | 8e6d3fe1af38bea3f6c003f8737d2e3a02d00fa0 (diff) |
vt: Add virtual console keyboard mode OFF
virtual console: add keyboard mode OFF
Add a new mode for the virtual console keyboard OFF in which all input
other than shift keys is ignored. Prevents vt input buffers from
overflowing when a program opens but doesn't read from a tty, like X11
using evdev for input.
Signed-off-by: Arthur Taylor <art@ified.ca>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/tty/vt/keyboard.c | 5 | ||||
-rw-r--r-- | drivers/tty/vt/vt_ioctl.c | 3 | ||||
-rw-r--r-- | include/linux/kbd_kern.h | 3 | ||||
-rw-r--r-- | include/linux/kd.h | 1 |
4 files changed, 9 insertions, 3 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index e95d7876ca6b..6dd3c68c13ad 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c | |||
@@ -654,7 +654,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag) | |||
654 | if (value >= ARRAY_SIZE(fn_handler)) | 654 | if (value >= ARRAY_SIZE(fn_handler)) |
655 | return; | 655 | return; |
656 | if ((kbd->kbdmode == VC_RAW || | 656 | if ((kbd->kbdmode == VC_RAW || |
657 | kbd->kbdmode == VC_MEDIUMRAW) && | 657 | kbd->kbdmode == VC_MEDIUMRAW || |
658 | kbd->kbdmode == VC_OFF) && | ||
658 | value != KVAL(K_SAK)) | 659 | value != KVAL(K_SAK)) |
659 | return; /* SAK is allowed even in raw mode */ | 660 | return; /* SAK is allowed even in raw mode */ |
660 | fn_handler[value](vc); | 661 | fn_handler[value](vc); |
@@ -1295,7 +1296,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1295 | if (rc == NOTIFY_STOP) | 1296 | if (rc == NOTIFY_STOP) |
1296 | return; | 1297 | return; |
1297 | 1298 | ||
1298 | if (raw_mode && type != KT_SPEC && type != KT_SHIFT) | 1299 | if ((raw_mode || kbd->kbdmode == VC_OFF) && type != KT_SPEC && type != KT_SHIFT) |
1299 | return; | 1300 | return; |
1300 | 1301 | ||
1301 | (*k_handler[type])(vc, keysym & 0xff, !down); | 1302 | (*k_handler[type])(vc, keysym & 0xff, !down); |
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 1235ebda6e1c..6bcf05bf4978 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c | |||
@@ -688,6 +688,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, | |||
688 | kbd->kbdmode = VC_UNICODE; | 688 | kbd->kbdmode = VC_UNICODE; |
689 | compute_shiftstate(); | 689 | compute_shiftstate(); |
690 | break; | 690 | break; |
691 | case K_OFF: | ||
692 | kbd->kbdmode = VC_OFF; | ||
693 | break; | ||
691 | default: | 694 | default: |
692 | ret = -EINVAL; | 695 | ret = -EINVAL; |
693 | goto out; | 696 | goto out; |
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h index 506ad20c18f8..4b0761cc7dd9 100644 --- a/include/linux/kbd_kern.h +++ b/include/linux/kbd_kern.h | |||
@@ -50,11 +50,12 @@ struct kbd_struct { | |||
50 | #define VC_CAPSLOCK 2 /* capslock mode */ | 50 | #define VC_CAPSLOCK 2 /* capslock mode */ |
51 | #define VC_KANALOCK 3 /* kanalock mode */ | 51 | #define VC_KANALOCK 3 /* kanalock mode */ |
52 | 52 | ||
53 | unsigned char kbdmode:2; /* one 2-bit value */ | 53 | unsigned char kbdmode:3; /* one 3-bit value */ |
54 | #define VC_XLATE 0 /* translate keycodes using keymap */ | 54 | #define VC_XLATE 0 /* translate keycodes using keymap */ |
55 | #define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */ | 55 | #define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */ |
56 | #define VC_RAW 2 /* raw (scancode) mode */ | 56 | #define VC_RAW 2 /* raw (scancode) mode */ |
57 | #define VC_UNICODE 3 /* Unicode mode */ | 57 | #define VC_UNICODE 3 /* Unicode mode */ |
58 | #define VC_OFF 4 /* disabled mode */ | ||
58 | 59 | ||
59 | unsigned char modeflags:5; | 60 | unsigned char modeflags:5; |
60 | #define VC_APPLIC 0 /* application key mode */ | 61 | #define VC_APPLIC 0 /* application key mode */ |
diff --git a/include/linux/kd.h b/include/linux/kd.h index 15f2853ea58f..c36d8476db55 100644 --- a/include/linux/kd.h +++ b/include/linux/kd.h | |||
@@ -81,6 +81,7 @@ struct unimapinit { | |||
81 | #define K_XLATE 0x01 | 81 | #define K_XLATE 0x01 |
82 | #define K_MEDIUMRAW 0x02 | 82 | #define K_MEDIUMRAW 0x02 |
83 | #define K_UNICODE 0x03 | 83 | #define K_UNICODE 0x03 |
84 | #define K_OFF 0x04 | ||
84 | #define KDGKBMODE 0x4B44 /* gets current keyboard mode */ | 85 | #define KDGKBMODE 0x4B44 /* gets current keyboard mode */ |
85 | #define KDSKBMODE 0x4B45 /* sets current keyboard mode */ | 86 | #define KDSKBMODE 0x4B45 /* sets current keyboard mode */ |
86 | 87 | ||