CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: roy Date: Mon Oct 12 16:54:43 UTC 2020 Modified Files: src/usr.sbin/powerd: powerd.c Log Message: powerd: Stop crashing if entries are not found in the dictionary If the first three are not found, log a diagnostic and do nothing. If the latter two are not found, set them to NULL rather than garbage. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/powerd/powerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.c diff -u src/usr.sbin/powerd/powerd.c:1.19 src/usr.sbin/powerd/powerd.c:1.20 --- src/usr.sbin/powerd/powerd.c:1.19 Sun Jun 7 05:54:00 2020 +++ src/usr.sbin/powerd/powerd.c Mon Oct 12 16:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: powerd.c,v 1.19 2020/06/07 05:54:00 thorpej Exp $ */ +/* $NetBSD: powerd.c,v 1.20 2020/10/12 16:54:43 roy Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -325,18 +325,33 @@ dispatch_power_event_state_change(int fd __func__, error); return; } - + if (debug) { buf = prop_dictionary_externalize(dict); printf("%s", buf); free(buf); } - prop_dictionary_get_string(dict, "powerd-script-name", [0]); - prop_dictionary_get_string(dict, "driver-name", [1]); - prop_dictionary_get_string(dict, "powerd-event-name", [2]); - prop_dictionary_get_string(dict, "sensor-name", [3]); - prop_dictionary_get_string(dict, "state-description", [4]); + /* First three arguments are not optional. */ + if (!prop_dictionary_get_string(dict, "powerd-script-name", [0])) { + powerd_log(LOG_ERR, "dict does not have powerd-script-name"); + return; + } + if (!prop_dictionary_get_string(dict, "driver-name", [1])) { + powerd_log(LOG_ERR, "dict does not have driver-name"); + return; + } + if (!prop_dictionary_get_string(dict, "powerd-event-name", [2])) { + powerd_log(LOG_ERR, "dict does not have powerd-event-name"); + return; + } + + /* These arguments are optional. */ + if (!prop_dictionary_get_string(dict, "sensor-name", [3])) + argv[3] = NULL; + if (!prop_dictionary_get_string(dict, "state-description", [4])) + argv[4] = NULL; + argv[5] = NULL; run_script(argv);
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: thorpej Date: Sun Jun 7 05:54:00 UTC 2020 Modified Files: src/usr.sbin/powerd: powerd.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/powerd/powerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.c diff -u src/usr.sbin/powerd/powerd.c:1.18 src/usr.sbin/powerd/powerd.c:1.19 --- src/usr.sbin/powerd/powerd.c:1.18 Sat Feb 9 01:16:39 2013 +++ src/usr.sbin/powerd/powerd.c Sun Jun 7 05:54:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: powerd.c,v 1.18 2013/02/09 01:16:39 christos Exp $ */ +/* $NetBSD: powerd.c,v 1.19 2020/06/07 05:54:00 thorpej Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -314,7 +314,6 @@ static void dispatch_power_event_state_change(int fd, power_event_t *pev) { prop_dictionary_t dict; - prop_object_t obj; const char *argv[6]; char *buf = NULL; int error; @@ -333,21 +332,11 @@ dispatch_power_event_state_change(int fd free(buf); } - obj = prop_dictionary_get(dict, "powerd-script-name"); - argv[0] = prop_string_cstring_nocopy(obj); - - obj = prop_dictionary_get(dict, "driver-name"); - argv[1] = prop_string_cstring_nocopy(obj); - - obj = prop_dictionary_get(dict, "powerd-event-name"); - argv[2] = prop_string_cstring_nocopy(obj); - - obj = prop_dictionary_get(dict, "sensor-name"); - argv[3] = prop_string_cstring_nocopy(obj); - - obj = prop_dictionary_get(dict, "state-description"); - argv[4] = prop_string_cstring_nocopy(obj); - + prop_dictionary_get_string(dict, "powerd-script-name", [0]); + prop_dictionary_get_string(dict, "driver-name", [1]); + prop_dictionary_get_string(dict, "powerd-event-name", [2]); + prop_dictionary_get_string(dict, "sensor-name", [3]); + prop_dictionary_get_string(dict, "state-description", [4]); argv[5] = NULL; run_script(argv);
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: abhinav Date: Tue Feb 21 15:15:20 UTC 2017 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Fix spelling of "occurs". To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.25 src/usr.sbin/powerd/powerd.8:1.26 --- src/usr.sbin/powerd/powerd.8:1.25 Tue Nov 6 19:08:45 2012 +++ src/usr.sbin/powerd/powerd.8 Tue Feb 21 15:15:19 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: powerd.8,v 1.25 2012/11/06 19:08:45 dholland Exp $ +.\" $NetBSD: powerd.8,v 1.26 2017/02/21 15:15:19 abhinav Exp $ .\" .\" Copyright (c) 2003 Wasabi Systems, Inc. .\" All rights reserved. @@ -141,7 +141,7 @@ This script is called when an event occu .It Em sensor_fan This script is called when an event occurs on a fan sensor. .It Em sensor_indicator -This script is called when an event ocurrs on a indicator/integer sensor. +This script is called when an event occurs on a indicator/integer sensor. .It Em sensor_power This script is called when an event occurs on a power sensor (W/Ampere). .It Em sensor_resistance
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: christos Date: Sat Feb 9 01:16:40 UTC 2013 Modified Files: src/usr.sbin/powerd: powerd.c Log Message: CID/980002: missing va_end() To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/powerd/powerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.c diff -u src/usr.sbin/powerd/powerd.c:1.17 src/usr.sbin/powerd/powerd.c:1.18 --- src/usr.sbin/powerd/powerd.c:1.17 Wed Mar 14 22:02:24 2012 +++ src/usr.sbin/powerd/powerd.c Fri Feb 8 20:16:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: powerd.c,v 1.17 2012/03/15 02:02:24 joerg Exp $ */ +/* $NetBSD: powerd.c,v 1.18 2013/02/09 01:16:39 christos Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -371,4 +371,5 @@ powerd_log(int pri, const char *msg, ... UNKNOWN : prioritynames[i].c_name); vfprintf(stderr, msg, arglist); } + va_end(arglist); }
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: dholland Date: Tue Nov 6 19:08:45 UTC 2012 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Minor grammar fix, from Bug Hunting in PR 47159. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.24 src/usr.sbin/powerd/powerd.8:1.25 --- src/usr.sbin/powerd/powerd.8:1.24 Wed Dec 15 18:11:01 2010 +++ src/usr.sbin/powerd/powerd.8 Tue Nov 6 19:08:45 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.24 2010/12/15 18:11:01 wiz Exp $ +.\ $NetBSD: powerd.8,v 1.25 2012/11/06 19:08:45 dholland Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -53,8 +53,7 @@ translates the event into a script name then runs the script in order to implement the power management policy defined by the system administrator. .Pp -.Nm -supports the following option: +The following options are available: .Bl -tag -width .It Fl d Enable debugging mode.
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: pgoyette Date: Sun Dec 19 22:52:08 UTC 2010 Modified Files: src/usr.sbin/powerd: Makefile powerd.c Added Files: src/usr.sbin/powerd: powerd_hostops.c powerd_rumpops.c prog_ops.h Log Message: Rump-ify powerd. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/powerd/Makefile cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/powerd/powerd.c cvs rdiff -u -r0 -r1.1 src/usr.sbin/powerd/powerd_hostops.c \ src/usr.sbin/powerd/powerd_rumpops.c src/usr.sbin/powerd/prog_ops.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/Makefile diff -u src/usr.sbin/powerd/Makefile:1.5 src/usr.sbin/powerd/Makefile:1.6 --- src/usr.sbin/powerd/Makefile:1.5 Wed Apr 22 15:23:06 2009 +++ src/usr.sbin/powerd/Makefile Sun Dec 19 22:52:08 2010 @@ -1,8 +1,14 @@ -# $NetBSD: Makefile,v 1.5 2009/04/22 15:23:06 lukem Exp $ +# $NetBSD: Makefile,v 1.6 2010/12/19 22:52:08 pgoyette Exp $ PROG= powerd SRCS= powerd.c +RUMPPRG= powerd + +.PATH: ${.CURDIR}/../../common/lib/libprop +CPPFLAGS+= -DRUMP_ACTION +RUMPSRCS+= prop_kern.c + DPADD+= ${LIBPROP} ${LIBUTIL} LDADD+= -lprop -lutil Index: src/usr.sbin/powerd/powerd.c diff -u src/usr.sbin/powerd/powerd.c:1.15 src/usr.sbin/powerd/powerd.c:1.16 --- src/usr.sbin/powerd/powerd.c:1.15 Wed Dec 15 17:12:40 2010 +++ src/usr.sbin/powerd/powerd.c Sun Dec 19 22:52:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: powerd.c,v 1.15 2010/12/15 17:12:40 pgoyette Exp $ */ +/* $NetBSD: powerd.c,v 1.16 2010/12/19 22:52:08 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -42,10 +42,12 @@ #define SYSLOG_NAMES #include sys/cdefs.h +#include sys/ioctl.h #include sys/param.h #include sys/event.h #include sys/power.h #include sys/wait.h +#include err.h #include errno.h #include fcntl.h #include paths.h @@ -59,6 +61,8 @@ #include stdarg.h #include string.h +#include prog_ops.h + int debug, no_scripts; static int kq; @@ -88,6 +92,9 @@ setprogname(*argv); + if (prog_init prog_init() == -1) + err(1, init failed); + while ((ch = getopt(argc, argv, dn)) != -1) { switch (ch) { case 'd': @@ -115,24 +122,24 @@ (void)pidfile(NULL); } - if ((kq = kqueue()) == -1) { + if ((kq = prog_kqueue()) == -1) { powerd_log(LOG_ERR, kqueue: %s, strerror(errno)); exit(EX_OSERR); } - if ((fd = open(_PATH_POWER, O_RDONLY|O_NONBLOCK, 0600)) == -1) { + if ((fd = prog_open(_PATH_POWER, O_RDONLY|O_NONBLOCK, 0600)) == -1) { powerd_log(LOG_ERR, open %s: %s, _PATH_POWER, strerror(errno)); exit(EX_OSERR); } - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { + if (prog_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { powerd_log(LOG_ERR, Cannot set close on exec in power fd: %s, strerror(errno)); exit(EX_OSERR); } - if (ioctl(fd, POWER_IOC_GET_TYPE, power_type) == -1) { + if (prog_ioctl(fd, POWER_IOC_GET_TYPE, power_type) == -1) { powerd_log(LOG_ERR, POWER_IOC_GET_TYPE: %s, strerror(errno)); exit(EX_OSERR); } @@ -254,7 +261,7 @@ { int rv; - while ((rv = kevent(kq, nchanges ? changebuf : NULL, nchanges, + while ((rv = prog_kevent(kq, nchanges ? changebuf : NULL, nchanges, events, nevents, NULL)) 0) { nchanges = 0; if (errno != EINTR) { @@ -278,7 +285,7 @@ ev-data, ev-data 1 ? s : ); again: - if (read(fd, pev, sizeof(pev)) != sizeof(pev)) { + if (prog_read(fd, pev, sizeof(pev)) != sizeof(pev)) { if (errno == EWOULDBLOCK) return; powerd_log(LOG_ERR, read of %s: %s, _PATH_POWER, Added files: Index: src/usr.sbin/powerd/powerd_hostops.c diff -u /dev/null src/usr.sbin/powerd/powerd_hostops.c:1.1 --- /dev/null Sun Dec 19 22:52:08 2010 +++ src/usr.sbin/powerd/powerd_hostops.c Sun Dec 19 22:52:08 2010 @@ -0,0 +1,51 @@ +/* $NetBSD: powerd_hostops.c,v 1.1 2010/12/19 22:52:08 pgoyette Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: pgoyette Date: Wed Dec 15 17:12:40 UTC 2010 Modified Files: src/usr.sbin/powerd: powerd.8 powerd.c Log Message: Add an option to not actually run the power management scripts, and when in debug mode send all error messages to stderr rather than to syslog(8). To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/powerd/powerd.8 cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/powerd/powerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.22 src/usr.sbin/powerd/powerd.8:1.23 --- src/usr.sbin/powerd/powerd.8:1.22 Wed Jan 27 06:52:24 2010 +++ src/usr.sbin/powerd/powerd.8 Wed Dec 15 17:12:40 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.22 2010/01/27 06:52:24 wiz Exp $ +.\ $NetBSD: powerd.8,v 1.23 2010/12/15 17:12:40 pgoyette Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -33,7 +33,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd January 26, 2010 +.Dd December 15, 2010 .Dt POWERD 8 .Os .Sh NAME @@ -42,6 +42,7 @@ .Sh SYNOPSIS .Nm .Op Fl d +.Op Fl n .Sh DESCRIPTION .Nm acts upon power management events posted by the kernel's power management @@ -58,9 +59,13 @@ .Bl -tag -width .It Fl d Enable debugging mode. -Verbose messages will be sent to stderr and +Verbose messages and all messages intended for +.Xr syslog 8 +will be sent to stderr, and .Nm will stay in the foreground of the controlling terminal. +.It Fl n +Prevent execution of power management scripts. .El .Sh CONFIGURATION SCRIPTS All configuration of Index: src/usr.sbin/powerd/powerd.c diff -u src/usr.sbin/powerd/powerd.c:1.14 src/usr.sbin/powerd/powerd.c:1.15 --- src/usr.sbin/powerd/powerd.c:1.14 Sat Apr 24 20:44:33 2010 +++ src/usr.sbin/powerd/powerd.c Wed Dec 15 17:12:40 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: powerd.c,v 1.14 2010/04/24 20:44:33 jruoho Exp $ */ +/* $NetBSD: powerd.c,v 1.15 2010/12/15 17:12:40 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -39,6 +39,8 @@ * Power management daemon for sysmon. */ +#define SYSLOG_NAMES + #include sys/cdefs.h #include sys/param.h #include sys/event.h @@ -54,8 +56,10 @@ #include unistd.h #include util.h #include prop/proplib.h +#include stdarg.h +#include string.h -int debug; +int debug, no_scripts; static int kq; @@ -67,6 +71,7 @@ static int wait_for_events(struct kevent *, size_t); static void dispatch_dev_power(struct kevent *); static void dispatch_power_event_state_change(int, power_event_t *); +static void powerd_log(int, const char *, ...); static const char *script_paths[] = { NULL, @@ -83,12 +88,16 @@ setprogname(*argv); - while ((ch = getopt(argc, argv, d)) != -1) { + while ((ch = getopt(argc, argv, dn)) != -1) { switch (ch) { case 'd': debug = 1; break; + case 'n': + no_scripts = 1; + break; + default: usage(); } @@ -99,36 +108,40 @@ if (argc) usage(); - if (debug == 0) + if (debug == 0) { (void)daemon(0, 0); - openlog(powerd, LOG_PID | LOG_NOWAIT, LOG_DAEMON); - (void)pidfile(NULL); + openlog(powerd, LOG_PID | LOG_NOWAIT, LOG_DAEMON); + (void)pidfile(NULL); + } if ((kq = kqueue()) == -1) { - syslog(LOG_ERR, kqueue: %m); + powerd_log(LOG_ERR, kqueue: %s, strerror(errno)); exit(EX_OSERR); } if ((fd = open(_PATH_POWER, O_RDONLY|O_NONBLOCK, 0600)) == -1) { - syslog(LOG_ERR, open %s: %m, _PATH_POWER); + powerd_log(LOG_ERR, open %s: %s, _PATH_POWER, + strerror(errno)); exit(EX_OSERR); } if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { - syslog(LOG_ERR, Cannot set close on exec in power fd: %m); + powerd_log(LOG_ERR, Cannot set close on exec in power fd: %s, + strerror(errno)); exit(EX_OSERR); } if (ioctl(fd, POWER_IOC_GET_TYPE, power_type) == -1) { - syslog(LOG_ERR, POWER_IOC_GET_TYPE: %m); + powerd_log(LOG_ERR, POWER_IOC_GET_TYPE: %s, strerror(errno)); exit(EX_OSERR); } (void)asprintf(cp, %s/%s, _PATH_POWERD_SCRIPTS, power_type.power_type); if (cp == NULL) { - syslog(LOG_ERR, allocating script path: %m); + powerd_log(LOG_ERR, allocating script path: %s, + strerror(errno)); exit(EX_OSERR); } script_paths[0] = cp; @@ -153,7 +166,7 @@ usage(void) { - (void)fprintf(stderr, usage: %s [-d]\n, getprogname()); + (void)fprintf(stderr, usage: %s [-dn]\n, getprogname()); exit(EX_USAGE); } @@ -173,16 +186,19 @@ argv[0] = path; if (debug) { -(void)fprintf(stderr, running script: %s, -argv[0]); +(void)fprintf(stderr, %srunning script: %s, +no_scripts?not :, argv[0]); for (j = 1; argv[j] != NULL; j++) (void)fprintf(stderr, %s, argv[j]); (void)fprintf(stderr, \n); } + if (no_scripts != 0) +return; switch ((pid =
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: wiz Date: Wed Dec 15 18:11:01 UTC 2010 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Merge single-letter options in SYNOPSIS. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.23 src/usr.sbin/powerd/powerd.8:1.24 --- src/usr.sbin/powerd/powerd.8:1.23 Wed Dec 15 17:12:40 2010 +++ src/usr.sbin/powerd/powerd.8 Wed Dec 15 18:11:01 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.23 2010/12/15 17:12:40 pgoyette Exp $ +.\ $NetBSD: powerd.8,v 1.24 2010/12/15 18:11:01 wiz Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -41,8 +41,7 @@ .Nd power management daemon for sysmon .Sh SYNOPSIS .Nm -.Op Fl d -.Op Fl n +.Op Fl dn .Sh DESCRIPTION .Nm acts upon power management events posted by the kernel's power management
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: jruoho Date: Tue Jan 26 14:28:23 UTC 2010 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Emphasize the script names and events. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.19 src/usr.sbin/powerd/powerd.8:1.20 --- src/usr.sbin/powerd/powerd.8:1.19 Mon May 4 19:11:49 2009 +++ src/usr.sbin/powerd/powerd.8 Tue Jan 26 14:28:23 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.19 2009/05/04 19:11:49 wiz Exp $ +.\ $NetBSD: powerd.8,v 1.20 2010/01/26 14:28:23 jruoho Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -98,27 +98,27 @@ the device is associated, and the event type. .Pp The following power switch script names are defined: -.Bl -tag -width power_button -.It power_button +.Bl -tag -width hotkey_button +.It Em power_button This script is called when an event occurs on a power button device. -.It reset_button +.It Em reset_button This script is called when an event occurs on a reset button device. -.It sleep_button +.It Em sleep_button This script is called when an event occurs on a sleep button device. -.It lid_switch +.It Em lid_switch This script is called when an event occurs on a lid switch device. -.It acadapter +.It Em acadapter This script is called when an online or offline event occurs on an AC adapter device. -.It hotkey_button +.It Em hotkey_button This script is called when an event occurs on a hotkey button device. .El .Pp The following events are defined for power switch devices: -.Bl -tag -width released -.It pressed +.Bl -tag -width hotkey_button +.It Em pressed The button was pressed, the lid closed, or the AC adapter connected. -.It released +.It Em released The button was released, the lid opened, or the AC adapter disconnected. Note that power and sleep button devices usually do not post this type of event. @@ -142,22 +142,22 @@ .Pp The following envsys script names are defined: .Bl -tag -width sensor_temperature -.It sensor_battery +.It Em sensor_battery This script is called when an event occurs on a battery sensor (Wh/Ah/Battery state). -.It sensor_drive +.It Em sensor_drive This script is called when an event occurs on a drive sensor. -.It sensor_fan +.It Em sensor_fan This script is called when an event occurs on a fan sensor. -.It sensor_indicator +.It Em sensor_indicator This script is called when an event ocurrs on a indicator/integer sensor. -.It sensor_power +.It Em sensor_power This script is called when an event occurs on a power sensor (W/Ampere). -.It sensor_resistance +.It Em sensor_resistance This script is called when an event occurs on a resistance sensor (Ohm). -.It sensor_temperature +.It Em sensor_temperature This script is called when an event occurs on a temperature sensor. -.It sensor_voltage +.It Em sensor_voltage This script is called when an event occurs on a voltage sensor. .El .Pp @@ -171,23 +171,23 @@ The following events are defined for fan, indicator, power, resistance, temperature and voltage sensors: .Bl -tag -width sensor_temperature -.It critical +.It Em critical A critical condition was triggered. -.It critical-under +.It Em critical-under A critical under condition was triggered. -.It critical-over +.It Em critical-over A critical over condition was triggered. -.It warning-under +.It Em warning-under A warning under condition was triggered. -.It warning-over +.It Em warning-over A warning over condition was triggered. .El .Pp The following events are defined only for battery sensors: .Bl -tag -width sensor_temperature -.It user-capacity +.It Em user-capacity Capacity dropped below the limit set by the user. -.It low-power +.It Em low-power System is running in low power, that means that there is not any AC Adapter connected and all batteries are in critical or low capacity. @@ -198,7 +198,7 @@ .Pp The following events are defined for drive and battery sensors: .Bl -tag -width sensor_temperature -.It state-changed +.It Em state-changed The state on the sensor has been changed and it's not in normal state. .El .Pp
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: jruoho Date: Tue Jan 26 20:37:13 UTC 2010 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Some miscellaneous fixes: * Apparently there is only a single location for the scripts. Thus, remove the references to /etc/powerd/scripts/apm and /etc/powerd/scripts/acpi. * Correct confusion: instead of the device with which the device is associated, write the device with which the event is associated. Correct also an example related to this. * Improve wording, grammar, and markup in few places. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.20 src/usr.sbin/powerd/powerd.8:1.21 --- src/usr.sbin/powerd/powerd.8:1.20 Tue Jan 26 14:28:23 2010 +++ src/usr.sbin/powerd/powerd.8 Tue Jan 26 20:37:13 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.20 2010/01/26 14:28:23 jruoho Exp $ +.\ $NetBSD: powerd.8,v 1.21 2010/01/26 20:37:13 jruoho Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -63,27 +63,13 @@ will stay in the foreground of the controlling terminal. .El .Sh CONFIGURATION SCRIPTS -All of +All configuration of .Nm -configuration is encapsulated into scripts that are run when power -management events occur. -.Nm -will look for these scripts in two locations. -The first location is -.Pa /etc/powerd/scripts/\*[Lt]power_type\*[Gt] , -where -.Aq Pa power_type -is defined by the power management mechanism supported by the system, -e.g., -.Dq apm -or -.Dq acpi . -If the script is not found in the first location, -.Nm -looks in +is encapsulated into scripts that are run when power management events occur. +The daemon will look for the scripts from the directory .Pa /etc/powerd/scripts . .Pp -Configuration scripts are run synchronously, i.e., +Configuration scripts are run synchronously; .Nm will start the script and wait for its completion before it handles the next event. @@ -95,7 +81,7 @@ Power switch scripts are called when a state change event occurs on a power switch device. Power switch scripts are called with two arguments: the device with which -the device is associated, and the event type. +the event is associated, and the event type. .Pp The following power switch script names are defined: .Bl -tag -width hotkey_button @@ -117,9 +103,11 @@ The following events are defined for power switch devices: .Bl -tag -width hotkey_button .It Em pressed -The button was pressed, the lid closed, or the AC adapter connected. +The button was pressed, the lid was closed, +or the AC adapter was connected. .It Em released -The button was released, the lid opened, or the AC adapter disconnected. +The button was released, the lid was opened, +or the AC adapter was disconnected. Note that power and sleep button devices usually do not post this type of event. .El @@ -127,13 +115,13 @@ The following is an example of how a power button script might be invoked when a power button is pressed by the operator: .Bd -literal -offset indent -/etc/powerd/scripts/power_button acpi0 pressed +/etc/powerd/scripts/power_button acpibut0 pressed .Ed .Ss ENVSYS SCRIPTS .Xr envsys 4 scripts are called when a condition was triggered in a sensor. These scripts are called with three arguments: the -device associated, the event type and sensor's name. +device associated, the event type, and the sensor's name. The .Sy sensor_drive and the @@ -161,15 +149,8 @@ This script is called when an event occurs on a voltage sensor. .El .Pp -The following event is defined for all scripts but is only sent if -a critical/warning or any other event was previously sent: -.Bl -tag -width sensor_temperature -.It normal -A normal state/capacity/condition was triggered. -.El -.Pp The following events are defined for fan, indicator, power, -resistance, temperature and voltage sensors: +resistance, temperature, and voltage sensors: .Bl -tag -width sensor_temperature .It Em critical A critical condition was triggered. @@ -183,23 +164,28 @@ A warning over condition was triggered. .El .Pp +The following event is defined for all scripts, but it is only sent if +any of the previous events has been previously sent: +.Bl -tag -width sensor_temperature +.It Em normal +A normal state/capacity/condition was triggered. +.El +.Pp The following events are defined only for battery sensors: .Bl -tag -width sensor_temperature .It Em user-capacity Capacity dropped below the limit set by the user. .It Em low-power -System is running in low power, that means that there is not -any AC Adapter connected and all batteries are in critical or -low capacity. -When this event is received there's no much time so you should only -suspend or shutdown the system. +System is running in low power. +This
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: wiz Date: Wed Jan 27 06:52:24 UTC 2010 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.21 src/usr.sbin/powerd/powerd.8:1.22 --- src/usr.sbin/powerd/powerd.8:1.21 Tue Jan 26 20:37:13 2010 +++ src/usr.sbin/powerd/powerd.8 Wed Jan 27 06:52:24 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.21 2010/01/26 20:37:13 jruoho Exp $ +.\ $NetBSD: powerd.8,v 1.22 2010/01/27 06:52:24 wiz Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -33,7 +33,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd December 22, 2007 +.Dd January 26, 2010 .Dt POWERD 8 .Os .Sh NAME
CVS commit: src/usr.sbin/powerd
Module Name:src Committed By: wiz Date: Mon May 4 19:11:49 UTC 2009 Modified Files: src/usr.sbin/powerd: powerd.8 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/powerd/powerd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/powerd/powerd.8 diff -u src/usr.sbin/powerd/powerd.8:1.18 src/usr.sbin/powerd/powerd.8:1.19 --- src/usr.sbin/powerd/powerd.8:1.18 Sat Dec 22 18:40:21 2007 +++ src/usr.sbin/powerd/powerd.8 Mon May 4 19:11:49 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: powerd.8,v 1.18 2007/12/22 18:40:21 jmcneill Exp $ +.\ $NetBSD: powerd.8,v 1.19 2009/05/04 19:11:49 wiz Exp $ .\ .\ Copyright (c) 2003 Wasabi Systems, Inc. .\ All rights reserved. @@ -190,9 +190,10 @@ .It low-power System is running in low power, that means that there is not any AC Adapter connected and all batteries are in critical or -low capacity. When this event is received there's no much time -so you should only suspend or shutdown the system. The script -shutdowns the system gracefully by default. +low capacity. +When this event is received there's no much time so you should only +suspend or shutdown the system. +The script shutdowns the system gracefully by default. .El .Pp The following events are defined for drive and battery sensors: