kern_shutdown.c (65394) | kern_shutdown.c (65395) |
---|---|
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 * $FreeBSD: head/sys/kern/kern_shutdown.c 65394 2000-09-03 06:35:04Z peter $ | 39 * $FreeBSD: head/sys/kern/kern_shutdown.c 65395 2000-09-03 06:44:53Z peter $ |
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> --- 54 unchanged lines hidden (view full) --- 102#endif /* HW_WDOG */ 103 104/* 105 * Variable panicstr contains argument to first call to panic; used as flag 106 * to indicate that the kernel has already called panic. 107 */ 108const char *panicstr; 109 | 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> --- 54 unchanged lines hidden (view full) --- 102#endif /* HW_WDOG */ 103 104/* 105 * Variable panicstr contains argument to first call to panic; used as flag 106 * to indicate that the kernel has already called panic. 107 */ 108const char *panicstr; 109 |
110static void boot __P((int)) __dead2; 111static void dumpsys __P((void)); 112static int setdumpdev __P((dev_t dev)); 113static void poweroff_wait __P((void *, int)); 114static void print_uptime __P((void)); 115static void shutdown_halt __P((void *junk, int howto)); 116static void shutdown_panic __P((void *junk, int howto)); 117static void shutdown_reset __P((void *junk, int howto)); | 110static void boot(int) __dead2; 111static void dumpsys(void); 112static void poweroff_wait(void *, int); 113static void shutdown_halt(void *junk, int howto); 114static void shutdown_panic(void *junk, int howto); 115static void shutdown_reset(void *junk, int howto); |
118 119/* register various local shutdown events */ 120static void 121shutdown_conf(void *unused) 122{ 123 EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL, SHUTDOWN_PRI_FIRST); 124 EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL, SHUTDOWN_PRI_LAST + 100); 125 EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL, SHUTDOWN_PRI_LAST + 100); 126 EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL, SHUTDOWN_PRI_LAST + 200); 127} 128 129SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) 130 131/* ARGSUSED */ 132 133/* 134 * The system call that results in a reboot 135 */ 136int | 116 117/* register various local shutdown events */ 118static void 119shutdown_conf(void *unused) 120{ 121 EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL, SHUTDOWN_PRI_FIRST); 122 EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL, SHUTDOWN_PRI_LAST + 100); 123 EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL, SHUTDOWN_PRI_LAST + 100); 124 EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL, SHUTDOWN_PRI_LAST + 200); 125} 126 127SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) 128 129/* ARGSUSED */ 130 131/* 132 * The system call that results in a reboot 133 */ 134int |
137reboot(p, uap) 138 struct proc *p; 139 struct reboot_args *uap; | 135reboot(struct proc *p, struct reboot_args *uap) |
140{ 141 int error; 142 143 if ((error = suser(p))) 144 return (error); 145 146 boot(uap->opt); 147 return (0); --- 17 unchanged lines hidden (view full) --- 165 boot(RB_NOSYNC); 166 } 167 return; 168} 169static int waittime = -1; 170static struct pcb dumppcb; 171 172static void | 136{ 137 int error; 138 139 if ((error = suser(p))) 140 return (error); 141 142 boot(uap->opt); 143 return (0); --- 17 unchanged lines hidden (view full) --- 161 boot(RB_NOSYNC); 162 } 163 return; 164} 165static int waittime = -1; 166static struct pcb dumppcb; 167 168static void |
173print_uptime() | 169print_uptime(void) |
174{ 175 int f; 176 struct timespec ts; 177 178 getnanouptime(&ts); 179 printf("Uptime: "); 180 f = 0; 181 if (ts.tv_sec >= 86400) { --- 15 unchanged lines hidden (view full) --- 197} 198 199/* 200 * Go through the rigmarole of shutting down.. 201 * this used to be in machdep.c but I'll be dammned if I could see 202 * anything machine dependant in it. 203 */ 204static void | 170{ 171 int f; 172 struct timespec ts; 173 174 getnanouptime(&ts); 175 printf("Uptime: "); 176 f = 0; 177 if (ts.tv_sec >= 86400) { --- 15 unchanged lines hidden (view full) --- 193} 194 195/* 196 * Go through the rigmarole of shutting down.. 197 * this used to be in machdep.c but I'll be dammned if I could see 198 * anything machine dependant in it. 199 */ 200static void |
205boot(howto) 206 int howto; | 201boot(int howto) |
207{ 208 209 /* collect extra flags that shutdown_nice might have set */ 210 howto |= shutdown_howto; 211 212#ifdef SMP | 202{ 203 204 /* collect extra flags that shutdown_nice might have set */ 205 howto |= shutdown_howto; 206 207#ifdef SMP |
213 if (smp_active) { | 208 if (smp_active) |
214 printf("boot() called on cpu#%d\n", cpuid); | 209 printf("boot() called on cpu#%d\n", cpuid); |
215 } | |
216#endif 217 /* 218 * Do any callouts that should be done BEFORE syncing the filesystems. 219 */ 220 EVENTHANDLER_INVOKE(shutdown_pre_sync, howto); 221 222 /* 223 * Now sync filesystems --- 168 unchanged lines hidden (view full) --- 392static int dumpsize = 0; /* also for savecore */ 393 394static int dodump = 1; 395 396SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW, &dodump, 0, 397 "Try to perform coredump on kernel panic"); 398 399static int | 210#endif 211 /* 212 * Do any callouts that should be done BEFORE syncing the filesystems. 213 */ 214 EVENTHANDLER_INVOKE(shutdown_pre_sync, howto); 215 216 /* 217 * Now sync filesystems --- 168 unchanged lines hidden (view full) --- 386static int dumpsize = 0; /* also for savecore */ 387 388static int dodump = 1; 389 390SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW, &dodump, 0, 391 "Try to perform coredump on kernel panic"); 392 393static int |
400setdumpdev(dev) 401 dev_t dev; | 394setdumpdev(dev_t dev) |
402{ 403 int psize; 404 long newdumplo; 405 406 if (dev == NODEV) { 407 dumpdev = dev; 408 return (0); 409 } --- 12 unchanged lines hidden (view full) --- 422 return (ENOSPC); 423 dumpdev = dev; 424 dumplo = newdumplo; 425 return (0); 426} 427 428 429/* ARGSUSED */ | 395{ 396 int psize; 397 long newdumplo; 398 399 if (dev == NODEV) { 400 dumpdev = dev; 401 return (0); 402 } --- 12 unchanged lines hidden (view full) --- 415 return (ENOSPC); 416 dumpdev = dev; 417 dumplo = newdumplo; 418 return (0); 419} 420 421 422/* ARGSUSED */ |
430static void dump_conf __P((void *dummy)); | |
431static void | 423static void |
432dump_conf(dummy) 433 void *dummy; | 424dump_conf(void *dummy) |
434{ 435 if (setdumpdev(dumpdev) != 0) 436 dumpdev = NODEV; 437} 438 439SYSINIT(dump_conf, SI_SUB_DUMP_CONF, SI_ORDER_FIRST, dump_conf, NULL) 440 441static int --- 169 unchanged lines hidden --- | 425{ 426 if (setdumpdev(dumpdev) != 0) 427 dumpdev = NODEV; 428} 429 430SYSINIT(dump_conf, SI_SUB_DUMP_CONF, SI_ORDER_FIRST, dump_conf, NULL) 431 432static int --- 169 unchanged lines hidden --- |