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