From dd3871ec53cb626920662f7270ff90083f2d3097 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 14 May 2004 20:24:15 -0700 Subject: [PATCH] [PATCH] Make /proc/sysrq-trigger ignore sysrq_enabled It's silly that writing to /proc/sysrq-trigger does nothing if you haven't enabled /proc/sys/kernel/sysrq. So provide a new __handle_sysrq() which ignores the sysrq_enabled check. The patch also withdraws __handle_sysrq_nolock() from the kernel API. It had no callers. --- drivers/char/sysrq.c | 36 +++++++++++++++--------------------- fs/proc/proc_misc.c | 2 +- include/linux/sysrq.h | 8 +------- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 249935804e71a..da52bff37f97d 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c @@ -312,37 +312,19 @@ void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p) { sysrq_key_table[i] = op_p; } -/* - * This function is called by the keyboard handler when SysRq is pressed - * and any other keycode arrives. - */ - -void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) -{ - if (!sysrq_enabled) - return; - - __sysrq_lock_table(); - __handle_sysrq_nolock(key, pt_regs, tty); - __sysrq_unlock_table(); -} - /* * This is the non-locking version of handle_sysrq * It must/can only be called by sysrq key handlers, * as they are inside of the lock */ -void __handle_sysrq_nolock(int key, struct pt_regs *pt_regs, - struct tty_struct *tty) +void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) { struct sysrq_key_op *op_p; int orig_log_level; int i, j; - - if (!sysrq_enabled) - return; + __sysrq_lock_table(); orig_log_level = console_loglevel; console_loglevel = 7; printk(KERN_INFO "SysRq : "); @@ -364,10 +346,22 @@ void __handle_sysrq_nolock(int key, struct pt_regs *pt_regs, printk ("\n"); console_loglevel = orig_log_level; } + __sysrq_unlock_table(); +} + +/* + * This function is called by the keyboard handler when SysRq is pressed + * and any other keycode arrives. + */ + +void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) +{ + if (!sysrq_enabled) + return; + __handle_sysrq(key, pt_regs, tty); } EXPORT_SYMBOL(handle_sysrq); -EXPORT_SYMBOL(__handle_sysrq_nolock); EXPORT_SYMBOL(__sysrq_lock_table); EXPORT_SYMBOL(__sysrq_unlock_table); EXPORT_SYMBOL(__sysrq_get_key_op); diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 14f1a8fe6a036..be50b44a8471e 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -631,7 +631,7 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, if (get_user(c, buf)) return -EFAULT; - handle_sysrq(c, NULL, NULL); + __handle_sysrq(c, NULL, NULL); } return count; } diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 1acdb0bd46899..7fe8012f79f98 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -30,13 +30,7 @@ struct sysrq_key_op { */ void handle_sysrq(int, struct pt_regs *, struct tty_struct *); - -/* - * Nonlocking version of handle sysrq, used by sysrq handlers that need to - * call sysrq handlers - */ - -void __handle_sysrq_nolock(int, struct pt_regs *, struct tty_struct *); +void __handle_sysrq(int, struct pt_regs *, struct tty_struct *); /* * Sysrq registration manipulation functions -- 2.53.0