OpenBSD CVS

CVS log for src/usr.sbin/apm/apm.c


[BACK] Up to [local] / src / usr.sbin / apm

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.43 / (download) - annotate - [select for diffs], Wed Nov 9 18:48:11 2022 UTC (18 months, 3 weeks ago) by mbuhl
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, HEAD
Changes since 1.42: +4 -2 lines
Diff to previous 1.42 (colored)

In do_zzz a garbage stack value could be accessed in case a read
or write in send_command failed.
Found by codechecker.
OK deraadt

Revision 1.42 / (download) - annotate - [select for diffs], Sat Sep 10 10:10:09 2022 UTC (20 months, 3 weeks ago) by sdk
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.41: +10 -3 lines
Diff to previous 1.41 (colored)

apm(1): Display unknown recharge time estimate instead of -1

OK miod@

Revision 1.41 / (download) - annotate - [select for diffs], Sun Feb 13 21:27:51 2022 UTC (2 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

- for -a, get the brackets right
- for -l and -m remove the brackets
- note that -m whilst charging now displays estimated recharge time
- A/C -> AC

from jan stary;
tweaked a little by myself

Revision 1.40 / (download) - annotate - [select for diffs], Sun Feb 6 09:07:42 2022 UTC (2 years, 3 months ago) by robert
Branch: MAIN
Changes since 1.39: +1 -5 lines
Diff to previous 1.39 (colored)

now that APM_BATT_CHARGING is also set in acpi and on some m1 devices
enable support for displaying an estimate recharge time in apm(d)

e.g:
Battery state: charging, 95% remaining, 11 minutes recharge time estimate
Battery state: charging, 97% remaining, 8 minutes recharge time estimate
Battery state: charging, 98% remaining, 6 minutes recharge time estimate
Battery state: charging, 99% remaining, 3 minutes recharge time estimate
Battery state: charging, 99% remaining, 1 minutes recharge time estimate
Battery state: charging, 99% remaining, 0 minutes recharge time estimate

ok jca@

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jan 12 13:09:29 2022 UTC (2 years, 4 months ago) by robert
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

set cpuspeed to 0 if hw.cpuspeed cannot be retrieved
ok kettenis@

Revision 1.38 / (download) - annotate - [select for diffs], Tue Apr 6 20:30:32 2021 UTC (3 years, 1 month ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.37: +8 -2 lines
Diff to previous 1.37 (colored)

Make apm(8) report apmd(8) failure

apm(8) never got the result of the requested power action carried out by
apmd(8), so apm(4) errors got silently discarded;  for example, zzz(8)
would merely print "Suspending system..." and exit zero on platforms
lacking suspend/resume support.

Enrich reply messages from apmd to apm with an error field containing the
failed ioctl(2)'s errno if need be.

Hoist apmd's power action dispatch into handle_client() so it can write the
error in the first place before replying.

OK dv

Revision 1.37 / (download) - annotate - [select for diffs], Wed Sep 23 05:50:26 2020 UTC (3 years, 8 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.36: +2 -7 lines
Diff to previous 1.36 (colored)

Zap code remnants of the "cool running mode" (removed in 2014)

Nowadays "auto" mode is used instead.  ok deraadt@

Revision 1.36 / (download) - annotate - [select for diffs], Fri Jun 28 13:32:46 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.35 / (download) - annotate - [select for diffs], Fri Mar 1 17:21:48 2019 UTC (5 years, 3 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.34: +5 -1 lines
Diff to previous 1.34 (colored)

usage if there's extra arguments. ok kn

Revision 1.34 / (download) - annotate - [select for diffs], Tue Aug 14 06:38:33 2018 UTC (5 years, 9 months ago) by mestre
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.33: +7 -3 lines
Diff to previous 1.33 (colored)

Drop unnecessary pledge(2) promises on apm(8):

After we successfully connect to the unix socket created by apmd(8) all actions
occur over fds so we can drop only to pledge("stdio").

The code path in the case that the required action is GETSTATUS, and we couldn't
connect to the socket, then after open(2)/ioctl(2) the device /dev/apm directly
we can pledge("stdio") as well since from here on down we only need to
printf(3) messages.

OK deraadt@

Revision 1.33 / (download) - annotate - [select for diffs], Sun Jul 23 12:51:20 2017 UTC (6 years, 10 months ago) by anton
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.32: +17 -15 lines
Diff to previous 1.32 (colored)

Cleanup apm:

- Zap trailing whitespace in license, noted by tb@
- Sort and align function prototypes
- Add static and __dead when appropriate in order to compile using `clang -Wall`
- Zap variable names from function prototypes, also noted by tb@
- Break long lines

ok tb@

Revision 1.32 / (download) - annotate - [select for diffs], Sun Nov 1 14:13:30 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.31: +6 -4 lines
Diff to previous 1.31 (colored)

only pledge if in doing-work-via-daemon mode

Revision 1.31 / (download) - annotate - [select for diffs], Wed Oct 28 12:25:13 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.30: +8 -5 lines
Diff to previous 1.30 (colored)

By hoisting sysctl hw.cpuspeed towards the top, it is possible to
pledge "stdio rpath wpath cpath unix".  I wonder what we can do in
apmd...

Revision 1.30 / (download) - annotate - [select for diffs], Sun Oct 11 20:23:49 2015 UTC (8 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.29: +3 -4 lines
Diff to previous 1.29 (colored)

Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept
sizeof(struct sockaddr_un), so do the simple, portable thing.
Also convert some strncpy() to strlcpy()

ok deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:15 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.28 / (download) - annotate - [select for diffs], Fri Oct 17 07:43:33 2014 UTC (9 years, 7 months ago) by jmc
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

remove -C from usage();

Revision 1.27 / (download) - annotate - [select for diffs], Wed Jul 11 13:27:13 2012 UTC (11 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.26: +6 -2 lines
Diff to previous 1.26 (colored)

improve messages for suspend/hibernate

Revision 1.26 / (download) - annotate - [select for diffs], Fri Mar 30 06:40:36 2012 UTC (12 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.25: +4 -4 lines
Diff to previous 1.25 (colored)

document ZZZ; ok deraadt

Revision 1.25 / (download) - annotate - [select for diffs], Mon Mar 26 20:17:43 2012 UTC (12 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.24: +20 -2 lines
Diff to previous 1.24 (colored)

Add hibernate request support.  Also installs a ZZZ binary for the
shortcut.
ok mlarkin miod

Revision 1.24 / (download) - annotate - [select for diffs], Fri Oct 30 19:41:10 2009 UTC (14 years, 7 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.23: +5 -2 lines
Diff to previous 1.23 (colored)

when used with incorrect flags, zzz(8) should call zzusage(void)
instead of usage(void).

millert@ suggested checking __progname() against "zzz" to match
existing code.

ok millert@

Revision 1.23 / (download) - annotate - [select for diffs], Sun Jun 11 17:45:54 2006 UTC (17 years, 11 months ago) by sturm
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.22: +3 -3 lines
Diff to previous 1.22 (colored)

change "apmd not running" to "cannot connect to apmd" in error message
as it could be a permission problem as well, pr 5151

ok deraadt

Revision 1.22 / (download) - annotate - [select for diffs], Wed May 10 17:36:12 2006 UTC (18 years ago) by mickey
Branch: MAIN
Changes since 1.21: +7 -3 lines
Diff to previous 1.21 (colored)

fail zzz w/ a reasonable error msg if apmd is not running; found by deraadt@

Revision 1.21 / (download) - annotate - [select for diffs], Wed Apr 12 19:41:08 2006 UTC (18 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.20: +28 -11 lines
Diff to previous 1.20 (colored)

If /dev/apm does not respond, use a fake (pre-built) response packet
that can be printed.  This makes apm(8) act the same whether talking
to apmd(8) or directly to a (potentially non-functioning) /dev/apm.
ok kettenis

Revision 1.20 / (download) - annotate - [select for diffs], Wed Mar 15 20:30:27 2006 UTC (18 years, 2 months ago) by sturm
Branch: MAIN
Changes since 1.19: +4 -4 lines
Diff to previous 1.19 (colored)

consistently use power *states* and performance *modes*

ok beck, mickey

Revision 1.19 / (download) - annotate - [select for diffs], Mon Mar 6 15:21:05 2006 UTC (18 years, 3 months ago) by mickey
Branch: MAIN
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

failure to connect to apmd socket -- get status from the /dev/apm directly

Revision 1.18 / (download) - annotate - [select for diffs], Sun Feb 26 17:59:07 2006 UTC (18 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (colored)

spacing; from ray lai
ok mickey

Revision 1.17 / (download) - annotate - [select for diffs], Sat Jan 28 17:08:13 2006 UTC (18 years, 4 months ago) by sturm
Branch: MAIN
Changes since 1.16: +42 -21 lines
Diff to previous 1.16 (colored)

be less verbose:
- status does not provide any information, remove it
- print battery status in one line
ok beck, drahn, i386 tested by bernd

Revision 1.16 / (download) - annotate - [select for diffs], Thu Jan 19 19:17:10 2006 UTC (18 years, 4 months ago) by sturm
Branch: MAIN
Changes since 1.15: +5 -5 lines
Diff to previous 1.15 (colored)

prompted by deraadt:
manual performance mode -> low/high performance mode
show cpuspeed in apm output

ok beck, weingart
man page bits ok jmc

Revision 1.15 / (download) - annotate - [select for diffs], Fri Dec 2 04:33:27 2005 UTC (18 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.14: +5 -5 lines
Diff to previous 1.14 (colored)

sync to usage in man page

Revision 1.14 / (download) - annotate - [select for diffs], Fri Dec 2 04:27:52 2005 UTC (18 years, 6 months ago) by beck
Branch: MAIN
Changes since 1.13: +10 -4 lines
Diff to previous 1.13 (colored)

Modify automatic performance adjustment mode so that the cpu is set
to go fast if the power is connected and the battery is more than 15%
charged, and when on batteries keeps setperf low unless needed.
add a cool runnings mode option (-C) that does the previous behaviour
of keeping the CPU as low as possible unless needed.
ok deradt@, sturm@, "i like it's" djm@ henning@ and others.

Revision 1.13 / (download) - annotate - [select for diffs], Wed Nov 23 08:02:58 2005 UTC (18 years, 6 months ago) by sturm
Branch: MAIN
Changes since 1.12: +34 -3 lines
Diff to previous 1.12 (colored)

permit apmd to run on systems without apm support
let apmd control hw.setperf manually or dynamically

tested by Chris Kuethe and beck@, 'get it in' deraadt@

Revision 1.12 / (download) - annotate - [select for diffs], Tue Nov 15 01:25:48 2005 UTC (18 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (colored)

sync usage() w/ man page;

Revision 1.11 / (download) - annotate - [select for diffs], Wed Mar 30 20:00:55 2005 UTC (19 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.10: +2 -5 lines
Diff to previous 1.10 (colored)

spacing

Revision 1.10 / (download) - annotate - [select for diffs], Tue Mar 29 16:25:20 2005 UTC (19 years, 2 months ago) by miod
Branch: MAIN
Changes since 1.9: +18 -6 lines
Diff to previous 1.9 (colored)

Allow an apm implementation to return -1 in the minutes_left field of the
apm_power_info struct, if it has no reasonable value to provide.

ok deraadt@ mickey@

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jul 30 21:44:32 2003 UTC (20 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6, OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.8: +95 -90 lines
Diff to previous 1.8 (colored)

indents; jfb ok

Revision 1.8 / (download) - annotate - [select for diffs], Wed Jun 11 23:33:25 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +2 -4 lines
Diff to previous 1.7 (colored)

some ansification, some de-register

Revision 1.7 / (download) - annotate - [select for diffs], Fri Sep 6 19:14:47 2002 UTC (21 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.6: +3 -1 lines
Diff to previous 1.6 (colored)

put some code after default:

Revision 1.6 / (download) - annotate - [select for diffs], Wed Nov 14 22:20:22 2001 UTC (22 years, 6 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.5: +12 -2 lines
Diff to previous 1.5 (colored)

On macppc, print the recharge time estimate as a recharge time estimate, not
a battery life estimate, when the battery is charging.
Also, if the ac switched state and the life time, whatever it will be a
life estimate or a recharge estimate, has been reset to zero, print it as
not available.

Revision 1.5 / (download) - annotate - [select for diffs], Fri Jul 6 21:08:00 2001 UTC (22 years, 11 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.4: +193 -202 lines
Diff to previous 1.4 (colored)

cleanup and knf

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jul 5 20:10:32 2001 UTC (22 years, 11 months ago) by mickey
Branch: MAIN
Changes since 1.3: +2 -6 lines
Diff to previous 1.3 (colored)

remove -d, fix manual, document -s option; mostly from Kevin Steves <stevesk@pobox.com>

Revision 1.3 / (download) - annotate - [select for diffs], Thu Oct 29 18:21:44 1998 UTC (25 years, 7 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.2: +22 -9 lines
Diff to previous 1.2 (colored)

provide an option to retreive battery life estimate in minutes
from Martin Forseen <maf@firedoor.se>
some corrections from me.

Revision 1.2 / (download) - annotate - [select for diffs], Fri Sep 12 04:07:14 1997 UTC (26 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.1: +4 -2 lines
Diff to previous 1.1 (colored)

Kill extra newline in err()/warn().

Revision 1.1 / (download) - annotate - [select for diffs], Mon Apr 29 13:08:40 1996 UTC (28 years, 1 month ago) by hvozda
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1, OPENBSD_2_0_BASE, OPENBSD_2_0

Pull in John Kohl's most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework  by Stefan Grefen).

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.