summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruebayasi <uebayasi@openbsd.org>2014-07-11 14:36:44 +0000
committeruebayasi <uebayasi@openbsd.org>2014-07-11 14:36:44 +0000
commitfed31332d572142068f1121a8c2c931f196f0500 (patch)
treec2ad998d8c091a94497a8543111bbbcef2dbba5b
parentRemove redundant check and wrong fix: fat.c checks already take care (diff)
downloadwireguard-openbsd-fed31332d572142068f1121a8c2c931f196f0500.tar.xz
wireguard-openbsd-fed31332d572142068f1121a8c2c931f196f0500.zip
reboot(9): Add MI reboot entry function
Now, for kernel to "reboot" (reboot, halt, or shutdown), MD boot(9) is called in some places. This change introduces a new MI function reboot(9) which is simply a wrapper to call MD boot(9). OK kettenis@ deraadt@
-rw-r--r--sys/ddb/db_command.c14
-rw-r--r--sys/kern/kern_xxx.c14
-rw-r--r--sys/kern/subr_disk.c6
-rw-r--r--sys/kern/subr_prf.c5
-rw-r--r--sys/sys/reboot.h3
5 files changed, 27 insertions, 15 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 32449fc6163..8c1c5945331 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_command.c,v 1.63 2013/12/01 16:40:56 krw Exp $ */
+/* $OpenBSD: db_command.c,v 1.64 2014/07/11 14:36:44 uebayasi Exp $ */
/* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */
/*
@@ -722,37 +722,37 @@ db_fncall(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
void
db_boot_sync_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_AUTOBOOT | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_AUTOBOOT | RB_TIMEBAD | RB_USERREQ);
}
void
db_boot_crash_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_NOSYNC | RB_DUMP | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_NOSYNC | RB_DUMP | RB_TIMEBAD | RB_USERREQ);
}
void
db_boot_dump_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_DUMP | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_DUMP | RB_TIMEBAD | RB_USERREQ);
}
void
db_boot_halt_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_NOSYNC | RB_HALT | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_NOSYNC | RB_HALT | RB_TIMEBAD | RB_USERREQ);
}
void
db_boot_reboot_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_AUTOBOOT | RB_NOSYNC | RB_TIMEBAD | RB_USERREQ);
}
void
db_boot_poweroff_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
- boot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
+ reboot(RB_NOSYNC | RB_HALT | RB_POWERDOWN | RB_TIMEBAD | RB_USERREQ);
}
void
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 2f54a2e708b..28645e74657 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_xxx.c,v 1.25 2014/07/08 17:19:25 deraadt Exp $ */
+/* $OpenBSD: kern_xxx.c,v 1.26 2014/07/11 14:36:44 uebayasi Exp $ */
/* $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $ */
/*
@@ -59,10 +59,20 @@ sys_reboot(struct proc *p, void *v, register_t *retval)
sched_stop_secondary_cpus();
KASSERT(CPU_IS_PRIMARY(curcpu()));
#endif
- boot(SCARG(uap, opt));
+ reboot(SCARG(uap, opt));
+ /* NOTREACHED */
return (0);
}
+__dead void
+reboot(int howto)
+{
+ KASSERT((howto & RB_NOSYNC) || curproc != NULL);
+
+ boot(howto);
+ /* NOTREACHED */
+}
+
#if !defined(NO_PROPOLICE)
void __stack_smash_handler(char [], int __attribute__((unused)));
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 06d0723cb40..28d94942358 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.164 2014/07/02 09:59:43 dlg Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.165 2014/07/11 14:36:44 uebayasi Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -1163,7 +1163,7 @@ setroot(struct device *bootdv, int part, int exitflags)
cnpollc(FALSE);
splx(s);
if (strcmp(buf, "exit") == 0)
- boot(exitflags);
+ reboot(exitflags);
if (len == 0 && bootdv != NULL) {
strlcpy(buf, bootdv->dv_xname, sizeof buf);
len = strlen(buf);
@@ -1200,7 +1200,7 @@ setroot(struct device *bootdv, int part, int exitflags)
cnpollc(FALSE);
splx(s);
if (strcmp(buf, "exit") == 0)
- boot(exitflags);
+ reboot(exitflags);
if (len == 0 && rootdv != NULL) {
switch (rootdv->dv_class) {
case DV_IFNET:
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 7336d268f60..ed134d1fe3a 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.81 2013/12/12 21:00:09 guenther Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.82 2014/07/11 14:36:44 uebayasi Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -217,7 +217,8 @@ panic(const char *fmt, ...)
else
db_stack_dump();
#endif
- boot(bootopt);
+ reboot(bootopt);
+ /* NOTREACHED */
}
/*
diff --git a/sys/sys/reboot.h b/sys/sys/reboot.h
index 3b6ad8666c5..f82d87a8e9d 100644
--- a/sys/sys/reboot.h
+++ b/sys/sys/reboot.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: reboot.h,v 1.16 2014/07/11 07:57:58 deraadt Exp $ */
+/* $OpenBSD: reboot.h,v 1.17 2014/07/11 14:36:44 uebayasi Exp $ */
/* $NetBSD: reboot.h,v 1.9 1996/04/22 01:23:25 christos Exp $ */
/*
@@ -96,6 +96,7 @@
#if defined(_KERNEL) && !defined(_STANDALONE) && !defined(_LOCORE)
__BEGIN_DECLS
+__dead void reboot(int);
__dead void boot(int);
__END_DECLS