xref: /freebsd/sbin/devd/devd.conf.5 (revision 592ae60e2b2eff6c2ec467c34be9a457ce24b044)
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 July 28, 2026
42.Dt DEVD.CONF 5
43.Os
44.Sh NAME
45.Nm devd.conf
46.Nd configuration file format 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 4
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" "12345678" -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" "12345678" -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" "12345678" -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 invalidate Ta
366Peripheral invalidation.
367.It Li CAM Ta Li periph Ta Li timeout Ta
368Command timeouts.
369.El
370.Pp
371.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -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 Li 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 Li CARP Ta Ar vhid@inet Ta Li MASTER Ta
383Node become the master for a virtual host.
384.It Li CARP Ta Ar vhid@inet Ta Li BACKUP Ta
385Node become the backup for a virtual host.
386.El
387.Pp
388.Bl -column "CORETEMP" "SUBSYSTEM" "TEMPERATURE" -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" "12345678" -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 4
406node is created.
407.It Li DEVFS Ta Li CDEV Ta Li DESTROY Ta
408The
409.Xr devfs 4
410node is destroyed.
411.El
412.Pp
413.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -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" "GEOM::ROTATION_RATE" -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" "LINK_DOWN" -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" "12345678" -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" "SMART_ERROR" -compact
485.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
486.It Li nvme Ta Li controller Ta Ta
487Controller events provide the controller name
488.Pq for example, Li nvme0
489in $name.
490.It Li nvme Ta Li controller Ta Li SMART_ERROR Ta
491A SMART Critical Warning State change has happened.
492$state has a hex bitmask of the bits that changed, as defined
493in the NVMe Standard for Critical Warning field of log page 2
494.Dq SMART / Health Information Log :
495.Pp
496.Bl -tag -width "Bit Value" -compact
497.It Sy "Bit Value"
498.Sy Meaning
499.It 0x1
500Spare capacity below threshold
501.It 0x2
502Temperature outside acceptable range
503.It 0x4
504Reliability of media degraded
505.It 0x8
506Media placed into read-only mode
507.It 0x10
508Volatime memory backup failure
509.It 0x20
510Persistent memory read-only or degraded
511.El
512.It Li nvme Ta Li controller Ta Li RESET Ta
513A controller reset event has happened.
514$event is one of
515.Dq start ,
516.Dq success ,
517and
518.Dq timed_out
519representing the start of a controller reset, the successful completion of a
520controller reset, or a timeout while waiting for the controller to reset,
521respectively.
522.It Li nvme Ta Li controller Ta Li RECONNECT Ta
523An NVMe over Fabrics host has disconnected and is requesting a reconnect.
524.El
525.Pp
526.Bl -column "SYSTEM" "SUBSYSTEM" "SHUTDOWN-THRESHOLD" -compact
527.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
528.It Li PMU Ta Ta Ta
529Notification of events from various types of Power Management Units.
530.It Li PMU Ta Li "AC" Ta Ta
531Notifications of AC power related events.
532.It Li PMU Ta Li "AC" Ta Li overvoltage Ta
533An over-voltage condition was detected on the AC power line.
534.It Li PMU Ta Li "AC" Ta Li plugged Ta
535Power has been applied to the AC power line.
536.It Li PMU Ta Li "AC" Ta Li unplugged Ta
537Power has been removed from the AC power line.
538.It Li PMU Ta Li Battery Ta Ta
539.It Li PMU Ta Li Battery Ta Li absent Ta
540Battery is no longer absent.
541.It Li PMU Ta Li Battery Ta Li charged Ta
542The battery has become charged.
543.It Li PMU Ta Li Battery Ta Li charging Ta
544The battery has started charging.
545.It Li PMU Ta Li Battery Ta Li disconnected Ta
546The battery has been disconnected.
547.It Li PMU Ta Li Battery Ta Li high-temp Ta
548The battery reported a temperature over the limit.
549.It Li PMU Ta Li Battery Ta Li low-temp Ta
550The battery reported a temperature under the limit.
551.It Li PMU Ta Li Battery Ta Li plugged Ta
552The battery has become plugged (eg connected).
553.It Li PMU Ta Li Battery Ta Li shutdown-threshold Ta
554The power in the battery has fallen below the shutdown threshold.
555.It Li PMU Ta Li Battery Ta Li warning-threshold Ta
556The power in the battery has fallen below the warn the user threshold.
557.It Li PMU Ta Li Button Ta Li pressed Ta
558A button on a
559.Xr adb 4
560or
561.Xr pmu 4
562has been pressed.
563.It Li PMU Ta Li keys Ta Ta
564One of the keys on the
565.Xr adb 4
566keyboard has been pressed.
567.It Li PMU Ta Li keys Ta Li brightness Ta
568A brightness level change has been requested.
569Direction is in the $notify variable.
570.It Li PMU Ta Li keys Ta Li mute Ta
571The mute key
572.It Li PMU Ta Li keys Ta Li volume Ta
573A volume level change has been requested.
574Direction is in the $notify variable.
575.It Li PMU Ta Li keys Ta Li eject Ta
576An ejection has been requested.
577.It Li PMU Ta Li lid Ta Li close Ta
578The
579.Xr pmc 4
580device has detected the lid closing.
581.It Li PMU Ta Li lid Ta Li open Ta
582The
583.Xr pmc 4
584device has detected the lid openinging.
585.It Li PMU Ta Li POWER Ta Li ACLINE Ta
586The
587.Xr pmc 4
588device has detected an AC line state ($notify=0x00 is offline, 0x01 is online).
589.It Li PMU Ta Li USB Ta Li overvoltage Ta
590An over-voltage condition on the power lines for the USB power pins.
591.It Li PMU Ta Li USB Ta Li plugged Ta
592A device has been plugged into a USB device.
593.It Li PMU Ta Li USB Ta Li undervoltage Ta
594An under-voltage condition on the power lines for the USB power pins.
595.It Li PMU Ta Li USB Ta Li unplugged Ta
596A device has been unplugged from a USB device.
597.El
598.Pp
599.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
600.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
601.It Li RCTL Ta Ta Ta
602Events related to the
603.Xr rctl 8
604framework.
605.It Li RCTL Ta Li rule Ta Li matched Ta
606A rule with action specified as "devctl" was triggered.
607.El
608.Pp
609.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
610.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
611.It Li USB Ta Ta Ta
612Events related to the USB subsystem.
613.It Li USB Ta Li DEVICE Ta Li ATTACH Ta
614USB device is attached to the system.
615.It Li USB Ta Li DEVICE Ta Li DETACH Ta
616USB device is detached to the system.
617.It Li USB Ta Li INTERFACE Ta Li ATTACH Ta
618USB interface is attached to a device.
619.It Li USB Ta Li INTERFACE Ta Li DETACH Ta
620USB interface is detached from a device.
621.El
622.Pp
623.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
624.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
625.It Li VFS Ta Ta Ta
626Events from the vfs system.
627.It Li VFS Ta Li FS Ta Ta
628Events that change what is mounted to the system.
629.It Li VFS Ta Li FS Ta Li MOUNT Ta
630Notification of a filesystem is mounted for the first time.
631.It Li VFS Ta Li FS Ta Li REMOUNT Ta
632Notification of a filesystem is remounted (whether or not the options actually change).
633.It Li VFS Ta Li FS Ta Li UNMOUNT Ta
634Notification of a filesystem being unmounted.
635.El
636.Pp
637.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
638.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
639.It Li VT Ta Li BELL Ta Li RING Ta
640Notification that the console bell has rung.
641See
642.Xr vt 4
643for details.
644.El
645.Pp
646.Bl -column "SYSTEM" "SUBSYSTEM" "12345678" -compact
647.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
648.It Li ZFS Ta Li ZFS Ta Ta
649Events about the ZFS subsystem.
650See
651.Xr zfsd 8
652and
653.Pa /etc/devd/zfs.conf
654for details.
655.El
656.Pp
657.Bl -column "System" "Subsystem" "1234567" -compact
658.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
659.It Li SND Ta Ta Ta
660Events related to the
661.Xr sound 4
662driver.
663.It Li SND Ta Li CONN Ta Li IN Ta
664Connected input device specified in
665.Pa cdev
666variable.
667.It Li SND Ta Li CONN Ta Li OUT Ta
668Connected output device specified in
669.Pa cdev
670variable.
671.It Li SND Ta Li CONN Ta Li NODEV Ta
672No connected devices.
673.El
674.Pp
675.\"
676.\" End of tables
677.\"
678A link state change to UP on the interface
679.Dq Li fxp0
680would result in the following notify event:
681.Bd -literal -offset indent
682system=IFNET subsystem=fxp0 type=LINK_UP
683.Ed
684.Pp
685An AC line state change to
686.Dq offline
687would result in the following event:
688.Bd -literal -offset indent
689system=ACPI subsystem=ACAD notify=0x00
690.Ed
691.Ss Comments
692Comments may appear anywhere that whitespace may appear in a
693configuration file.
694To appeal to programmers of all kinds, they can
695be written in C, C++, or shell/Perl constructs.
696.Pp
697C-style comments start with the two characters
698.Ql /*
699(slash, star) and end with
700.Ql */
701(star, slash).
702Because they are completely delimited with these characters,
703they can be used to comment only a portion of a line or to span
704multiple lines.
705.Pp
706C-style comments cannot be nested.
707For example, the following is
708not valid because the entire comment ends with the first
709.Ql */ :
710.Bd -literal -offset indent
711/* This is the start of a comment.
712   This is still part of the comment.
713/* This is an incorrect attempt at nesting a comment. */
714   This is no longer in any comment. */
715.Ed
716.Pp
717C++-style comments start with the two characters
718.Ql //
719(slash, slash) and continue to the end of the physical line.
720They cannot be continued across multiple physical lines; to have
721one logical comment span multiple lines, each line must use the
722.Ql //
723pair.
724For example:
725.Bd -literal -offset indent
726// This is the start of a comment.  The next line
727// is a new comment, even though it is logically
728// part of the previous comment.
729.Ed
730.Ss Notes on Variable Expansion
731Variables are expanded by preceding them by a
732.Dq $
733sign.
734Any text immediately following that sign, starting with a letter, a minus sign
735.Dq - ,
736an underscore
737.Dq _ ,
738or an asterisk
739.Dq *
740is considered an internal variable, and expanded accordingly.
741If that variable does not exist, it silently expands to an empty string.
742Consequently, if the intention is to pass a
743.Xr sh 1
744variable, it must be surrounded by braces to prevent it from being
745considered an internal variable.
746.Pp
747See
748.Sx EXAMPLES
749for a detailed example.
750.Pp
751To prevent issues with special shell characters, the following happens for each
752variable
753.Ic $foo .
754.Bl -enum
755.It
756The characters
757.Dq $'
758are inserted.
759.It
760The string
761.Dq $foo
762is removed.
763.It
764The value of the
765.Ic foo
766variable is inserted into the buffer with all single quote characters
767prefixed by a backslash.
768.It
769A final
770.Dq '
771is inserted.
772.El
773.Pp
774See
775.Xr sh 1
776for what this construct means.
777It is safe in all context, except one: inside single quotes.
778If foo=meta and bar=var, then a rule like the following:
779.Bd -literal -offset indent -compact
780action "echo '$foo $bar'";
781.Ed
782will be presented to the shell via
783.Xr system 3
784as
785.Bd -literal -offset indent -compact
786echo '$'meta' $'var''
787.Ed
788which produces the following output:
789.Bd -literal -offset indent -compact
790$meta $var
791.Ed
792as its output.
793This is an unanticipated result.
794A future version of this software will change this behavior.
795Users are discouraged from using single quotes inside
796.Ic action
797value without due care.
798.Pp
799The above should be written as
800.Bd -literal -offset indent -compact
801action "echo $foo' '$bar"
802.Ed
803to produce a single argument to echo.
804Given the above expansion, juxtaposing bare variables with
805single quote expressions will produce the right output,
806regardless of the value of the variable.
807.Sh FILES
808.Bl -tag -width ".Pa /etc/devd.conf" -compact
809.It Pa /etc/devd.conf
810The
811.Xr devd 8
812configuration file.
813.It Pa /etc/devd
814A directory that
815.Nm devd
816searches for additional configuration files.
817.It Pa /usr/local/etc/devd
818A directory that
819.Nm devd
820searches for additional configuration files.
821.El
822.Sh EXAMPLES
823.Bd -literal
824#
825# This will catch link down events on the interfaces fxp0 and ath0
826#
827notify 0 {
828	match "system"			"IFNET";
829	match "subsystem"		"(fxp0|ath0)";
830	match "type"			"LINK_DOWN";
831	action "logger $subsystem is DOWN";
832};
833
834#
835# Match lid open/close events
836# These can be combined to a single event, by passing the
837# value of $notify to the external script.
838#
839notify 0 {
840	match "system"			"ACPI";
841	match "subsystem"		"Lid";
842	match "notify"			"0x00";
843	action "logger Lid closed, we can sleep now!";
844};
845
846notify 0 {
847	match "system"			"ACPI";
848	match "subsystem"		"Lid";
849	match "notify"			"0x01";
850	action "logger Lid opened, the sleeper must awaken!";
851};
852
853#
854# Match a USB device type
855#
856notify 0 {
857	match "system"			"USB";
858	match "subsystem"		"INTERFACE";
859	match "type"			"ATTACH";
860	match "intclass"		"0x0e";
861	action "logger USB video device attached";
862};
863
864#
865# Try to configure ath and iwn devices with pccard_ether
866# as they are attached.
867#
868attach 0 {
869        device-name "(ath|iwn)[0-9]+";
870        action "/etc/pccard_ether $device-name start";
871};
872
873#
874# Stop ath and iwn devices as they are detached from
875# the system.
876#
877detach 0 {
878        device-name "(ath|iwn)[0-9]+";
879        action "/etc/pccard_ether $device-name stop";
880};
881.Ed
882.Pp
883The following example illustrates the difference between internal and shell variables:
884.Bd -literal
885attach 20 {
886        device-name             "umodem[0-9]+";
887        match "vendor"          "0x2047";
888        match "product"         "0x001(0|3|4)";
889        match "interface"       "0";
890        action "cd /dev; p=$product; dn=$device-name; \\
891                un=$(sysctl -n dev.umodem.${dn#umodem}.ttyname); \\
892                chmod 666 cua${un}; ln -sf cua${un} mspfet${p#0x}";
893};
894.Ed
895.Pp
896.Dq product ,
897and
898.Dq device-name
899are internal variables.
900Their contents are initially assigned to shell variables
901.Dq p ,
902and
903.Dq dn ,
904respectively.
905Then, variable
906.Dq dn
907is used inside a shell command substitution, assigning to shell variable
908.Dq un .
909Finally, this shell variable is used in two other shell statements, where
910it needs to be wrapped in braces in order to prevent it from being
911considered in internal variable to
912.Nm devd .
913.Pp
914The installed
915.Pa /etc/devd.conf
916has many additional examples.
917.Sh SEE ALSO
918.Xr cam 4 ,
919.Xr coretemp 4 ,
920.Xr devfs 4 ,
921.Xr re_format 7 ,
922.Xr devd 8
923.Sh BUGS
924The variable expansion's interaction with single quotes is
925suboptimal and surprising.
926