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. 25-akpm/Documentation/sysrq.txt | 4 ++++ 25-akpm/fs/proc/proc_misc.c | 28 ++++++++++++++++++++++++++++ Documentation/filesystems/proc.txt | 0 3 files changed, 32 insertions(+) diff -puN fs/proc/proc_misc.c~proc-sysrq-trigger fs/proc/proc_misc.c --- 25/fs/proc/proc_misc.c~proc-sysrq-trigger Thu Mar 13 16:33:40 2003 +++ 25-akpm/fs/proc/proc_misc.c Thu Mar 13 16:46:21 2003 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -533,6 +534,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) @@ -605,6 +628,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; diff -puN Documentation/sysrq.txt~proc-sysrq-trigger Documentation/sysrq.txt --- 25/Documentation/sysrq.txt~proc-sysrq-trigger Thu Mar 13 17:10:03 2003 +++ 25-akpm/Documentation/sysrq.txt Thu Mar 13 17:10:53 2003 @@ -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 Documentation/filesystems/proc.txt~proc-sysrq-trigger Documentation/filesystems/proc.txt _