Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

proc: move sysrq-trigger out of fs/proc/

Move it into sysrq.c, along with the rest of the sysrq implementation.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
f40cbaa5 ac0d86f5

+30 -26
+30
drivers/char/sysrq.c
··· 23 23 #include <linux/reboot.h> 24 24 #include <linux/sysrq.h> 25 25 #include <linux/kbd_kern.h> 26 + #include <linux/proc_fs.h> 26 27 #include <linux/quotaops.h> 27 28 #include <linux/kernel.h> 28 29 #include <linux/module.h> ··· 535 534 return __sysrq_swap_key_ops(key, NULL, op_p); 536 535 } 537 536 EXPORT_SYMBOL(unregister_sysrq_key); 537 + 538 + #ifdef CONFIG_PROC_FS 539 + /* 540 + * writing 'C' to /proc/sysrq-trigger is like sysrq-C 541 + */ 542 + static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, 543 + size_t count, loff_t *ppos) 544 + { 545 + if (count) { 546 + char c; 547 + 548 + if (get_user(c, buf)) 549 + return -EFAULT; 550 + __handle_sysrq(c, NULL, 0); 551 + } 552 + return count; 553 + } 554 + 555 + static const struct file_operations proc_sysrq_trigger_operations = { 556 + .write = write_sysrq_trigger, 557 + }; 558 + 559 + static int __init sysrq_init(void) 560 + { 561 + proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations); 562 + return 0; 563 + } 564 + module_init(sysrq_init); 565 + #endif
-26
fs/proc/proc_misc.c
··· 45 45 #include <linux/blkdev.h> 46 46 #include <linux/hugetlb.h> 47 47 #include <linux/jiffies.h> 48 - #include <linux/sysrq.h> 49 48 #include <linux/vmalloc.h> 50 49 #include <linux/crash_dump.h> 51 50 #include <linux/pid_namespace.h> ··· 703 704 return proc_calc_metrics(page, start, off, count, eof, len); 704 705 } 705 706 706 - #ifdef CONFIG_MAGIC_SYSRQ 707 - /* 708 - * writing 'C' to /proc/sysrq-trigger is like sysrq-C 709 - */ 710 - static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, 711 - size_t count, loff_t *ppos) 712 - { 713 - if (count) { 714 - char c; 715 - 716 - if (get_user(c, buf)) 717 - return -EFAULT; 718 - __handle_sysrq(c, NULL, 0); 719 - } 720 - return count; 721 - } 722 - 723 - static const struct file_operations proc_sysrq_trigger_operations = { 724 - .write = write_sysrq_trigger, 725 - }; 726 - #endif 727 - 728 707 #ifdef CONFIG_PROC_PAGE_MONITOR 729 708 #define KPMSIZE sizeof(u64) 730 709 #define KPMMASK (KPMSIZE - 1) ··· 910 933 #endif 911 934 #ifdef CONFIG_PROC_VMCORE 912 935 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); 913 - #endif 914 - #ifdef CONFIG_MAGIC_SYSRQ 915 - proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations); 916 936 #endif 917 937 }