Deleted Added
full compact
kern_shutdown.c (42135) kern_shutdown.c (43436)
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
39 * $Id: kern_shutdown.c,v 1.43 1998/12/04 22:54:51 archie Exp $
39 * $Id: kern_shutdown.c,v 1.44 1998/12/28 23:03:00 msmith Exp $
40 */
41
42#include "opt_ddb.h"
43#include "opt_hw_wdog.h"
44#include "opt_panic.h"
45#include "opt_show_busybufs.h"
46
47#include <sys/param.h>

--- 35 unchanged lines hidden (view full) ---

83int debugger_on_panic = 0;
84#else
85int debugger_on_panic = 1;
86#endif
87SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
88 &debugger_on_panic, 0, "");
89#endif
90
40 */
41
42#include "opt_ddb.h"
43#include "opt_hw_wdog.h"
44#include "opt_panic.h"
45#include "opt_show_busybufs.h"
46
47#include <sys/param.h>

--- 35 unchanged lines hidden (view full) ---

83int debugger_on_panic = 0;
84#else
85int debugger_on_panic = 1;
86#endif
87SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
88 &debugger_on_panic, 0, "");
89#endif
90
91SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment");
92
91#ifdef HW_WDOG
92/*
93 * If there is a hardware watchdog, point this at the function needed to
94 * hold it off.
95 * It's needed when the kernel needs to do some lengthy operations.
96 * e.g. in wd.c when dumping core.. It's most annoying to have
97 * your precious core-dump only half written because the wdog kicked in.
98 */

--- 366 unchanged lines hidden (view full) ---

465 * at_shutdown_pri():
466 * Take the arguments given and put them onto the shutdown callout list
467 * with the given execution priority.
468 * returns 0 on success.
469 */
470int
471at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
472{
93#ifdef HW_WDOG
94/*
95 * If there is a hardware watchdog, point this at the function needed to
96 * hold it off.
97 * It's needed when the kernel needs to do some lengthy operations.
98 * e.g. in wd.c when dumping core.. It's most annoying to have
99 * your precious core-dump only half written because the wdog kicked in.
100 */

--- 366 unchanged lines hidden (view full) ---

467 * at_shutdown_pri():
468 * Take the arguments given and put them onto the shutdown callout list
469 * with the given execution priority.
470 * returns 0 on success.
471 */
472int
473at_shutdown_pri(bootlist_fn function, void *arg, int queue, int pri)
474{
473 sle_p ep, ip;
475 sle_p op, ep, ip;
474
475 if (queue < SHUTDOWN_PRE_SYNC
476 || queue > SHUTDOWN_FINAL) {
477 printf("at_shutdown: bad exit callout queue %d specified\n",
478 queue);
479 return (EINVAL);
480 }
481 if (rm_at_shutdown(function, arg))

--- 5 unchanged lines hidden (view full) ---

487 ep->arg = arg;
488 ep->priority = pri;
489
490 /* Sort into list of items on this queue */
491 ip = LIST_FIRST(&shutdown_lists[queue]);
492 if (ip == NULL) {
493 LIST_INSERT_HEAD(&shutdown_lists[queue], ep, links);
494 } else {
476
477 if (queue < SHUTDOWN_PRE_SYNC
478 || queue > SHUTDOWN_FINAL) {
479 printf("at_shutdown: bad exit callout queue %d specified\n",
480 queue);
481 return (EINVAL);
482 }
483 if (rm_at_shutdown(function, arg))

--- 5 unchanged lines hidden (view full) ---

489 ep->arg = arg;
490 ep->priority = pri;
491
492 /* Sort into list of items on this queue */
493 ip = LIST_FIRST(&shutdown_lists[queue]);
494 if (ip == NULL) {
495 LIST_INSERT_HEAD(&shutdown_lists[queue], ep, links);
496 } else {
495 for (; LIST_NEXT(ip, links) != NULL; ip = LIST_NEXT(ip, links)) {
497 for (; ip != NULL; op = ip, ip = LIST_NEXT(ip, links)) {
496 if (ep->priority < ip->priority) {
497 LIST_INSERT_BEFORE(ip, ep, links);
498 ep = NULL;
499 break;
500 }
501 }
502 if (ep != NULL)
498 if (ep->priority < ip->priority) {
499 LIST_INSERT_BEFORE(ip, ep, links);
500 ep = NULL;
501 break;
502 }
503 }
504 if (ep != NULL)
503 LIST_INSERT_AFTER(ip, ep, links);
505 LIST_INSERT_AFTER(op, ep, links);
504 }
505 return (0);
506}
507
508/*
509 * Scan the exit callout lists for the given items and remove them.
510 * Returns the number of items removed.
511 */

--- 11 unchanged lines hidden (view full) ---

523 LIST_REMOVE(ep, links);
524 free(ep, M_TEMP);
525 count++;
526 }
527 }
528 }
529 return (count);
530}
506 }
507 return (0);
508}
509
510/*
511 * Scan the exit callout lists for the given items and remove them.
512 * Returns the number of items removed.
513 */

--- 11 unchanged lines hidden (view full) ---

525 LIST_REMOVE(ep, links);
526 free(ep, M_TEMP);
527 count++;
528 }
529 }
530 }
531 return (count);
532}
533
534/*
535 * Support for poweroff delay.
536 */
537static int poweroff_delay = 0;
538SYSCTL_INT(_kern_shutdown, OID_AUTO, poweroff_delay, CTLFLAG_RW,
539 &poweroff_delay, 0, "");
540
541static void poweroff_wait(int howto, void *unused)
542{
543 if(!(howto & RB_POWEROFF) || poweroff_delay <= 0)
544 return;
545 DELAY(poweroff_delay * 1000);
546}
547
548/*
549 * XXX OK? This implies I know SHUTDOWN_PRI_LAST > SHUTDOWN_PRI_FIRST
550 */
551static void poweroff_conf(void *unused)
552{
553 at_shutdown_pri(poweroff_wait, NULL, SHUTDOWN_FINAL, SHUTDOWN_PRI_FIRST);
554}
555
556SYSINIT(poweroff_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, poweroff_conf, NULL)