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