diff options
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r-- | usr.sbin/apmd/apm-proto.h | 6 | ||||
-rw-r--r-- | usr.sbin/apmd/apmd.c | 18 | ||||
-rw-r--r-- | usr.sbin/apmd/pathnames.h | 3 |
3 files changed, 23 insertions, 4 deletions
diff --git a/usr.sbin/apmd/apm-proto.h b/usr.sbin/apmd/apm-proto.h index fee1405b72c..0d5716eb1a0 100644 --- a/usr.sbin/apmd/apm-proto.h +++ b/usr.sbin/apmd/apm-proto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apm-proto.h,v 1.8 2006/03/15 20:30:28 sturm Exp $ */ +/* $OpenBSD: apm-proto.h,v 1.9 2012/03/26 20:17:45 deraadt Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -33,6 +33,7 @@ enum apm_action { NONE, SUSPEND, STANDBY, + HIBERNATE, GETSTATUS, SETPERF_LOW, SETPERF_HIGH, @@ -43,7 +44,8 @@ enum apm_action { enum apm_state { NORMAL, SUSPENDING, - STANDING_BY + STANDING_BY, + HIBERNATING }; enum apm_perfmode { diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 5a65d9702c7..6ddb2cfbfd3 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.57 2011/04/21 06:45:04 jasper Exp $ */ +/* $OpenBSD: apmd.c,v 1.58 2012/03/26 20:17:45 deraadt Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -79,6 +79,7 @@ int get_avg_idle_up(void); void perf_status(struct apm_power_info *pinfo, int ncpu); void suspend(int ctl_fd); void stand_by(int ctl_fd); +void hibernate(int ctl_fd); void setperf(int new_perf); void sigexit(int signo); void do_etc_file(const char *file); @@ -429,6 +430,9 @@ handle_client(int sock_fd, int ctl_fd) case STANDBY: reply.newstate = STANDING_BY; break; + case HIBERNATE: + reply.newstate = HIBERNATING; + break; case SETPERF_LOW: doperf = PERF_MANUAL; reply.newstate = NORMAL; @@ -487,6 +491,15 @@ stand_by(int ctl_fd) ioctl(ctl_fd, APM_IOC_STANDBY, 0); } +void +hibernate(int ctl_fd) +{ + do_etc_file(_PATH_APM_ETC_HIBERNATE); + sync(); + sleep(1); + ioctl(ctl_fd, APM_IOC_HIBERNATE, 0); +} + #define TIMO (10*60) /* 10 minutes */ int @@ -721,6 +734,9 @@ main(int argc, char *argv[]) case STANDING_BY: stand_by(ctl_fd); break; + case HIBERNATING: + hibernate(ctl_fd); + break; } } error("kevent loop", NULL); diff --git a/usr.sbin/apmd/pathnames.h b/usr.sbin/apmd/pathnames.h index 9f53af6b255..2503610404f 100644 --- a/usr.sbin/apmd/pathnames.h +++ b/usr.sbin/apmd/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.5 2005/06/14 15:18:53 deraadt Exp $ */ +/* $OpenBSD: pathnames.h,v 1.6 2012/03/26 20:17:45 deraadt Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -34,6 +34,7 @@ #define _PATH_APM_ETC_DIR "/etc/apm" #define _PATH_APM_ETC_SUSPEND _PATH_APM_ETC_DIR"/suspend" #define _PATH_APM_ETC_STANDBY _PATH_APM_ETC_DIR"/standby" +#define _PATH_APM_ETC_HIBERNATE _PATH_APM_ETC_DIR"/hibernate" #define _PATH_APM_ETC_RESUME _PATH_APM_ETC_DIR"/resume" #define _PATH_APM_ETC_POWERUP _PATH_APM_ETC_DIR"/powerup" #define _PATH_APM_ETC_POWERDOWN _PATH_APM_ETC_DIR"/powerdown" |