/* * writing 'C' to /proc/sysrq-trigger is like sysrq-C */ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct ve_struct *cur = get_exec_env(); static int pnum = 10; if (count) { int i, cnt; char c[32]; cnt = min(count, sizeof(c)); if (copy_from_user(c, buf, cnt)) return -EFAULT; for (i = 0; i < cnt && c[i] != '\n'; i++) { if (!ve_is_super(cur)) { if (!pnum) continue; printk("SysRq: CT#%u sent '%c' magic key.\n", cur->veid, c[i]); pnum--; continue; } __handle_sysrq(c[i], NULL, 0); } } return count; }
/* * writing 'C' to /proc/sysrq-trigger is like sysrq-C */ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { if (count) { char c; if (get_user(c, buf)) return -EFAULT; __handle_sysrq(c, NULL, 0); } return count; }
static bool sysrq_filter(struct input_handle *handle, unsigned int type, unsigned int code, int value) { if (type != EV_KEY) goto out; switch (code) { case KEY_LEFTALT: case KEY_RIGHTALT: if (value) sysrq_alt = code; else { if (sysrq_down && code == sysrq_alt_use) sysrq_down = false; sysrq_alt = 0; } break; case KEY_SYSRQ: if (value == 1 && sysrq_alt) { sysrq_down = true; sysrq_alt_use = sysrq_alt; } break; default: if (sysrq_down && value && value != 2) __handle_sysrq(sysrq_xlate[code], NULL, 1); break; } out: return sysrq_down; }
void handle_sysrq(int key) { if (sysrq_on()) __handle_sysrq(key, true); }
/* * This function is called by the keyboard handler when SysRq is pressed * and any other keycode arrives. */ void handle_sysrq(int key, struct tty_struct *tty) { if (sysrq_on()) __handle_sysrq(key, tty, 1); }
static bool sysrq_filter(struct input_handle *handle, unsigned int type, unsigned int code, int value) { if (type != EV_KEY) goto out; switch (code) { /* use volumedown + volumeup + power for sysrq function */ #ifdef CONFIG_HUAWEI_KERNEL case KEY_VOLUMEDOWN: /* identify volumedown pressed down or not */ if (value) { sysrq_alt = code; } /* when volumedown lifted up clear the state of syrq_down and syrq_alt */ else { if (sysrq_down && code == sysrq_alt_use) { sysrq_down = false; } sysrq_alt = 0; } break; case KEY_VOLUMEUP: /* identify volumeup pressed down or not */ if (value == 1 && sysrq_alt) { sysrq_down = true; sysrq_alt_use = sysrq_alt; } break; case KEY_POWER: /* identify power pressed down or not */ if (sysrq_down && value && value != 2) { /* trigger system crash */ __handle_sysrq('c', NULL, 1); } break; default: break; #else case KEY_LEFTALT: case KEY_RIGHTALT: if (value) sysrq_alt = code; else { if (sysrq_down && code == sysrq_alt_use) sysrq_down = false; sysrq_alt = 0; } break; case KEY_SYSRQ: if (value == 1 && sysrq_alt) { sysrq_down = true; sysrq_alt_use = sysrq_alt; } break; default: if (sysrq_down && value && value != 2) __handle_sysrq(sysrq_xlate[code], NULL, 1); break; #endif } out: return sysrq_down; }
void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) { if (!sysrq_enabled) return; __handle_sysrq(key, pt_regs, tty); }
/* * This function is called by the keyboard handler when SysRq is pressed * and any other keycode arrives. */ void handle_sysrq(int key, struct tty_struct *tty) { if (!sysrq_enabled) return; __handle_sysrq(key, tty, 1); }