]> git.zerfleddert.de Git - ms2-kexec/blame - sys.c
update offsets to new european GB kernel, set software booting from USB
[ms2-kexec] / sys.c
CommitLineData
4e93cb00
MG
1/*
2 * linux/kernel/sys.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <linux/module.h>
8#include <linux/mm.h>
9#include <linux/utsname.h>
10#include <linux/mman.h>
11#include <linux/smp_lock.h>
12#include <linux/notifier.h>
13#include <linux/reboot.h>
14#include <linux/prctl.h>
15#include <linux/highuid.h>
16#include <linux/fs.h>
17#include <linux/resource.h>
18#include <linux/kernel.h>
19#include <linux/kexec.h>
20#include <linux/workqueue.h>
21#include <linux/capability.h>
22#include <linux/device.h>
23#include <linux/key.h>
24#include <linux/times.h>
25#include <linux/posix-timers.h>
26#include <linux/security.h>
27#include <linux/dcookies.h>
28#include <linux/suspend.h>
29#include <linux/tty.h>
30#include <linux/signal.h>
31#include <linux/cn_proc.h>
32#include <linux/getcpu.h>
33#include <linux/task_io_accounting_ops.h>
34#include <linux/seccomp.h>
35#include <linux/cpu.h>
36#include <linux/ptrace.h>
37
38#include <linux/compat.h>
39#include <linux/syscalls.h>
40#include <linux/kprobes.h>
41#include <linux/user_namespace.h>
42
43#include <asm/uaccess.h>
44#include <asm/io.h>
45#include <asm/unistd.h>
46
47extern asmlinkage long (*original_reboot)(int magic1, int magic2, unsigned int cmd, void __user *arg);
48
76b7ce1b 49#if 1
a16260b8
MG
50static struct notifier_block dummy_notifier_reboot = {
51 .notifier_call = NULL,
52 .next = NULL,
53 .priority = INT_MAX
54};
55
56BLOCKING_NOTIFIER_HEAD(notifier_head);
4f5f5319 57#endif
a16260b8
MG
58
59
4e93cb00
MG
60void kernel_restart_prepare(char *cmd)
61{
76b7ce1b 62#if 0
37bd435c
MG
63#warning assuming kernel_restart_prepare is at 0xc00779cc
64 void (*original_kernel_restart_prepare)(char *) = (void (*)(char *))0xc00779cc;
65 //void (*original_kernel_restart_prepare)(char *) = (void (*)(char *))KERNEL_RESTART_PREPARE;
4f5f5319 66 return original_kernel_restart_prepare(cmd);
76b7ce1b 67#else
a16260b8
MG
68 register_reboot_notifier(&dummy_notifier_reboot);
69 notifier_head.head=dummy_notifier_reboot.next;
70 unregister_reboot_notifier(&dummy_notifier_reboot);
71
72 blocking_notifier_call_chain(&notifier_head, SYS_RESTART, cmd);
73 system_state = SYSTEM_RESTART;
1109a23f
MG
74 //device_shutdown();
75 //sysdev_shutdown();
4f5f5319 76#endif
4e93cb00
MG
77}
78
79/*
80 * Reboot system call: for obvious reasons only root may call it,
81 * and even root needs to set up some magic numbers in the registers
82 * so that some mistake won't make this reboot the whole machine.
83 * You can also set the meaning of the ctrl-alt-del-key here.
84 *
85 * reboot doesn't sync: do that yourself before calling this.
86 */
87asmlinkage long reboot(int magic1, int magic2, unsigned int cmd, void __user *arg)
88{
89 int ret;
90 if(cmd==LINUX_REBOOT_CMD_KEXEC) {
91 /* We only trust the superuser with rebooting the system. */
92 if (!capable(CAP_SYS_BOOT))
93 return -EPERM;
94
95 /* For safety, we require "magic" arguments. */
96 if (magic1 != LINUX_REBOOT_MAGIC1 ||
97 (magic2 != LINUX_REBOOT_MAGIC2 &&
98 magic2 != LINUX_REBOOT_MAGIC2A &&
99 magic2 != LINUX_REBOOT_MAGIC2B &&
100 magic2 != LINUX_REBOOT_MAGIC2C))
101 return -EINVAL;
102
103 lock_kernel();
104 ret = kernel_kexec();
105 unlock_kernel();
106 return ret;
107 } else {
108 return original_reboot(magic1, magic2, cmd, arg);
109 }
110}
Impressum, Datenschutz