This makes sysrq facilities available to remote users. Writing a 'C' to /proc/sysrq-trigger receives the same treatment as typing sysrq-C on the local keyboard. Documentation/sysrq.txt | 4 ++++ fs/proc/proc_misc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff -puN Documentation/sysrq.txt~proc-sysrq-trigger Documentation/sysrq.txt --- 25/Documentation/sysrq.txt~proc-sysrq-trigger 2003-03-17 21:33:20.000000000 -0800 +++ 25-akpm/Documentation/sysrq.txt 2003-03-17 21:33:20.000000000 -0800 @@ -36,6 +36,10 @@ On PowerPC - Press 'ALT - Print Screen ( On other - If you know of the key combos for other architectures, please let me know so I can add them to this section. +On all - write a character to /proc/sysrq-trigger. eg: + + echo t > /proc/sysrq-trigger + * What are the 'command' keys? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'r' - Turns off keyboard raw mode and sets it to XLATE. diff -puN fs/proc/proc_misc.c~proc-sysrq-trigger fs/proc/proc_misc.c --- 25/fs/proc/proc_misc.c~proc-sysrq-trigger 2003-03-17 21:33:20.000000000 -0800 +++ 25-akpm/fs/proc/proc_misc.c 2003-03-17 21:33:20.000000000 -0800 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -521,6 +522,28 @@ static struct file_operations proc_profi .write = write_profile, }; +#ifdef CONFIG_MAGIC_SYSRQ +/* + * writing 'C' to /proc/sysrq-trigger is like sysrq-C + */ +static ssize_t write_sysrq_trigger(struct file *file, const char *buf, + size_t count, loff_t *ppos) +{ + if (count) { + char c; + + if (get_user(c, buf)) + return -EFAULT; + handle_sysrq(c, NULL, NULL); + } + return count; +} + +static struct file_operations proc_sysrq_trigger_operations = { + .write = write_sysrq_trigger, +}; +#endif + struct proc_dir_entry *proc_root_kcore; static void create_seq_entry(char *name, mode_t mode, struct file_operations *f) @@ -592,6 +615,11 @@ void __init proc_misc_init(void) entry->size = (1+prof_len) * sizeof(unsigned int); } } +#ifdef CONFIG_MAGIC_SYSRQ + entry = create_proc_entry("sysrq-trigger", S_IWUSR, NULL); + if (entry) + entry->proc_fops = &proc_sysrq_trigger_operations; +#endif #ifdef CONFIG_PPC32 { extern struct file_operations ppc_htab_operations; _