Deleted Added
full compact
kern_shutdown.c (213648) kern_shutdown.c (214004)
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.

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

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
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.

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

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 213648 2010-10-09 08:07:49Z avg $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 214004 2010-10-18 04:30:27Z marcel $");
39
40#include "opt_ddb.h"
41#include "opt_kdb.h"
42#include "opt_panic.h"
43#include "opt_show_busybufs.h"
44#include "opt_sched.h"
45
46#include <sys/param.h>

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

128int dumping; /* system is dumping */
129int rebooting; /* system is rebooting */
130static struct dumperinfo dumper; /* our selected dumper */
131
132/* Context information for dump-debuggers. */
133static struct pcb dumppcb; /* Registers. */
134static lwpid_t dumptid; /* Thread ID. */
135
39
40#include "opt_ddb.h"
41#include "opt_kdb.h"
42#include "opt_panic.h"
43#include "opt_show_busybufs.h"
44#include "opt_sched.h"
45
46#include <sys/param.h>

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

128int dumping; /* system is dumping */
129int rebooting; /* system is rebooting */
130static struct dumperinfo dumper; /* our selected dumper */
131
132/* Context information for dump-debuggers. */
133static struct pcb dumppcb; /* Registers. */
134static lwpid_t dumptid; /* Thread ID. */
135
136static void boot(int) __dead2;
137static void poweroff_wait(void *, int);
138static void shutdown_halt(void *junk, int howto);
139static void shutdown_panic(void *junk, int howto);
140static void shutdown_reset(void *junk, int howto);
141
142/* register various local shutdown events */
143static void
144shutdown_conf(void *unused)

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

168 error = 0;
169#ifdef MAC
170 error = mac_system_check_reboot(td->td_ucred, uap->opt);
171#endif
172 if (error == 0)
173 error = priv_check(td, PRIV_REBOOT);
174 if (error == 0) {
175 mtx_lock(&Giant);
136static void poweroff_wait(void *, int);
137static void shutdown_halt(void *junk, int howto);
138static void shutdown_panic(void *junk, int howto);
139static void shutdown_reset(void *junk, int howto);
140
141/* register various local shutdown events */
142static void
143shutdown_conf(void *unused)

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

167 error = 0;
168#ifdef MAC
169 error = mac_system_check_reboot(td->td_ucred, uap->opt);
170#endif
171 if (error == 0)
172 error = priv_check(td, PRIV_REBOOT);
173 if (error == 0) {
174 mtx_lock(&Giant);
176 boot(uap->opt);
175 kern_reboot(uap->opt);
177 mtx_unlock(&Giant);
178 }
179 return (error);
180}
181
182/*
183 * Called by events that want to shut down.. e.g <CTL><ALT><DEL> on a PC
184 */

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

192
193 /* Send a signal to init(8) and have it shutdown the world */
194 if (initproc != NULL) {
195 PROC_LOCK(initproc);
196 psignal(initproc, SIGINT);
197 PROC_UNLOCK(initproc);
198 } else {
199 /* No init(8) running, so simply reboot */
176 mtx_unlock(&Giant);
177 }
178 return (error);
179}
180
181/*
182 * Called by events that want to shut down.. e.g <CTL><ALT><DEL> on a PC
183 */

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

191
192 /* Send a signal to init(8) and have it shutdown the world */
193 if (initproc != NULL) {
194 PROC_LOCK(initproc);
195 psignal(initproc, SIGINT);
196 PROC_UNLOCK(initproc);
197 } else {
198 /* No init(8) running, so simply reboot */
200 boot(RB_NOSYNC);
199 kern_reboot(RB_NOSYNC);
201 }
202 return;
203}
204static int waittime = -1;
205
206static void
207print_uptime(void)
208{

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

264 ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI))
265 return (1);
266 return (0);
267}
268
269/*
270 * Shutdown the system cleanly to prepare for reboot, halt, or power off.
271 */
200 }
201 return;
202}
203static int waittime = -1;
204
205static void
206print_uptime(void)
207{

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

263 ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI))
264 return (1);
265 return (0);
266}
267
268/*
269 * Shutdown the system cleanly to prepare for reboot, halt, or power off.
270 */
272static void
273boot(int howto)
271void
272kern_reboot(int howto)
274{
275 static int first_buf_printf = 1;
276
277#if defined(SMP)
278 /*
279 * Bind us to CPU 0 so that all shutdown code runs there. Some
280 * systems don't shutdown properly (i.e., ACPI power off) if we
281 * run on another processor.
282 */
283 thread_lock(curthread);
284 sched_bind(curthread, 0);
285 thread_unlock(curthread);
273{
274 static int first_buf_printf = 1;
275
276#if defined(SMP)
277 /*
278 * Bind us to CPU 0 so that all shutdown code runs there. Some
279 * systems don't shutdown properly (i.e., ACPI power off) if we
280 * run on another processor.
281 */
282 thread_lock(curthread);
283 sched_bind(curthread, 0);
284 thread_unlock(curthread);
286 KASSERT(PCPU_GET(cpuid) == 0, ("boot: not running on cpu 0"));
285 KASSERT(PCPU_GET(cpuid) == 0, ("%s: not running on cpu 0", __func__));
287#endif
288 /* We're in the process of rebooting. */
289 rebooting = 1;
290
291 /* collect extra flags that shutdown_nice might have set */
292 howto |= shutdown_howto;
293
294 /* We are out of the debugger now. */

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

584#endif
585#endif
586 /*thread_lock(td); */
587 td->td_flags |= TDF_INPANIC;
588 /* thread_unlock(td); */
589 if (!sync_on_panic)
590 bootopt |= RB_NOSYNC;
591 critical_exit();
286#endif
287 /* We're in the process of rebooting. */
288 rebooting = 1;
289
290 /* collect extra flags that shutdown_nice might have set */
291 howto |= shutdown_howto;
292
293 /* We are out of the debugger now. */

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

583#endif
584#endif
585 /*thread_lock(td); */
586 td->td_flags |= TDF_INPANIC;
587 /* thread_unlock(td); */
588 if (!sync_on_panic)
589 bootopt |= RB_NOSYNC;
590 critical_exit();
592 boot(bootopt);
591 kern_reboot(bootopt);
593}
594
595/*
596 * Support for poweroff delay.
597 *
598 * Please note that setting this delay too short might power off your machine
599 * before the write cache on your hard disk has been flushed, leading to
600 * soft-updates inconsistencies.

--- 117 unchanged lines hidden ---
592}
593
594/*
595 * Support for poweroff delay.
596 *
597 * Please note that setting this delay too short might power off your machine
598 * before the write cache on your hard disk has been flushed, leading to
599 * soft-updates inconsistencies.

--- 117 unchanged lines hidden ---