summaryrefslogtreecommitdiffstats
path: root/sbin/devd
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2016-03-28 04:22:22 +0000
committerimp <imp@FreeBSD.org>2016-03-28 04:22:22 +0000
commit2b800612daf9f1e49be89fbebf8432f23f01cbc4 (patch)
tree6344a8d644078301182946395897b026f4c94ebf /sbin/devd
parentb98b691b5e86a35cd178463a894ae5ae81462fed (diff)
downloadFreeBSD-src-2b800612daf9f1e49be89fbebf8432f23f01cbc4.zip
FreeBSD-src-2b800612daf9f1e49be89fbebf8432f23f01cbc4.tar.gz
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.
Diffstat (limited to 'sbin/devd')
-rw-r--r--sbin/devd/devd.cc9
-rw-r--r--sbin/devd/devd.conf.59
2 files changed, 15 insertions, 3 deletions
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index 203d750..46fe315 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -648,8 +648,8 @@ config::expand_one(const char *&src, string &dst)
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:
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index 86570fb..21779ed 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -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 possible values that can be used together
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
OpenPOWER on IntegriCloud