summaryrefslogtreecommitdiff
path: root/usr.sbin/apmd
AgeCommit message (Collapse)Author
2023-04-27zap APM_CANCEL, dead since import; OK tbKlemens Nanni
2023-03-08Delete obsolete /* ARGSUSED */ lint comments.Philip Guenther
ok miod@ millert@
2022-12-04userspace: remove vestigial '?' cases from top-level getopt(3) loopsScott Soule Cheloha
getopt(3) returns '?' when it encounters a flag not present in the in the optstring or if a flag is missing its option argument. We can handle this case with the "default" failure case with no loss of legibility. Hence, remove all the redundant "case '?':" lines. Prompted by dlg@. With help from dlg@ and millert@. Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2 ok naddy@ millert@ dlg@
2022-05-28rework the power status changes text;Jason McIntyre
original diff from jan stary, adjusted according to sthen
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-02-18apmd should replace /etc/random.seed for hibernate-resumes (and alsoTheo de Raadt
chmod 600 the file to remove the t-bit that the bootblocks set when the file is used) comments from naddy
2022-02-18shut apmd up while the battery is coming to the full capacity when chargingRobert Nagy
to avoid filling up syslog with unnecessary information ok tb@
2022-02-06now that APM_BATT_CHARGING is also set in acpi and on some m1 devicesRobert Nagy
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@
2021-11-03adjust for perfpolicy being auto by default; ok deraadtJason McIntyre
2021-07-12Change the error reporting pattern throughout the tree when unveilBob Beck
fails to report the path that the failure occured on. Suggested by deraadt@ after some tech discussion. Work done and verified by Ashton Fagg <ashton@fagg.id.au> ok deraadt@ semarie@ claudio@
2021-07-08typo: hibenate -> hibernateTheo Buehler
2021-04-18Simpler error handling for suspend()/hibernate()Jeremie Courreges-Anglas
Save errno when we get an error so we can pass it to the apm(8) client. ok kn@
2021-04-06handle_client() doesn't need to return a valueJeremie Courreges-Anglas
Its caller doesn't use the return value so zap it. Also zap tentative error handling in the caller. ok kn@
2021-04-06Missing indentation, ok kn@Jeremie Courreges-Anglas
2021-04-06Bump APMD_VNO, for the size of struct apm_reply has changedJeremie Courreges-Anglas
ok kn@
2021-04-06Make apm(8) report apmd(8) failurekn
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
2021-03-29Install apm(8) and and apmd(8) under MI MANPATHkn
powerpc64 was lacking manual pages; instead of shipping yet another identical MD manual, merge them under MI MANPATH as usual. Input OK deraadt
2021-03-25Log ioctl failureskn
Otherwise there is no way to determine why e.g. zzz(8) does not do anything on certain machines; macppc and arm64 for example have no suspend/resume suspend at all (for now) and loongson has partial support. This still does not make `zzz' or `apm -z' report the informative warning on standar error, but syslog now prints apmd: system suspending apmd: battery status: unknown. external power status: not known. estimated battery life 0% apmd: suspend: Operation not supported OK benno
2021-03-16Do not delete control socket upon exitkn
The control socket is not unveiled, therefore accounting would report unveil violations whenever apmd(8) stopped (normally). As discussed and done with other daemons such as relayd which also employ no pledge (due to inherent limitations) but unveil effecting all of /, simply stop removing the socket upon exit and leave it to the next apmd which completely sets up its control socket anew at startup. Violations reported by anton Feedback OK semarie mestre
2021-03-11Use unveil(2)kn
Pledge is not possible due to the ioctls, but as apmd hoists both the control socket and apm device early at startup and only ever possibly executes scripts under /etc/apm/, hiding the rest of the filesystem becomes easy. Technically, only "x" is required to traverse the directory and run scripts, but apmd carefully access(2) each script, which requires the read bit regardless of the permission bits being tested. OK mestre
2020-09-28Set hw.perfpolicy to "manual" and hw.setperf to max when handling -HJeremie Courreges-Anglas
This is better than using hw.perfpolicy="high" for a number of reasons: - matches the manpage - apm(8) reporting becomes accurate - more symmetry with -L ("low") - lets the user tweak hw.setperf with sysctl(8) later ok tedu@
2020-09-24Always ask the kernel about current hw.perfpolicyJeremie Courreges-Anglas
apmd(8) doesn't need to maintain state about the current hw.perfpolicy. Dropping this weak caching fixes several issues: - setting hw.perfpolicy can fail, don't report a bogus hw.perfpolicy if that happens (reported by Miod) - don't assume that hw.perfpolicy is set to "manual" at apmd(8) startup - don't assume that hw.perfpolicy can't change behind apmd(8)'s back "Seems fine" tedu@
2020-09-23Zap code remnants of the "cool running mode" (removed in 2014)Jeremie Courreges-Anglas
Nowadays "auto" mode is used instead. ok deraadt@
2020-07-15powerpc64 has the sysctl's for power control, so it can use theTheo de Raadt
apmd/apm combo for -L/-H and such. (it gets all the rest of the mess too) ok kettenis
2020-03-13Block autoaction after it kicks in, until 60 seconds after resumeJeremie Courreges-Anglas
This prevents your laptop from immediately going back to sleep after resume, leaving you some time to look up stuff or even stop apmd in case you need the machine RIGHT NOW. Blocking autoaction until the laptop resumes prevents spurious suspend/resume cycles. Advices from cheloha@
2020-02-18Further unify apm events and timeout polling codeJeremie Courreges-Anglas
Fake an APM_POWER_CHANGE event if we time out waiting for an event. This allows us to handle autoaction in a single place.
2020-02-12Reorder to handle apm events and timeouts with the same codeJeremie Courreges-Anglas
2020-02-12On APM_POWER_CHANGE events check battery life against autoaction levelJeremie Courreges-Anglas
Makes -z/-Z just work for me using acpibat(4). Other battery drivers that provide APM_POWER_CHANGE events: acpisbs(4), apm(4), ykbec(4/loongson) and stsec(4/loongson). ok tedu@
2020-02-12Zap apmtimeout, the way it's used isn't meaningful any moreJeremie Courreges-Anglas
Just check the return value of kevent(2) to detect a timeout. ok tedu@
2020-01-25With -d, messages are now printed on stderrJeremie Courreges-Anglas
Missed when I changed this in apmd.c rev 1.91.
2019-11-02Write debug messages to stderr instead of stdoutJeremie Courreges-Anglas
ok kn@ mpi@
2019-11-02Zap remnants from "cpu throttling on mp systems" introduced in rev 1.46Jeremie Courreges-Anglas
That logic is now in the kernel. ok kn@ mpi@
2019-09-25When battery state switches to critical, apmd(8) generates anAlexander Bluhm
emergency log message. Then syslogd(8) could select on that and write a warning to all users. OK benno@ deraadt@
2019-07-25Fix another %m occurencekn
Found by bluhm, thanks.
2019-07-24Fix format specifier in execl(3) error messagekn
Typo from r1.84 introducing the logmsg() wrapper. OK deraadt
2019-07-22Zap useless globalskn
Initialize stack variables directly instead of using global state in between. OK tedu deraadt
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
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.
2019-01-23enable the apm(4) programs on arm64Peter Hessler
previous version OK deraadt@ patrick@ OK jsg@
2018-12-04redo the debug logging to be more like everything else.Ted Unangst
ok kn
2018-12-01Use strtonum(3) for -t seconds, improve errors on invalid number inputkn
Base 10 suffices, negative numbers should be invalid (not converted) and zero not treated specially. This also unifies error messages and removes unnecessary EINVAL from them since strtonum()'s errstr is explicit enough already. Feedback and OK martjin, tb
2018-11-30log current power status going into and out of suspend, since it may beTed Unangst
interesting to review. it seems the battery status is sometimes stale, but that's another bug. ok kn phessler
2017-10-15Kill unused definesJeremie Courreges-Anglas
2017-08-29zap trailing whitespace;Jason McIntyre
2017-08-28add -z and -Z options to auto suspend or hibernate when low on battery.Ted Unangst
from Jesper Wallin
2016-09-03Retire zaurus, as it hasn't made the EABI jump and will be permanently brokenPhilip Guenther
shortly when we use the hardware thread register in userland
2016-09-01remove sparcTed Unangst
2015-11-16fix log messages, from jan staryTed Unangst
2015-11-13apmd doesn't connect to the socket, it binds on it; tweak error messageJeremie Courreges-Anglas
2015-10-11Userspace doesn't need to use SUN_LEN(): connect() and bind() must acceptPhilip Guenther
sizeof(struct sockaddr_un), so do the simple, portable thing. Also convert some strncpy() to strlcpy() ok deraadt@
2015-08-28log battery changes every 10%, not every 21.Ted Unangst
ok deraadt jung phessler