mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-18 17:46:15 +07:00
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>
This commit is contained in:
parent
8e6d3fe1af
commit
9fc3de9c83
@ -654,7 +654,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
|
|||||||
if (value >= ARRAY_SIZE(fn_handler))
|
if (value >= ARRAY_SIZE(fn_handler))
|
||||||
return;
|
return;
|
||||||
if ((kbd->kbdmode == VC_RAW ||
|
if ((kbd->kbdmode == VC_RAW ||
|
||||||
kbd->kbdmode == VC_MEDIUMRAW) &&
|
kbd->kbdmode == VC_MEDIUMRAW ||
|
||||||
|
kbd->kbdmode == VC_OFF) &&
|
||||||
value != KVAL(K_SAK))
|
value != KVAL(K_SAK))
|
||||||
return; /* SAK is allowed even in raw mode */
|
return; /* SAK is allowed even in raw mode */
|
||||||
fn_handler[value](vc);
|
fn_handler[value](vc);
|
||||||
@ -1295,7 +1296,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
|
|||||||
if (rc == NOTIFY_STOP)
|
if (rc == NOTIFY_STOP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (raw_mode && type != KT_SPEC && type != KT_SHIFT)
|
if ((raw_mode || kbd->kbdmode == VC_OFF) && type != KT_SPEC && type != KT_SHIFT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*k_handler[type])(vc, keysym & 0xff, !down);
|
(*k_handler[type])(vc, keysym & 0xff, !down);
|
||||||
|
@ -688,6 +688,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
|
|||||||
kbd->kbdmode = VC_UNICODE;
|
kbd->kbdmode = VC_UNICODE;
|
||||||
compute_shiftstate();
|
compute_shiftstate();
|
||||||
break;
|
break;
|
||||||
|
case K_OFF:
|
||||||
|
kbd->kbdmode = VC_OFF;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -50,11 +50,12 @@ struct kbd_struct {
|
|||||||
#define VC_CAPSLOCK 2 /* capslock mode */
|
#define VC_CAPSLOCK 2 /* capslock mode */
|
||||||
#define VC_KANALOCK 3 /* kanalock mode */
|
#define VC_KANALOCK 3 /* kanalock mode */
|
||||||
|
|
||||||
unsigned char kbdmode:2; /* one 2-bit value */
|
unsigned char kbdmode:3; /* one 3-bit value */
|
||||||
#define VC_XLATE 0 /* translate keycodes using keymap */
|
#define VC_XLATE 0 /* translate keycodes using keymap */
|
||||||
#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
|
#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
|
||||||
#define VC_RAW 2 /* raw (scancode) mode */
|
#define VC_RAW 2 /* raw (scancode) mode */
|
||||||
#define VC_UNICODE 3 /* Unicode mode */
|
#define VC_UNICODE 3 /* Unicode mode */
|
||||||
|
#define VC_OFF 4 /* disabled mode */
|
||||||
|
|
||||||
unsigned char modeflags:5;
|
unsigned char modeflags:5;
|
||||||
#define VC_APPLIC 0 /* application key mode */
|
#define VC_APPLIC 0 /* application key mode */
|
||||||
|
@ -81,6 +81,7 @@ struct unimapinit {
|
|||||||
#define K_XLATE 0x01
|
#define K_XLATE 0x01
|
||||||
#define K_MEDIUMRAW 0x02
|
#define K_MEDIUMRAW 0x02
|
||||||
#define K_UNICODE 0x03
|
#define K_UNICODE 0x03
|
||||||
|
#define K_OFF 0x04
|
||||||
#define KDGKBMODE 0x4B44 /* gets current keyboard mode */
|
#define KDGKBMODE 0x4B44 /* gets current keyboard mode */
|
||||||
#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
|
#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user