patch-2.1.15 linux/kernel/sys.c

Next file: linux/kernel/sysctl.c
Previous file: linux/kernel/panic.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.14/linux/kernel/sys.c linux/kernel/sys.c
@@ -24,6 +24,7 @@
 #if defined(CONFIG_APM) && defined(CONFIG_APM_POWER_OFF)
 #include <linux/apm_bios.h>
 #endif
+#include <linux/notifier.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -31,8 +32,16 @@
 /*
  * this indicates whether you can reboot with ctrl-alt-del: the default is yes
  */
+
 int C_A_D = 1;
 
+/*
+ *	List of functions to call at shutdown. This is used to stop any
+ *	idling DMA operations and the like. 
+ */
+ 
+struct notifier_block *boot_notifier_list=NULL;
+
 extern void adjust_clock(void);
 
 asmlinkage int sys_ni_syscall(void)
@@ -187,7 +196,10 @@
 	if (magic != 0xfee1dead || magic_too != 672274793)
 		return -EINVAL;
 	if (flag == 0x01234567)
+	{
+		notifier_call_chain(&boot_notifier_list, SYS_DOWN, NULL);
 		hard_reset_now();
+	}
 	else if (flag == 0x89ABCDEF)
 		C_A_D = 1;
 	else if (!flag)
@@ -198,6 +210,7 @@
 #if defined(CONFIG_APM) && defined(CONFIG_APM_POWER_OFF)
 		apm_set_power_state(APM_STATE_OFF);
 #endif
+		notifier_call_chain(&boot_notifier_list, SYS_HALT, NULL);
 		do_exit(0);
 	} else
 		return -EINVAL;
@@ -212,7 +225,10 @@
 void ctrl_alt_del(void)
 {
 	if (C_A_D)
+	{
+		notifier_call_chain(&boot_notifier_list, SYS_DOWN, NULL);
 		hard_reset_now();
+	}
 	else
 		kill_proc(1, SIGINT, 1);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov