From owner-freebsd-bugs Mon Jul 12 18: 1:33 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 441051509A for ; Mon, 12 Jul 1999 18:01:27 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id SAA90602; Mon, 12 Jul 1999 18:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from not.there.com (mg131-151.ricochet.net [204.179.131.151]) by hub.freebsd.org (Postfix) with ESMTP id 2DC7F15256 for ; Mon, 12 Jul 1999 17:52:44 -0700 (PDT) (envelope-from mconst@not.there.com) Received: (from mconst@localhost) by not.there.com (8.9.3/8.9.3) id RAA01409; Mon, 12 Jul 1999 17:40:25 -0700 (PDT) (envelope-from mconst) Message-Id: <199907130040.RAA01409@not.there.com> Date: Mon, 12 Jul 1999 17:40:25 -0700 (PDT) From: Michael Constant Reply-To: mconst@csua.berkeley.edu To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/12614: [patch] apm -r doesn't respect wall_cmos_clock Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 +#include #include #include #include @@ -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