Messages in this thread Patch in this message | | | Date | 24 Aug 1999 03:37:56 -0000 | From | Scott Laird <> | Subject | Re: PATCH: magic sysrq for serial console |
| |
In article <7pcr4l$vtg$1@defiant.cistron.net> you write: >Hopefully this is useful for someone. I made the sysrq stuff work >on a serial console, since we have some trouble with a machine which >is on a remote location and has a serial console (see my other message >about the oopsen on that machine).
Nice, this should be *very* useful to us. Here's an additional patch that adds support for redisplaying the last 1k of the message ring buffer and for faking a Ctrl-Atl-Delete. Feel free to add this to the patch that you're distributing :-).
The message buffer redisplay code is a bit ugly, but it's not really much worse than the rest of printk.c or sysrq.c -- someone should really take a good look at the locking in do_syslog and the code in is_local_disk. They both look wrong :-(.
--- linux-old/drivers/char/sysrq.c Wed Aug 11 11:51:38 1999 +++ linux-new/drivers/char/sysrq.c Mon Aug 23 20:13:26 1999 @@ -36,6 +36,7 @@ extern void reset_vc(unsigned int); extern int console_loglevel; extern struct vfsmount *vfsmntlist; +extern void reprint_messages(void) ; /* Send a signal to all user processes */ @@ -134,6 +135,16 @@ send_sig_all(SIGKILL, 1); orig_log_level = 8; break; + case 'd': /* D -- emulate Ctrl-Alt-Del */ + printk("Faking ctrl-alt-del\n"); + ctrl_alt_del(); + orig_log_level = 8; + break; + case 'c': /* C -- Dump the last 1k of the kernel + * message log to the console */ + printk("Dump console buffer\n"); + reprint_messages(); + break; default: /* Unknown: help */ if (kbd) printk("unRaw "); @@ -145,7 +156,7 @@ #ifdef CONFIG_APM "Off " #endif - "Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL\n"); + "Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL showConsole ctrl-alt-Del\n"); /* Don't use 'A' as it's handled specially on the Sparc */ } diff -u -N -r linux-old/kernel/printk.c linux-new/kernel/printk.c --- linux-old/kernel/printk.c Sat Mar 6 14:37:10 1999 +++ linux-new/kernel/printk.c Mon Aug 23 20:06:13 1999 @@ -433,3 +433,39 @@ tty->driver.write(tty, 0, msg, strlen(msg)); return; } + + +/* + * Re-print the message log to console(s) + * + * Useful for sysrq over non-buffering serial consoles + * + */ + +void reprint_messages(void) +{ + int len=1023; + unsigned long i, j, count, flags; + int do_clear = 0; + + memset(buf,0,1024); + + /* + * The logged_chars, log_start, and log_size values may + * change from an interrupt, so we disable interrupts. + */ + __save_flags(flags); + __cli(); + count = len; + if (count > LOG_BUF_LEN) + count = LOG_BUF_LEN; + if (count > logged_chars) + count = logged_chars; + j = log_start + log_size - count; + __restore_flags(flags); + for (i = 0; i < count; i++) { + buf[i] = *((char *) log_buf+(j++ & (LOG_BUF_LEN-1))); + } + + console_print(buf); +}
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |