⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysrq.txt

📁 ARM 嵌入式 系统 设计与实例开发 实验教材 二源码
💻 TXT
字号:
Linux Magic System Request Key HacksDocumentation for sysrq.c version 1.15Last update: $Date: 2001/01/28 10:15:59 $*  What is the magic SysRq key?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~It is a 'magical' key combo you can hit which the kernel will respond toregardless of whatever else it is doing, unless it is completely locked up.*  How do I enable the magic SysRq key?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' whenconfiguring the kernel. When running on a kernel with SysRq compiled in, itmay be DISABLED at run-time using following command:        echo "0" > /proc/sys/kernel/sysrqNote that previous versions disabled sysrq by default, and you were requiredto specifically enable it at run-time. That is not the case any longer.*  How do I use the magic SysRq key?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~On x86   - You press the key combo 'ALT-SysRq-<command key>'. Note - Some           keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is           also known as the 'Print Screen' key.On SPARC - You press 'ALT-STOP-<command key>', I believe.On the serial console (PC style standard serial ports only) -           You send a BREAK, then within 5 seconds a command key. Sending           BREAK twice is interpreted as a normal BREAK.On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>,               Print Screen (or F13) - <command key> may suffice.On other - If you know of the key combos for other architectures, please           let me know so I can add them to this section.*  What are the 'command' keys?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'r'     - Turns off keyboard raw mode and sets it to XLATE.'k'     - Secure Access Key (SAK) Kills all programs on the current virtual          console. NOTE: See important comments below in SAK section.'b'     - Will immediately reboot the system without syncing or unmounting          your disks.'o'     - Will shut your system off (if configured and supported).'s'     - Will attempt to sync all mounted filesystems.'u'     - Will attempt to remount all mounted filesystems read-only.'p'     - Will dump the current registers and flags to your console.'t'     - Will dump a list of current tasks and their information to your          console.'m'     - Will dump current memory info to your console.'0'-'9' - Sets the console log level, controlling which kernel messages          will be printed to your console. ('0', for example would make          it so that only emergency messages like PANICs or OOPSes would          make it to your console.)'e'     - Send a SIGTERM to all processes, except for init.'i'     - Send a SIGKILL to all processes, except for init.'l'     - Send a SIGKILL to all processes, INCLUDING init. (Your system          will be non-functional after this.)'h'     - Will display help ( actually any other key than those listed          above will display help. but 'h' is easy to remember :-)*  Okay, so what can I use them for?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Well, un'R'aw is very handy when your X server or a svgalib program crashes.sa'K' (Secure Access Key) is useful when you want to be sure there are notrojan program is running at console and which could grab your passwordwhen you would try to login. It will kill all programs on given consoleand thus letting you make sure that the login prompt you see is actuallythe one from init, not some trojan program.IMPORTANT:In its true form it is not a true SAK like the one in   :IMPORTANTIMPORTANT:c2 compliant systems, and it should be mistook as such. :IMPORTANT       It seems other find it useful as (System Attention Key) which isuseful when you want to exit a program that will not let you switch consoles.(For example, X or a svgalib program.)re'B'oot is good when you're unable to shut down. But you should also 'S'yncand 'U'mount first.'S'ync is great when your system is locked up, it allows you to sync yourdisks and will certainly lessen the chance of data loss and fscking. Notethat the sync hasn't taken place until you see the "OK" and "Done" appearon the screen. (If the kernel is really in strife, you may not ever get theOK or Done message...)'U'mount is basically useful in the same ways as 'S'ync. I generally 'S'ync,'U'mount, then re'B'oot when my system locks. It's saved me many a fsck.Again, the unmount (remount read-only) hasn't taken place until you see the"OK" and "Done" message appear on the screen.The loglevel'0'-'9' is useful when your console is being flooded withkernel messages you do not want to see. Setting '0' will prevent all butthe most urgent kernel messages from reaching your console. (They willstill be logged if syslogd/klogd are alive, though.)t'E'rm and k'I'll are useful if you have some sort of runaway process youare unable to kill any other way, especially if it's spawning otherprocesses.*  Sometimes SysRq seems to get 'stuck' after using it, what can I do?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~That happens to me, also. I've found that tapping shift, alt, and controlon both sides of the keyboard, and hitting an invalid sysrq sequence againwill fix the problem. (ie, something like alt-sysrq-z). Switching to anothervirtual console (ALT+Fn) and then back again should also help.*  I hit SysRq, but nothing seems to happen, what's wrong?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~There are some keyboards that send different scancodes for SysRq than thepre-defined 0x54. So if SysRq doesn't work out of the box for a certainkeyboard, run 'showkey -s' to find out the proper scancode sequence. Thenuse 'setkeycodes <sequence> 84' to define this sequence to the usual SysRqcode (84 is decimal for 0x54). It's probably best to put this command in aboot script. Oh, and by the way, you exit 'showkey' by not typing anythingfor ten seconds.*  I want to add SysRQ key events to a module, how does it work?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In order to register a basic function with the table, you must first includethe header 'include/linux/sysrq.h', this will define everything else you need.Next, you must create a sysrq_key_op struct, and populate it with A) the keyhandler function you will use, B) a help_msg string, that will print when SysRQprints help, and C) an action_msg string, that will print right before yourhandler is called. Your handler must conform to the protoype in 'sysrq.h'.After the sysrq_key_op is created, you can call the macro register_sysrq_key(int key, struct sysrq_key_op *op_p) that is defined insysrq.h, this will register the operation pointed to by 'op_p' at tablekey 'key', if that slot in the table is blank. At module unload time, you mustcall the macro unregister_sysrq_key(int key, struct sysrq_key_op *op_p), whichwill remove the key op pointed to by 'op_p' from the key 'key', if and only ifit is currently registered in that slot. This is in case the slot has beenoverwritten since you registered it.The Magic SysRQ system works by registering key operations against a key oplookup table, which is defined in 'drivers/char/sysrq.c'. This key table hasa number of operations registered into it at compile time, but is mutable,and 4 functions are exported for interface to it: __sysrq_lock_table,__sysrq_unlock_table, __sysrq_get_key_op, and __sysrq_put_key_op. Thefunctions __sysrq_swap_key_ops and __sysrq_swap_key_ops_nolock are definedin the header itself, and the REGISTER and UNREGISTER macros are built fromithese. More complex (and dangerous!) manipulations of the table are possibleusing these functions, but you must be careful to always lock the table beforeyou read or write from it, and to unlock it again when you are done. (And ofcourse, to never ever leave an invalid pointer in the table). Null pointers inthe table are always safe :)If for some reason you feel the need to call the handle_sysrq function fromwithin a function called by handle_sysrq, you must be aware that you are ina lock (you are also in an interupt handler, which means don't sleep!), soyou must call __handle_sysrq_nolock instead.*  I have more questions, who can I ask?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You may feel free to send email to myrdraal@deathsdoor.com, and I willrespond as soon as possible. -MyrdraalAnd I'll answer any questions about the registration system you got, alsoresponding as soon as possible. -Crutcher*  Credits~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Written by Mydraal <myrdraal@deathsdoor.com>Updated by Adam Sulmicki <adam@cfar.umd.edu>Updated by Jeremy M. Dolan <jmd@turbogeek.org> 2001/01/28 10:15:59Added to by Crutcher Dunnavant <crutcher+kernel@datastacks.com>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -