direct-io.hg

changeset 9377:787b39f5fc83

Externally triggered reboot signal executes ctrl_alt_del()
rather than calling /sbin/reboot directly.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 22 16:48:00 2006 +0100 (2006-03-22)
parents 4080ec91a014
children bd930874222e
files linux-2.6-xen-sparse/drivers/xen/core/reboot.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Mar 22 16:47:18 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Mar 22 16:48:00 2006 +0100
     1.3 @@ -25,9 +25,10 @@ void (*pm_power_off)(void);
     1.4  EXPORT_SYMBOL(pm_power_off);
     1.5  #endif
     1.6  
     1.7 +extern void ctrl_alt_del(void);
     1.8 +
     1.9  #define SHUTDOWN_INVALID  -1
    1.10  #define SHUTDOWN_POWEROFF  0
    1.11 -#define SHUTDOWN_REBOOT    1
    1.12  #define SHUTDOWN_SUSPEND   2
    1.13  /* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only
    1.14   * report a crash, not be instructed to crash!
    1.15 @@ -234,33 +235,19 @@ static int shutdown_process(void *__unus
    1.16  {
    1.17  	static char *envp[] = { "HOME=/", "TERM=linux",
    1.18  				"PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
    1.19 -	static char *restart_argv[]  = { "/sbin/reboot", NULL };
    1.20  	static char *poweroff_argv[] = { "/sbin/poweroff", NULL };
    1.21  
    1.22  	extern asmlinkage long sys_reboot(int magic1, int magic2,
    1.23  					  unsigned int cmd, void *arg);
    1.24  
    1.25 -	daemonize("shutdown");
    1.26 -
    1.27 -	switch (shutting_down) {
    1.28 -	case SHUTDOWN_POWEROFF:
    1.29 -	case SHUTDOWN_HALT:
    1.30 +	if ((shutting_down == SHUTDOWN_POWEROFF) ||
    1.31 +	    (shutting_down == SHUTDOWN_HALT)) {
    1.32  		if (execve("/sbin/poweroff", poweroff_argv, envp) < 0) {
    1.33  			sys_reboot(LINUX_REBOOT_MAGIC1,
    1.34  				   LINUX_REBOOT_MAGIC2,
    1.35  				   LINUX_REBOOT_CMD_POWER_OFF,
    1.36  				   NULL);
    1.37  		}
    1.38 -		break;
    1.39 -
    1.40 -	case SHUTDOWN_REBOOT:
    1.41 -		if (execve("/sbin/reboot", restart_argv, envp) < 0) {
    1.42 -			sys_reboot(LINUX_REBOOT_MAGIC1,
    1.43 -				   LINUX_REBOOT_MAGIC2,
    1.44 -				   LINUX_REBOOT_CMD_RESTART,
    1.45 -				   NULL);
    1.46 -		}
    1.47 -		break;
    1.48  	}
    1.49  
    1.50  	shutting_down = SHUTDOWN_INVALID; /* could try again */
    1.51 @@ -331,7 +318,7 @@ static void shutdown_handler(struct xenb
    1.52  	if (strcmp(str, "poweroff") == 0)
    1.53  		shutting_down = SHUTDOWN_POWEROFF;
    1.54  	else if (strcmp(str, "reboot") == 0)
    1.55 -		shutting_down = SHUTDOWN_REBOOT;
    1.56 +		ctrl_alt_del();
    1.57  	else if (strcmp(str, "suspend") == 0)
    1.58  		shutting_down = SHUTDOWN_SUSPEND;
    1.59  	else if (strcmp(str, "halt") == 0)
    1.60 @@ -391,8 +378,6 @@ static struct xenbus_watch sysrq_watch =
    1.61  };
    1.62  #endif
    1.63  
    1.64 -static struct notifier_block xenstore_notifier;
    1.65 -
    1.66  static int setup_shutdown_watcher(struct notifier_block *notifier,
    1.67                                    unsigned long event,
    1.68                                    void *data)
    1.69 @@ -420,11 +405,10 @@ static int setup_shutdown_watcher(struct
    1.70  
    1.71  static int __init setup_shutdown_event(void)
    1.72  {
    1.73 -
    1.74 -	xenstore_notifier.notifier_call = setup_shutdown_watcher;
    1.75 -
    1.76 +	static struct notifier_block xenstore_notifier = {
    1.77 +		.notifier_call = setup_shutdown_watcher
    1.78 +	};
    1.79  	register_xenstore_notifier(&xenstore_notifier);
    1.80 -
    1.81  	return 0;
    1.82  }
    1.83