Re: [patch] Re: Magic Alt-SysRq change in 2.6.18-rc1

From: Paulo Marques
Date: Wed Jul 12 2006 - 15:40:33 EST


Paulo Marques wrote:
Roman Zippel wrote:
On Tue, 11 Jul 2006, Andrew Morton wrote:
[...]
What, actually, is the problem?

It changes the behaviour, it will annoy the hell out of people like me who have to deal with different kernels and expect this to just work. :-(
Since then has it been acceptable to just go ahead and break stuff? This problem doesn't really look unsolvable, so why is my request to fix the damn thing so unreasonable?

Ok, what about this one?

It doesn't work :P

Ok, I've tested it this time and this new one works as expected. I can
use any of the sequences discussed and I can produce a SysRq every time.
Still, just pressing SysRq or any sequence that doesn't start with "press Alt -> press SysRq" seems unaffected.

--
Paulo Marques - www.grupopie.com

Pointy-Haired Boss: I don't see anything that could stand in our way.
Dilbert: Sanity? Reality? The laws of physics?

Subject: allow the old behavior of Alt+SysRq+<key>

This should allow any order of Alt + SysRq press followed by any key
while still holding one of SysRq or Alt.

Signed-off-by: Paulo Marques <pmarques@xxxxxxxxxxxx>

--- ./drivers/char/keyboard.c.orig 2006-07-12 13:03:32.000000000 +0100
+++ ./drivers/char/keyboard.c 2006-07-12 20:39:21.000000000 +0100
@@ -150,7 +150,7 @@ unsigned char kbd_sysrq_xlate[KEY_MAX +
"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
"\r\000/"; /* 0x60 - 0x6f */
static int sysrq_down;
-static int sysrq_alt_use;
+static int sysrq_active;
#endif
static int sysrq_alt;

@@ -1164,16 +1164,24 @@ static void kbd_keycode(unsigned int key
printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);

#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
- if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
- if (!sysrq_down) {
- sysrq_down = down;
- sysrq_alt_use = sysrq_alt;
+ if (keycode == KEY_SYSRQ) {
+ if (down) {
+ if(sysrq_alt)
+ sysrq_down = down;
+ } else {
+ sysrq_down = 0;
}
- return;
}
- if (sysrq_down && !down && keycode == sysrq_alt_use)
- sysrq_down = 0;
- if (sysrq_down && down && !rep) {
+
+ if (sysrq_down && sysrq_alt)
+ sysrq_active = 1;
+ else if (!sysrq_down && !sysrq_alt)
+ sysrq_active = 0;
+
+ if (keycode == KEY_SYSRQ && sysrq_active)
+ return;
+
+ if (sysrq_active && down && !rep) {
handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
return;
}