svn commit: r297331 - head/sbin/devd
Warner Losh
imp at FreeBSD.org
Mon Mar 28 04:22:23 UTC 2016
Author: imp
Date: Mon Mar 28 04:22:22 2016
New Revision: 297331
URL: https://svnweb.freebsd.org/changeset/base/297331
Log:
Sometimes, it's useful to export the entire line to an external
program without listening to the devd socket for all events. Define
two new pseudo variables $*, the entire event from devctl and $_,
the entire event without the type character, since it might be easier
to use in some circumstances.
Modified:
head/sbin/devd/devd.cc
head/sbin/devd/devd.conf.5
Modified: head/sbin/devd/devd.cc
==============================================================================
--- head/sbin/devd/devd.cc Mon Mar 28 02:05:35 2016 (r297330)
+++ head/sbin/devd/devd.cc Mon Mar 28 04:22:22 2016 (r297331)
@@ -648,8 +648,8 @@ config::expand_one(const char *&src, str
return;
}
- // $[^A-Za-z] -> $\1
- if (!isalpha(*src)) {
+ // $[^-A-Za-z_*] -> $\1
+ if (!isalpha(*src) && *src != '_' && *src != '-' && *src != '*') {
dst += '$';
dst += *src++;
return;
@@ -793,10 +793,15 @@ process_event(char *buffer)
devdlog(LOG_INFO, "Processing event '%s'\n", buffer);
type = *buffer++;
cfg.push_var_table();
+ // $* is the entire line
+ cfg.set_variable("*", buffer - 1);
+ // $_ is the entire line without the initial character
+ cfg.set_variable("_", buffer - 1);
// No match doesn't have a device, and the format is a little
// different, so handle it separately.
switch (type) {
case notify:
+ //! (k=v)*
sp = cfg.set_vars(sp);
break;
case nomatch:
Modified: head/sbin/devd/devd.conf.5
==============================================================================
--- head/sbin/devd/devd.conf.5 Mon Mar 28 02:05:35 2016 (r297330)
+++ head/sbin/devd/devd.conf.5 Mon Mar 28 04:22:22 2016 (r297331)
@@ -41,7 +41,7 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd July 11, 2015
+.Dd March 28, 2016
.Dt DEVD.CONF 5
.Os
.Sh NAME
@@ -234,10 +234,17 @@ A partial list of variables and their po
with the
.Ic match
statement.
+The variables are published by the bus based on characteristics of the device
+that generated the event (for device events).
+Variables for other classes of events are dependent on those events.
.Pp
.Bl -tag -width ".Li manufacturer" -compact
.It Ic Variable
.Ic Description
+.It Li *
+The entire message from the current event
+.It Li _
+The entire message from the current event, after the initial type character
.It Li bus
Device name of parent bus.
.It Li cdev
More information about the svn-src-head
mailing list