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