Date: Mon, 12 Jul 1999 17:40:25 -0700 (PDT) From: Michael Constant <mconst@csua.berkeley.edu> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/12614: [patch] apm -r doesn't respect wall_cmos_clock Message-ID: <199907130040.RAA01409@not.there.com>
index | next in thread | raw e-mail
>Number: 12614
>Category: bin
>Synopsis: [patch] apm -r doesn't respect wall_cmos_clock
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 12 18:00:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: Michael Constant
>Release: FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:
Thinkpad 570 running 4.0-CURRENT, last updated July 11, 1999.
>Description:
apm -r sets the machine to wake up from suspend mode after the specified
number of seconds. However, it always calculates the time to wake up in
UTC, even if the machine's CMOS clock uses wall time. The effect is that
apm -r will wake up your machine either several hours too late (if you're
west of Greenwich) or not at all (if you're east).
/usr/src/usr.sbin/apm/apm.c includes code to correctly set the wakeup
time on wall_cmos_clock machines, controlled by the variable "cmos_wall".
It never actually sets that variable, though, so it always uses the code
path for UTC CMOS clock machines. I've included a patch for apm below.
>How-To-Repeat:
$ ls -l /etc/wall_cmos_clock
-rw-r--r-- 1 root wheel 0 Jun 19 19:45 /etc/wall_cmos_clock
$ apm
APM version: 1.2
APM Managment: Enabled
AC Line status: on-line
Battery status: charging
Remaining battery life: 92%
Remaining battery time: unknown
Number of batteries: 2
Resume timer: disabled
Resume on ring indicator: disabled
APM Capacities:
global standby state
global suspend state
resume timer from suspend
$ apm -r30
$ zzz
The machine suspends, but does not resume 30 seconds later.
>Fix:
The following patch fixes the problem.
Note: when testing apm (with or without this patch), do not trust the
"Resume timer:" line it sometimes outputs. That's also broken, and I've
submitted a patch for it as a separate PR.
--- /usr/src/usr.sbin/apm/apm.c.orig Fri Sep 4 09:08:54 1998
+++ /usr/src/usr.sbin/apm/apm.c Sat Jul 10 22:22:57 1999
@@ -18,6 +18,8 @@
"$Id: apm.c,v 1.14 1998/09/04 16:08:54 imp Exp $";
#endif /* not lint */
+#include <sys/types.h>
+#include <sys/sysctl.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -288,7 +290,12 @@
int display = 0, batt_life = 0, ac_status = 0, standby = 0;
int batt_time = 0, delta = 0;
char *cmdname;
+ size_t cmos_wall_len;
+ cmos_wall_len = sizeof cmos_wall;
+ if (sysctlbyname("machdep.wall_cmos_clock", &cmos_wall, &cmos_wall_len,
+ NULL, 0) == -1)
+ err(1, "sysctlbyname machdep.wall_cmos_clock");
if ((cmdname = strrchr(argv[0], '/')) != NULL)
cmdname++;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907130040.RAA01409>
