shutdown_notify_reg Kernel Service

Purpose

Allows kernel extensions to register a shutdown notification.

Syntax

#include <sys/reboot.h>

int shutdown_notify_reg(sn)
shutdown_notify_t *sn;

typedef struct _shutdown_notify {
	struct _shutdown_notify *next;		/* Next in the link-list */
	int			version; 	/* Version of structure */
	int			oper;		   /* Bit map of the operation being performed */
	int			status;		/* The current status of this notify */
	uchar			cb_retry;	/* Internal use */
	uchar			scope;		/* Partition or system wide */
	uchar			reason;		/* User initiated or EPOW */
	uchar			padding;	   /* padding */
	long 			(*func)();	/* Function kernel calls to notify ext. */
	void 			*uaddr;		
/* Address to help extension identify the object this structure refers to */
} shutdown_notify_t;

/* Valid values 
for shutdown_notify_t->oper */
#define SHUTDOWN_NOTIFY_PREPARE	0x1	/* Shutdown has started */
#define SHUTDOWN_NOTIFY_REBOOT	0x2	/* 
Final notify that shutdown will be a reboot */
#define SHUTDOWN_NOTIFY_HALT	0x4	   
/* Final notify that shutdown will be a halt */
#define SHUTDOWN_NOTIFY_QUERY	0x8	
/* Check to see if finished shutdown */

/* Valid values for 
shutdown_notify_t->status and 
for SHUTDOWN_NOTIFY_QUERY return code */
#define SHUTDOWN_STATUS_PREPARE		0x1	/* Preparing for shutdown */
#define SHUTDOWN_STATUS_COMMENCE 	0x2	/* Commencing shutdown */
#define SHUTDOWN_STATUS_FINISH		0x4	/* Finished shutdown */

#define SHUTDOWN_NOTIFY_VERSION		1   /* Increment by 1
						     * every time add more
						     * variables to
						     * shutdown_notify_t
						     */
/* Valid values for shutdown_notify_t->scope */
#define		SHUTDOWN_SCOPE_PARTITION	1
#define		SHUTDOWN_SCOPE_SYSTEM		2

/* Valid values for shutdown_notify_t->reason */
#define		SHUTDOWN_REASON_USER		1
#define		SHUTDOWN_REASON_EPOW		2

/* Valid handler return codes 
during the SHUTDOWN_NOTIFY_PREPARE phase */
#define		SHUTDOWN_RC_SUCCESS		   0
#define		SHUTDOWN_RC_DELAY			1

#define   SHUTDOWN_NOTIFY_VERSION		2

Description

The shutdown notify subsystem has been extended to provide additional information during a shutdown operation. During the SHUTDOWN_NOTIFY_PREPARE phase, the kernel provides information on the scope and reason for the shutdown action. Additionally, when a handler is called, before its completion, it can now delay the shutdown operation in order to finalize any outstanding jobs. The kernel again then calls out to the handler after some small amount of time. This process continues until all handlers return SHUTDOWN_RC_SUCCESS. This functionality is only present for shutdown_notify_t version 2 and preceding handlers. For version 1 handlers, the new fields are not present and the return code from the handler is ignored.

Parameters

Item Description
cb_retry Internal use.
func Pointer to the function called to notify registered extension.
next Pointer to next shutdown_notify_t structure in list.
oper Bit map of operation(s) being performed.
padding Padding.
reason User initiated or EPOW event.
scope Shutdown at the partition or system level.
sn Pointer to a structure that the calling extension fills out when it registers.
status Current status of notify.
uaddr Place for extension to store an address to help it identify the object to which this structure refers.
version Version of structure. Set to 1.
SHUTDOWN_NOTIFY_HALT A halt is occurring.
SHUTDOWN_NOTIFY_PREPARE Shutdown has started.
SHUTDOWN_NOTIFY_QUERY Check to see if finished shutdown.
SHUTDOWN_NOTIFY_REBOOT A reboot is occurring.
SHUTDOWN_NOTIFY_VERSION Version number of structure.
SHUTDOWN_RC_DELAY Return from registered handler to indicate its processing is not complete and wants to delay the shutdown operation.
SHUTDOWN_RC_SUCCESS Return from registered handler to indicate all processing is complete and the shutdown operation can proceed.
SHUTDOWN_REASON_EPOW EPOW event.
SHUTDOWN_REASON_USER User initiated shutdown.
SHUTDOWN_SCOPE_PARTITION Shutdown at the partition level.
SHUTDOWN_SCOPE_SYSTEM Shutdown at the system level.
SHUTDOWN_STATUS_COMMENCE Wrap up shutdown.
SHUTDOWN_STATUS_FINISH Shutdown has completed.
SHUTDOWN_STATUS_PREPARE Preparing for shutdown.

Execution Environment

Process environment only.

Return Values

Item Description
0 Success.
EPERM Attempted to register after prepare notification has started.
EINVAL Invalid argument passed.