Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9214
b: refs/heads/master
c: e4c9433
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Sep 23, 2005
1 parent 44d4efc commit a45ff90
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0678e5feaab8b359b18858e8532bb6017edb112b
refs/heads/master: e4c94330e3395ae87451bded2840a25d04f27902
4 changes: 4 additions & 0 deletions trunk/include/linux/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ extern void machine_crash_shutdown(struct pt_regs *);
* Architecture independent implemenations of sys_reboot commands.
*/

extern void kernel_restart_prepare(char *cmd);
extern void kernel_halt_prepare(void);
extern void kernel_power_off_prepare(void);

extern void kernel_restart(char *cmd);
extern void kernel_halt(void);
extern void kernel_power_off(void);
Expand Down
52 changes: 46 additions & 6 deletions trunk/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,35 @@ asmlinkage long sys_getpriority(int which, int who)
return retval;
}

/**
* emergency_restart - reboot the system
*
* Without shutting down any hardware or taking any locks
* reboot the system. This is called when we know we are in
* trouble so this is our best effort to reboot. This is
* safe to call in interrupt context.
*/
void emergency_restart(void)
{
machine_emergency_restart();
}
EXPORT_SYMBOL_GPL(emergency_restart);

void kernel_restart(char *cmd)
/**
* kernel_restart - reboot the system
*
* Shutdown everything and perform a clean reboot.
* This is not safe to call in interrupt context.
*/
void kernel_restart_prepare(char *cmd)
{
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
device_shutdown();
}
void kernel_restart(char *cmd)
{
kernel_restart_prepare(cmd);
if (!cmd) {
printk(KERN_EMERG "Restarting system.\n");
} else {
Expand All @@ -382,6 +400,12 @@ void kernel_restart(char *cmd)
}
EXPORT_SYMBOL_GPL(kernel_restart);

/**
* kernel_kexec - reboot the system
*
* Move into place and start executing a preloaded standalone
* executable. If nothing was preloaded return an error.
*/
void kernel_kexec(void)
{
#ifdef CONFIG_KEXEC
Expand All @@ -390,31 +414,47 @@ void kernel_kexec(void)
if (!image) {
return;
}
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
system_state = SYSTEM_RESTART;
device_shutdown();
kernel_restart_prepare(NULL);
printk(KERN_EMERG "Starting new kernel\n");
machine_shutdown();
machine_kexec(image);
#endif
}
EXPORT_SYMBOL_GPL(kernel_kexec);

void kernel_halt(void)
/**
* kernel_halt - halt the system
*
* Shutdown everything and perform a clean system halt.
*/
void kernel_halt_prepare(void)
{
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
system_state = SYSTEM_HALT;
device_shutdown();
}
void kernel_halt(void)
{
kernel_halt_prepare();
printk(KERN_EMERG "System halted.\n");
machine_halt();
}
EXPORT_SYMBOL_GPL(kernel_halt);

void kernel_power_off(void)
/**
* kernel_power_off - power_off the system
*
* Shutdown everything and perform a clean system power_off.
*/
void kernel_power_off_prepare(void)
{
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
system_state = SYSTEM_POWER_OFF;
device_shutdown();
}
void kernel_power_off(void)
{
kernel_power_off_prepare();
printk(KERN_EMERG "Power down.\n");
machine_power_off();
}
Expand Down

0 comments on commit a45ff90

Please sign in to comment.