summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2012-03-29 06:57:03 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2012-03-29 06:57:03 +0000
commit6f6fa882d157fe614488c64e49b56e9f526eebc2 (patch)
tree9c9ddd5a3617c71e7475cad7e1d05b9cbb72bbf6
parentf6d5022ffdbe4bdcfd0a5c102ecea11c5eb73007 (diff)
Prevent hibernation attempts on machines with unsupported disk controllers.
The same check is also performed later in the hibernate sequence, but by then it's too late to cleanly unwind (presently). ok deraadt
-rw-r--r--sys/dev/acpi/acpi.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index f4f7424e525..d471cf387f6 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.230 2012/03/26 20:32:50 deraadt Exp $ */
+/* $OpenBSD: acpi.c,v 1.231 2012/03/29 06:57:02 mlarkin Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -30,6 +30,7 @@
#include <sys/workq.h>
#include <sys/sched.h>
#include <sys/reboot.h>
+#include <sys/hibernate.h>
#include <machine/conf.h>
#include <machine/cpufunc.h>
@@ -2518,8 +2519,13 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
if ((flag & FWRITE) == 0) {
error = EBADF;
} else {
- acpi_addtask(sc, acpi_sleep_task, sc, ACPI_STATE_S4);
- acpi_wakeup(sc);
+ if (get_hibernate_io_function() == NULL) {
+ error = EOPNOTSUPP;
+ } else {
+ acpi_addtask(sc, acpi_sleep_task, sc,
+ ACPI_STATE_S4);
+ acpi_wakeup(sc);
+ }
}
break;
#endif