void __handle_sysrq(int key, bool check_mask) { struct sysrq_key_op *op_p; int orig_log_level; int i; unsigned long flags; spin_lock_irqsave(&sysrq_key_table_lock, flags); set_sysrq_in_progress(1); /* * Raise the apparent loglevel to maximum so that the sysrq header * is shown to provide the user with positive feedback. We do not * simply emit this at KERN_EMERG as that would change message * routing in the consumers of /proc/kmsg. */ orig_log_level = console_loglevel; console_loglevel = 7; printk(KERN_INFO "SysRq : "); op_p = __sysrq_get_key_op(key); if (op_p) { /* * Should we check for enabled operations (/proc/sysrq-trigger * should not) and is the invoked operation enabled? */ if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { printk("%s\n", op_p->action_msg); console_loglevel = orig_log_level; op_p->handler(key); } else { printk("This sysrq operation is disabled.\n"); } } else { printk("HELP : "); /* Only print the help msg once per handler */ for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) { if (sysrq_key_table[i]) { int j; for (j = 0; sysrq_key_table[i] != sysrq_key_table[j]; j++) ; if (j != i) continue; printk("%s ", sysrq_key_table[i]->help_msg); } } printk("\n"); console_loglevel = orig_log_level; } set_sysrq_in_progress(0); spin_unlock_irqrestore(&sysrq_key_table_lock, flags); }
/* * 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(int key, struct tty_struct *tty, int check_mask) { struct sysrq_key_op *op_p; int orig_log_level; int i; unsigned long flags; spin_lock_irqsave(&sysrq_key_table_lock, flags); orig_log_level = console_loglevel; console_loglevel = 7; printk(KERN_INFO "SysRq : "); op_p = __sysrq_get_key_op(key); if (op_p) { /* * Should we check for enabled operations (/proc/sysrq-trigger * should not) and is the invoked operation enabled? */ if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { printk("%s\n", op_p->action_msg); console_loglevel = orig_log_level; op_p->handler(key, tty); } else { printk("This sysrq operation is disabled.\n"); } } else { printk("HELP : "); /* Only print the help msg once per handler */ for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) { if (sysrq_key_table[i]) { int j; for (j = 0; sysrq_key_table[i] != sysrq_key_table[j]; j++) ; if (j != i) continue; printk("%s ", sysrq_key_table[i]->help_msg); } } printk("\n"); console_loglevel = orig_log_level; } spin_unlock_irqrestore(&sysrq_key_table_lock, flags); }
void __handle_sysrq(int key, bool check_mask) { struct sysrq_key_op *op_p; int orig_log_level; int i; unsigned long flags; spin_lock_irqsave(&sysrq_key_table_lock, flags); orig_log_level = console_loglevel; console_loglevel = 7; printk(KERN_INFO "%s (%d) triggered SysRq\n", current->comm, current->pid); printk(KERN_INFO "SysRq : "); op_p = __sysrq_get_key_op(key); if (op_p) { if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { printk("%s\n", op_p->action_msg); console_loglevel = orig_log_level; op_p->handler(key); } else { printk("This sysrq operation is disabled.\n"); } } else { printk("HELP : "); for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) { if (sysrq_key_table[i]) { int j; for (j = 0; sysrq_key_table[i] != sysrq_key_table[j]; j++) ; if (j != i) continue; printk("%s ", sysrq_key_table[i]->help_msg); } } printk("\n"); console_loglevel = orig_log_level; } spin_unlock_irqrestore(&sysrq_key_table_lock, flags); }