xref: /freebsd/sbin/devd/devd.conf.5 (revision 6137b5f7b8c183ee8806d79b3f1d8e5e3ddb3df3)
1.\"
2.\" Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. The name of the author may not be used to endorse or promote products
10.\"    derived from this software without specific prior written permission.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22.\" SUCH DAMAGE.
23.\"
24.\" The section on comments was taken from named.conf.5, which has the
25.\" following copyright:
26.\" Copyright (c) 1999-2000 by Internet Software Consortium
27.\"
28.\" Permission to use, copy, modify, and distribute this software for any
29.\" purpose with or without fee is hereby granted, provided that the above
30.\" copyright notice and this permission notice appear in all copies.
31.\"
32.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
33.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
34.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
35.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
38.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
39.\" SOFTWARE.
40.\"
41.Dd December 1, 2022
42.Dt DEVD.CONF 5
43.Os
44.Sh NAME
45.Nm devd.conf
46.Nd configuration file for
47.Xr devd 8
48.Sh DESCRIPTION
49.Ss General Syntax
50A
51.Xr devd 8
52configuration consists of two general features, statements
53and comments.
54All statements end with a semicolon.
55Many statements can contain substatements, which are also
56terminated with a semicolon.
57.Pp
58The following statements are supported:
59.Bl -tag -width ".Ic options"
60.It Ic attach
61Specifies various matching criteria and actions to perform when
62a newly attached device matches said criteria.
63.It Ic detach
64Specifies various matching criteria and actions to perform when
65a newly detached device matches said criteria.
66.It Ic nomatch
67Specifies various matching criteria and actions to perform when
68no device driver currently loaded in the kernel claims a (new)
69device.
70.It Ic notify
71Specifies various matching criteria and actions to perform when the kernel
72sends an event notification to userland.
73.It Ic options
74Specifies various options and parameters for the operation of
75.Xr devd 8 .
76.El
77.Pp
78Statements may occur in any order in the configuration file, and may be
79repeated as often as required.
80Further details on the syntax and meaning of each statement and their
81substatements are explained below.
82.Pp
83Each statement, except
84.Ic options
85has a priority (an arbitrary number) associated with it, where
86.Ql 0
87is defined as the lowest priority.
88If two statements match the same event, only the action of the statement with
89highest priority will be executed.
90In this way generic statements can be overridden for devices or
91notifications that require special attention.
92.Pp
93The general syntax of a statement is:
94.Bd -literal -offset indent
95statement priority {
96	substatement "value";
97	...
98	substatement "value";
99};
100.Ed
101.Ss Sub-statements
102The following sub-statements are supported within the
103.Ic options
104statement.
105.Bl -tag -width ".Ic directory"
106.It Ic directory Qq Ar /some/path ;
107Adds the given directory to the list of directories from which
108.Xr devd 8
109will read all files named "*.conf" as further
110configuration files.
111Any number of
112.Ic directory
113statements can be used.
114.It Ic pid-file Qq Pa /var/run/devd.pid ;
115Specifies PID file.
116.It Ic set Ar regexp-name Qq Ar (some|regexp) ;
117Creates a regular expression and assigns it to the variable
118.Ar regexp-name .
119The variable is available throughout the rest of
120the configuration file.
121If the string begins with
122.Ql \&! ,
123it matches if the regular expression formed by the rest of the string
124does not match.
125All regular expressions have an implicit
126.Ql ^$
127around them.
128.El
129.Pp
130The following sub-statements are supported within the
131.Ic attach
132and
133.Ic detach
134statements.
135.Bl -tag -width ".Ic directory"
136.It Ic action Qq Ar command ;
137Command to execute upon a successful match.
138Example
139.Dq Li "/etc/pccard_ether $device-name start" .
140.It Ic class Qq Ar string ;
141This is shorthand for
142.Dq Ic match Qo Li class Qc Qq Ar string .
143.It Ic device-name Qq string ;
144This is shorthand for
145.Dq Ic match Qo Li device-name Qc Qq Ar string .
146This matches a device named
147.Ar string ,
148which is allowed to be a regular expression or a variable previously created
149containing a regular expression.
150The
151.Dq Li device-name
152variable
153is available for later use with the
154.Ic action
155statement.
156.It Ic match Qo Ar variable Qc Qq Ar value ;
157Matches the content of
158.Ar value
159against
160.Ar variable ;
161the content of
162.Ar value
163may be a regular expression.
164Not required during
165.Ic attach
166nor
167.Ic detach
168events since the
169.Ic device-name
170statement takes care of all device matching.
171For a partial list of variables, see below.
172.It Ic media-type Qq Ar string ;
173For network devices,
174.Ic media-type
175will match devices that have the given media type.
176Valid media types are:
177.Dq Li Ethernet ,
178.Dq Li 802.11 ,
179and
180.Dq Li ATM .
181.It Ic subdevice Qq Ar string ;
182This is shorthand for
183.Dq Ic match Qo Li subdevice Qc Qq Ar string .
184.El
185.Pp
186The following sub-statements are supported within the
187.Ic nomatch
188statement.
189.Bl -tag -width ".Ic directory"
190.It Ic action Qq Ar command ;
191Same as above.
192.It Ic match Qo Ar variable Qc Qq Ar value ;
193Matches the content of
194.Ar value
195against
196.Ar variable ;
197the content of
198.Ar value
199may be a regular expression.
200For a partial list of variables, see below.
201.El
202.Pp
203The following sub-statements are supported within the
204.Ic notify
205statement.
206The
207.Dq Li notify
208variable is available inside this statement and contains, a value, depending
209on which system and subsystem that delivered the event.
210.Bl -tag -width ".Ic directory"
211.It Ic action Qq Ar command ;
212Command to execute upon a successful match.
213Example
214.Dq Li "/etc/rc.d/power_profile $notify" .
215.It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ;
216Any number of
217.Ic match
218statements can exist within a
219.Ic notify
220statement;
221.Ar value
222can be either a fixed string or a regular expression.
223Below is a list of available systems, subsystems, and types.
224.It Ic media-type Qq Ar string ;
225See above.
226.El
227.Ss Variables that can be used with the match statement
228A partial list of variables and their possible values that can be used together
229with the
230.Ic match
231statement.
232The variables are published by the bus based on characteristics of the device
233that generated the event (for device events).
234Variables for other classes of events are dependent on those events.
235.Pp
236.Bl -tag -width ".Li manufacturer" -compact
237.It Ic Variable
238.Ic Description
239.It Li *
240The entire message from the current event.
241.It Li _
242The entire message from the current event, after the initial type character.
243.It Li timestamp
244The time this event was processed, in seconds since 1970 dot fraction.
245.It Li bus
246Device name of parent bus.
247.It Li cdev
248Device node path if one is created by the
249.Xr devfs 5
250filesystem.
251.It Li class
252Device class.
253.It Li comm
254Executable name (kernel).
255.It Li core
256Path to core file (kernel).
257.It Li device
258Device ID.
259.It Li devclass
260Device Class (USB).
261.It Li devsubclass
262Device Sub-class (USB).
263.It Li device-name
264Name of attached/detached device.
265.It Li endpoints
266Endpoint count (USB).
267.It Li function
268Card functions.
269.It Li interface
270Interface ID (USB).
271.It Li intclass
272Interface Class (USB).
273.It Li intprotocol
274Interface Protocol (USB).
275.It Li intsubclass
276Interface Sub-class (USB).
277.It Li jail
278Jail name for the process triggering the rule (RCTL).
279.It Li mode
280Peripheral mode (USB).
281.It Li notify
282Match the value of the
283.Dq Li notify
284variable.
285.It Li parent
286Parent device.
287.It Li pid
288PID of the process triggering the rule (RCTL).
289.It Li port
290Hub port number (USB).
291.It Li product
292Product ID (USB).
293.It Li release
294Hardware revision (USB).
295.It Li ruid
296Real UID of the process triggering the rule (RCTL).
297.It Li rule
298Rule (RCTL).
299.It Li sernum
300Serial Number (USB).
301.It Li slot
302Card slot.
303.It Li subvendor
304Sub-vendor ID (PCI).
305.It Li subdevice
306Sub-device ID (PCI).
307.It Li subsystem
308Matches a subsystem of a system, see below.
309.It Li system
310Matches a system type, see below.
311.It Li type
312Type of notification, see below.
313.It Li vendor
314Vendor ID.
315.El
316.Ss Notify matching
317A partial list of systems, subsystems, and types used within the
318.Ic notify
319mechanism.
320.\"
321.\" Please keep these tables sorted. Also, please use the same parameters
322.\" for each of the tables so that things line up in columns nicely.
323.\" Please do not omit the type column for notifiers that omit it.
324.Pp
325.Bl -column "System" "Subsystem" "1234567" -compact
326.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
327.It Li ACPI Ta Ta Ta
328Events related to the ACPI Subsystem.
329.It Li ACPI Ta Li ACAD Ta Ta
330AC line state ($notify=0x00 is offline, 0x01 is online).
331.It Li ACPI Ta Li Button Ta Ta
332Button state ($notify=0x00 is power, 0x01 is sleep).
333.It Li ACPI Ta Li CMBAT Ta Ta
334Battery events.
335.It Li ACPI Ta Li Dock Ta Ta
336Dock state ($notify=0x00 is undocked, 0x01 is docked).
337.It Li ACPI Ta Li Lid Ta Ta
338Lid state ($notify=0x00 is closed, 0x01 is open).
339.It Li ACPI Ta Li PROCESSOR Ta Ta
340Processor state/configuration ($notify=0x81 is a change in available Cx states).
341.It Li ACPI Ta Li Resume Ta Ta
342Resume notification.
343.It Li ACPI Ta Li Suspend Ta Ta
344Suspend notification.
345.It Li ACPI Ta Li Thermal Ta Ta
346Thermal zone events.
347.El
348.Pp
349.Bl -column "System" "Subsystem" "1234567" -compact
350.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
351.It Li AEON Ta Li power Ta Li press Ta
352The power button on an Amiga has been pressed.
353.El
354.Pp
355.Bl -column "System" "Subsystem" "1234567" -compact
356.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
357.It Li CAM Ta Ta Ta
358Events related to the
359.Xr cam 4
360system.
361.It Li CAM Ta Li periph Ta Ta
362Events related to peripheral devices.
363.It Li CAM Ta Li periph Ta Li error Ta
364Generic errors.
365.It Li CAM Ta Li periph Ta Li timeout Ta
366Command timeouts.
367.El
368.Pp
369.Bl -column "System" "Subsystem" "1234567" -compact
370.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
371.It Li CARP Ta Ta Ta
372Events related to the
373.Xr carp 4
374protocol.
375.It CARP Ta Ar vhid@inet Ta Ta
376The
377.Dq subsystem
378contains the actual CARP vhid and the name of the network interface
379on which the event took place.
380.It CARP Ta Ar vhid@inet Ta MASTER Ta
381Node become the master for a virtual host.
382.It CARP Ta Ar vhid@inet Ta BACKUP Ta
383Node become the backup for a virtual host.
384.El
385.Pp
386.Bl -column "System" "Subsystem" "1234567" -compact
387.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
388.It Li coretemp Ta Ta Ta
389Events related to the
390.Xr coretemp 4
391device.
392.It Li coretemp Ta Li Thermal Ta Ta
393Notification that the CPU core has reached critical temperature.
394.It Li coretemp Ta Li Thermal Ta Li temperature Ta
395String containing the temperature of the core that has become too hot.
396.El
397.Pp
398.Bl -column "System" "Subsystem" "1234567" -compact
399.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
400.It Li DEVFS
401.It Li DEVFS Ta Li CDEV Ta Li CREATE Ta
402The
403.Xr devfs 5
404node is created.
405.It Li DEVFS Ta Li CDEV Ta Li DESTROY Ta
406The
407.Xr devfs 5
408node is destroyed.
409.El
410.Pp
411.Bl -column "System" "Subsystem" "1234567" -compact
412.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
413.It Li ETHERNET Ta Ar inet Ta IFATTACH Ta
414Notification when the default VNET instance of the
415.Em inet
416interface is attached.
417.El
418.Pp
419.Bl -column "System" "Subsystem" "1234567" -compact
420.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
421.It Li GEOM Ta Ta Ta
422Events related to the
423.Xr geom 4
424framework.
425The difference compared to
426.Li DEVFS
427is that
428.Li GEOM
429only includes disk-like devices.
430.It Li GEOM Ta Li DEV Ta Li CREATE Ta
431A
432.Xr geom 4
433provider is created.
434.It Li GEOM Ta Li DEV Ta Li DESTROY Ta
435A
436.Xr geom 4
437provider is destroyed.
438.It Li GEOM Ta Li DEV Ta Li GEOM::physpath Ta
439The physical path of a device has changed.
440.It Li GEOM Ta Li DEV Ta Li GEOM::rotation_rate Ta
441The rotation rate of the disk has changed.
442.It Li GEOM Ta Li DEV Ta Li MEDIACHANGE Ta
443Physical media has changed.
444.It Li GEOM Ta Li DEV Ta Li SIZECHANGE Ta
445A
446.Xr geom 4
447provider size has changed.
448.El
449.Pp
450.Bl -column "System" "Subsystem" "1234567" -compact
451.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
452.It Li IFNET
453.It Li IFNET Ta Em inet Ta Ta
454The
455.Dq subsystem
456is the actual name of the network interface on which the event
457took place.
458.It Li IFNET Ta Em inet Ta Li LINK_UP Ta
459Carrier status changed to UP.
460.It Li IFNET Ta Em inet Ta Li LINK_DOWN Ta
461Carrier status changed to DOWN.
462.It Li IFNET Ta Em inet Ta Li ATTACH Ta
463The network interface is attached to the system.
464.It Li IFNET Ta Em inet Ta Li DETACH Ta
465The network interface is detached from the system.
466.It Li IFNET Ta Em inet Ta Li RENAME Ta
467The network interface is renamed.
468.It Li IFNET Ta Em inet Ta Li ADDR_ADD Ta
469The network interface address added.
470.It Li IFNET Ta Em inet Ta Li ADDR_DEL Ta
471The network interface address removed.
472.El
473.Pp
474.Bl -column "System" "Subsystem" "1234567" -compact
475.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
476.It Li kernel Ta Li signal Ta Li coredump Ta
477Notification that a process has crashed and dumped core.
478.It Li kernel Ta Li power Ta Li resume Ta
479Notification that the system has woken from the suspended state.
480.El
481.Pp
482.Bl -column "System" "Subsystem" "1234567" -compact
483.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
484.It Li PMU Ta Ta Ta
485Notification of events from various types of Power Management Units.
486.It Li PMU Ta Li "AC" Ta Ta
487Notifications of AC power related events.
488.It Li PMU Ta Li "AC" Ta Li overvoltage Ta
489An over-voltage condition was detected on the AC power line.
490.It Li PMU Ta Li "AC" Ta Li plugged Ta
491Power has been applied to the AC power line.
492.It Li PMU Ta Li "AC" Ta Li unplugged Ta
493Power has been removed from the AC power line.
494.It Li PMU Ta Li Battery Ta Ta
495.It Li PMU Ta Li Battery Ta absent Ta
496Battery is no longer absent.
497.It Li PMU Ta Li Battery Ta charged Ta
498The battery has become charged.
499.It Li PMU Ta Li Battery Ta charging Ta
500The battery has started charging.
501.It Li PMU Ta Li Battery Ta disconnected Ta
502The battery has been disconnected.
503.It Li PMU Ta Li Battery Ta high-temp Ta
504The battery reported a temperature over the limit.
505.It Li PMU Ta Li Battery Ta low-temp Ta
506The battery reported a temperature under the limit.
507.It Li PMU Ta Li Battery Ta plugged Ta
508The battery has become plugged (eg connected).
509.It Li PMU Ta Li Battery Ta shutdown-threshold Ta
510The power in the battery has fallen below the shutdown threshold.
511.It Li PMU Ta Li Battery Ta warning-threshold Ta
512The power in the battery has fallen below the warn the user threshold.
513.It Li PMU Ta Li Button Ta pressed Ta
514A button on a
515.Xr adb 4
516or
517.Xr pmu 4
518has been pressed.
519.It Li PMU Ta Li keys Ta Ta
520One of the keys on the
521.Xr adb 4
522keyboard has been pressed.
523.It Li PMU Ta Li keys Ta brightness Ta
524A brightness level change has been requested.
525Direction is in the $notify variable.
526.It Li PMU Ta Li keys Ta mute Ta
527The mute key
528.It Li PMU Ta Li keys Ta volume Ta
529A volume level change has been requested.
530Direction is in the $notify variable.
531.It Li PMU Ta Li keys Ta eject Ta
532An ejection has been requested.
533.It Li PMU Ta Li lid Ta close Ta
534The
535.Xr pmc 4
536device has detected the lid closing.
537.It Li PMU Ta Li lid Ta open Ta
538The
539.Xr pmc 4
540device has detected the lid openinging.
541.It Li PMU Ta Li POWER Ta ACLINE Ta
542The
543.Xr pmc 4
544device has detected an AC line state ($notify=0x00 is offline, 0x01 is online).
545.It Li PMU Ta Li USB Ta overvoltage Ta
546An over-voltage condition on the power lines for the USB power pins.
547.It Li PMU Ta Li USB Ta plugged Ta
548A device has been plugged into a USB device.
549.It Li PMU Ta Li USB Ta undervoltage Ta
550An under-voltage condition on the power lines for the USB power pins.
551.It Li PMU Ta Li USB Ta unplugged Ta
552A device has been unplugged into a USB device.
553.El
554.Pp
555.Bl -column "System" "Subsystem" "1234567" -compact
556.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
557.It Li RCTL Ta Ta Ta
558Events related to the
559.Xr rctl 8
560framework.
561.It Li RCTL Ta Li rule Ta Li matched Ta
562A rule with action specified as "devctl" was triggered.
563.El
564.Pp
565.Bl -column "System" "Subsystem" "1234567" -compact
566.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
567.It Li USB Ta Ta Ta
568Events related to the USB subsystem.
569.It Li USB Ta Li DEVICE Ta Li ATTACH Ta
570USB device is attached to the system.
571.It Li USB Ta Li DEVICE Ta Li DETACH Ta
572USB device is detached to the system.
573.It Li USB Ta Li INTERFACE Ta Li ATTACH Ta
574USB interface is attached to a device.
575.It Li USB Ta Li INTERFACE Ta Li DETACH Ta
576USB interface is detached from a device.
577.El
578.Pp
579.Bl -column "System" "Subsystem" "1234567" -compact
580.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
581.It Li VFS Ta Ta Ta
582Events from the vfs system.
583.It Li VFS Ta Li FS Ta Ta
584Events that change what is mounted to the system.
585.It Li VFS Ta Li FS Ta Li MOUNT Ta
586Notification of a filesystem is mounted for the first time.
587.It Li VFS Ta Li FS Ta Li REMOUNT Ta
588Notification of a filesystem is remounted (whether or not the options actually change).
589.It Li VFS Ta Li FS Ta Li UNMOUNT Ta
590Notification of a filesystem being unmounted.
591.El
592.Pp
593.Bl -column "System" "Subsystem" "1234567" -compact
594.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
595.It Li VT Ta BELL Ta RING Ta
596Notification that the console bell has rung.
597See
598.Xr vt 4
599for details.
600.El
601.Pp
602.Bl -column "System" "Subsystem" "1234567" -compact
603.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
604.It Li ZFS Ta ZFS Ta Ta
605Events about the ZFS subsystem.
606See
607.Xr zfsd 8
608and
609.Pa /etc/devd/zfs.conf
610for details.
611.El
612.Pp
613.\"
614.\" End of tables
615.\"
616A link state change to UP on the interface
617.Dq Li fxp0
618would result in the following notify event:
619.Bd -literal -offset indent
620system=IFNET subsystem=fxp0 type=LINK_UP
621.Ed
622.Pp
623An AC line state change to
624.Dq offline
625would result in the following event:
626.Bd -literal -offset indent
627system=ACPI subsystem=ACAD notify=0x00
628.Ed
629.Ss Comments
630Comments may appear anywhere that whitespace may appear in a
631configuration file.
632To appeal to programmers of all kinds, they can
633be written in C, C++, or shell/Perl constructs.
634.Pp
635C-style comments start with the two characters
636.Ql /*
637(slash, star) and end with
638.Ql */
639(star, slash).
640Because they are completely delimited with these characters,
641they can be used to comment only a portion of a line or to span
642multiple lines.
643.Pp
644C-style comments cannot be nested.
645For example, the following is
646not valid because the entire comment ends with the first
647.Ql */ :
648.Bd -literal -offset indent
649/* This is the start of a comment.
650   This is still part of the comment.
651/* This is an incorrect attempt at nesting a comment. */
652   This is no longer in any comment. */
653.Ed
654.Pp
655C++-style comments start with the two characters
656.Ql //
657(slash, slash) and continue to the end of the physical line.
658They cannot be continued across multiple physical lines; to have
659one logical comment span multiple lines, each line must use the
660.Ql //
661pair.
662For example:
663.Bd -literal -offset indent
664// This is the start of a comment.  The next line
665// is a new comment, even though it is logically
666// part of the previous comment.
667.Ed
668.Ss Notes on Variable Expansion
669To prevent issues with special shell characters, the following happens for each
670variable
671.Ic $foo .
672.Bl -enum
673.It
674The characters
675.Dq $'
676are inserted.
677.It
678The string
679.Dq $foo
680is removed.
681.It
682The value of the
683.Ic foo
684variable is inserted into the buffer with all single quote characters
685prefixed by a backslash.
686.El
687.Pp
688See
689.Xr sh 1
690for what this construct means.
691It is safe in all context, except one: inside single quotes.
692If foo=meta and bar=var, then a rule like the following:
693.Bd -literal -offset indent -compact
694action "echo '$foo $bar'";
695.Ed
696will be presented to the shell via
697.Xr system 3
698as
699.Bd -literal -offset indent -compact
700echo '$'meta' $'var''
701.Ed
702which produces the following output:
703.Bd -literal -offset indent -compact
704$meta $var
705.Ed
706as its output.
707This is an unanticipated result.
708A future version of this software will change this behavior.
709Users are discouraged from using single quotes inside
710.Ic action
711value without due care.
712.Pp
713The above should be written as
714.Bd -literal -offset indent -compact
715action "echo $foo' '$bar"
716.Ed
717to produce a single argument to echo.
718Given the above expansion, juxtaposing bare variables with
719single quote expressions will produce the right output,
720regardless of the value of the variable.
721.Sh FILES
722.Bl -tag -width ".Pa /etc/devd.conf" -compact
723.It Pa /etc/devd.conf
724The
725.Xr devd 8
726configuration file.
727.El
728.Sh EXAMPLES
729.Bd -literal
730#
731# This will catch link down events on the interfaces fxp0 and ath0
732#
733notify 0 {
734	match "system"			"IFNET";
735	match "subsystem"		"(fxp0|ath0)";
736	match "type"			"LINK_DOWN";
737	action "logger $subsystem is DOWN";
738};
739
740#
741# Match lid open/close events
742# These can be combined to a single event, by passing the
743# value of $notify to the external script.
744#
745notify 0 {
746	match "system"			"ACPI";
747	match "subsystem"		"Lid";
748	match "notify"			"0x00";
749	action "logger Lid closed, we can sleep now!";
750};
751
752notify 0 {
753	match "system"			"ACPI";
754	match "subsystem"		"Lid";
755	match "notify"			"0x01";
756	action "logger Lid opened, the sleeper must awaken!";
757};
758
759#
760# Match a USB device type
761#
762notify 0 {
763	match "system"			"USB";
764	match "subsystem"		"INTERFACE";
765	match "type"			"ATTACH";
766	match "intclass"		"0x0e";
767	action "logger USB video device attached";
768};
769
770#
771# Try to configure ath and iwn devices with pccard_ether
772# as they are attached.
773#
774attach 0 {
775        device-name "(ath|iwn)[0-9]+";
776        action "/etc/pccard_ether $device-name start";
777};
778
779#
780# Stop ath and iwn devices as they are detached from
781# the system.
782#
783detach 0 {
784        device-name "(ath|iwn)[0-9]+";
785        action "/etc/pccard_ether $device-name stop";
786};
787.Ed
788.Pp
789The installed
790.Pa /etc/devd.conf
791has many additional examples.
792.Sh SEE ALSO
793.Xr cam 4 ,
794.Xr coretemp 4 ,
795.Xr devfs 5 ,
796.Xr re_format 7 ,
797.Xr devd 8
798.Sh BUGS
799The variable expansion's interaction with single quotes is
800suboptimal and surprising.
801