Commit 5d954f33 authored by Andrew Morton's avatar Andrew Morton Committed by Dave Jones

[PATCH] /proc/sysrq-trigger: trigger sysrq functions via

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.
parent a92fb3fe
...@@ -36,6 +36,10 @@ On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>, ...@@ -36,6 +36,10 @@ On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>,
On other - If you know of the key combos for other architectures, please On other - If you know of the key combos for other architectures, please
let me know so I can add them to this section. 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? * What are the 'command' keys?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'r' - Turns off keyboard raw mode and sets it to XLATE. 'r' - Turns off keyboard raw mode and sets it to XLATE.
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/hugetlb.h> #include <linux/hugetlb.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/sysrq.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -521,6 +522,28 @@ static struct file_operations proc_profile_operations = { ...@@ -521,6 +522,28 @@ static struct file_operations proc_profile_operations = {
.write = write_profile, .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; struct proc_dir_entry *proc_root_kcore;
static void create_seq_entry(char *name, mode_t mode, struct file_operations *f) static void create_seq_entry(char *name, mode_t mode, struct file_operations *f)
...@@ -592,6 +615,11 @@ void __init proc_misc_init(void) ...@@ -592,6 +615,11 @@ void __init proc_misc_init(void)
entry->size = (1+prof_len) * sizeof(unsigned int); 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 #ifdef CONFIG_PPC32
{ {
extern struct file_operations ppc_htab_operations; extern struct file_operations ppc_htab_operations;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment