Index: kern_subr.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_subr.c,v retrieving revision 1.156 diff -u -r1.156 kern_subr.c --- kern_subr.c 8 Mar 2007 21:25:27 -0000 1.156 +++ kern_subr.c 17 Mar 2007 01:27:58 -0000 @@ -510,18 +510,48 @@ * it won't be run again. */ -static hook_list_t shutdownhook_list; +struct shutdownhook_desc { + LIST_ENTRY(shutdownhook_desc) shk_list; + void (*shk_fn)(int, void *); + void *shk_arg; +}; + +static LIST_HEAD(, shutdownhook_desc) shutdownhook_list = + LIST_HEAD_INITIALIZER(shutdownhook_list); void * -shutdownhook_establish(void (*fn)(void *), void *arg) +shutdownhook_establish(void (*fn)(int, void *), void *arg) { - return hook_establish(&shutdownhook_list, fn, arg); + struct shutdownhook_desc *hd; + + hd = malloc(sizeof(*hd), M_DEVBUF, M_NOWAIT); + if (hd == NULL) + return (NULL); + + hd->shk_fn = fn; + hd->shk_arg = arg; + LIST_INSERT_HEAD(&shutdownhook_list, hd, shk_list); + + return (hd); } void shutdownhook_disestablish(void *vhook) { - hook_disestablish(&shutdownhook_list, vhook); +#ifdef DIAGNOSTIC + struct shutdownhook_desc *hd; + + LIST_FOREACH(hd, &shutdownhook_list, shk_list) { + if (hd == vhook) + break; + } + + if (hd == NULL) + panic("hook_disestablish: hook %p not established", vhook); +#endif + LIST_REMOVE((struct shutdownhook_desc *)vhook, shk_list); + free(vhook, M_DEVBUF); + } /* @@ -533,13 +563,12 @@ * it won't be run again. */ void -doshutdownhooks(void) +doshutdownhooks(int howto) { - struct hook_desc *dp; + struct shutdownhook_desc *dp; - while ((dp = LIST_FIRST(&shutdownhook_list)) != NULL) { - LIST_REMOVE(dp, hk_list); - (*dp->hk_fn)(dp->hk_arg); + LIST_FOREACH(dp, &shutdownhook_list, shk_list) { + (*dp->shk_fn)(howto, dp->shk_arg); #if 0 /* * Don't bother freeing the hook structure,, since we may