Skip to contentSkip to conversation

hvc_console: send magic sysrq key to terminal

PATCH In review Hendrik Brueckner 2 participants 4 messages Dec 16, 2008 Char and misc drivers

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 hvc_console: escape magic sysrq key

In reply to Hendrik Brueckner

From: Hendrik Brueckner <[email protected]>

The ctrl-o (^O) is a common control key used by several applications like vim.

To allow users to send ^O to the terminal, this patch introduces a check if ^O is pressed again if the sysrq_pressed variable is already set. In this case, clear sysrq_pressed state and flip the ^O character to the tty. (The old behavior has always set "sysrq_pressed" if ^0 has been entered, and it has not flipped the ^O character to the tty.)

---
 drivers/char/hvc_console.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/char/hvc_console.c +5 -2
@@ -642,8 +642,11 @@ int hvc_poll(struct hvc_struct *hp)
 				/* Handle the SysRq Hack */
 				/* XXX should support a sequence */
 				if (buf[i] == '\x0f') {	/* ^O */
-					sysrq_pressed = 1;
-					continue;
+					/* if ^0 is pressed again, reset
+					 * sysrq_pressed and flip ^0 char */
+					sysrq_pressed = (sysrq_pressed) ? 0 : 1;
+					if (sysrq_pressed)
+						continue;
 				} else if (sysrq_pressed) {
 					handle_sysrq(buf[i], tty);
 					sysrq_pressed = 0;
Signature · 10 lines
Hendrik Brueckner
D/3303 Linux on System z Development
eMail: [email protected]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#0 lore raw

cover hvc_console: send magic sysrq key to terminal

Hello,

the patch allows to send the magic sysrq key to the terminal (if pressed twice), so that it can be consumed by applications (e.g. ^0 is used by some editors...)

Ben, Paul, could you add the patch to your powerpc tree?

Thanks and regards,
Hendrik

Signature · 10 lines
Hendrik Brueckner
D/3303 Linux on System z Development
eMail: [email protected]
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 Boeblingen

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#2 lore raw

Re: [patch 1/1] hvc_console: escape magic sysrq key

In reply to Hendrik Brueckner

drivers/char/hvc_console.c int hvc_poll(struct hvc_struct *hp) · line 646

Quoted 2 lines · Hendrik Brueckner
drivers/char/hvc_console.c +2 -0
+					/* if ^0 is pressed again, reset
+					 * sysrq_pressed and flip ^0 char */

The comment says ^0 twice when ^O is meant.

drivers/char/hvc_console.c int hvc_poll(struct hvc_struct *hp) · line 647

Quoted 1 line
drivers/char/hvc_console.c +1 -0
+					sysrq_pressed = (sysrq_pressed) ? 0 : 1;
                                        sysrq_pressed = !sysrc_pressed;

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#3 lore raw

Re: [patch 1/1 v2] hvc_console: escape magic sysrq key

Hello Andreas,

thanks for your comments.

Quoted 3 lines · Andreas Schwab

Review

Quoted 2 lines
(quoted diff) +2 -0
+					/* if ^0 is pressed again, reset
+					 * sysrq_pressed and flip ^0 char */

The comment says ^0 twice when ^O is meant.

Correct. I have updated the comment.

Quoted 2 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+					sysrq_pressed = (sysrq_pressed) ? 0 : 1;
                                        sysrq_pressed = !sysrc_pressed;

Ok, it might look better.

[PATCH v2] hvc_console: escape magic sysrq key

From: Hendrik Brueckner <[email protected]>

The ctrl-o (^O) is a common control key used by several applications like vim.

To allow users to send ^O to the terminal, this patch introduces a check if ^O is pressed again if the sysrq_pressed variable is already set. In this case, clear sysrq_pressed state and flip the ^O character to the tty. (The old behavior has always set "sysrq_pressed" if ^O has been entered, and it has not flipped the ^O character to the tty.)

---
 drivers/char/hvc_console.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/char/hvc_console.c +5 -2
@@ -642,8 +642,11 @@ int hvc_poll(struct hvc_struct *hp)
 				/* Handle the SysRq Hack */
 				/* XXX should support a sequence */
 				if (buf[i] == '\x0f') {	/* ^O */
-					sysrq_pressed = 1;
-					continue;
+					/* if ^O is pressed again, reset
+					 * sysrq_pressed and flip ^O char */
+					sysrq_pressed = !sysrq_pressed;
+					if (sysrq_pressed)
+						continue;
 				} else if (sysrq_pressed) {
 					handle_sysrq(buf[i], tty);
 					sysrq_pressed = 0;