2 .\" Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
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
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.
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
43 .Dd September 22, 2022
48 .Nd configuration file for
54 configuration consists of two general features, statements
56 All statements end with a semicolon.
57 Many statements can contain substatements, which are also
58 terminated with a semicolon.
60 The following statements are supported:
61 .Bl -tag -width ".Ic options"
63 Specifies various matching criteria and actions to perform when
64 a newly attached device matches said criteria.
66 Specifies various matching criteria and actions to perform when
67 a newly detached device matches said criteria.
69 Specifies various matching criteria and actions to perform when
70 no device driver currently loaded in the kernel claims a (new)
73 Specifies various matching criteria and actions to perform when the kernel
74 sends an event notification to userland.
76 Specifies various options and parameters for the operation of
80 Statements may occur in any order in the configuration file, and may be
81 repeated as often as required.
82 Further details on the syntax and meaning of each statement and their
83 substatements are explained below.
85 Each statement, except
87 has a priority (an arbitrary number) associated with it, where
89 is defined as the lowest priority.
90 If two statements match the same event, only the action of the statement with
91 highest priority will be executed.
92 In this way generic statements can be overridden for devices or
93 notifications that require special attention.
95 The general syntax of a statement is:
96 .Bd -literal -offset indent
100 substatement "value";
104 The following sub-statements are supported within the
107 .Bl -tag -width ".Ic directory"
108 .It Ic directory Qq Ar /some/path ;
109 Adds the given directory to the list of directories from which
111 will read all files named "*.conf" as further
115 statements can be used.
116 .It Ic pid-file Qq Pa /var/run/devd.pid ;
118 .It Ic set Ar regexp-name Qq Ar (some|regexp) ;
119 Creates a regular expression and assigns it to the variable
121 The variable is available throughout the rest of
122 the configuration file.
123 If the string begins with
125 it matches if the regular expression formed by the rest of the string
127 All regular expressions have an implicit
132 The following sub-statements are supported within the
137 .Bl -tag -width ".Ic directory"
138 .It Ic action Qq Ar command ;
139 Command to execute upon a successful match.
141 .Dq Li "/etc/pccard_ether $device-name start" .
142 .It Ic class Qq Ar string ;
143 This is shorthand for
144 .Dq Ic match Qo Li class Qc Qq Ar string .
145 .It Ic device-name Qq string ;
146 This is shorthand for
147 .Dq Ic match Qo Li device-name Qc Qq Ar string .
148 This matches a device named
150 which is allowed to be a regular expression or a variable previously created
151 containing a regular expression.
155 is available for later use with the
158 .It Ic match Qo Ar variable Qc Qq Ar value ;
159 Matches the content of
165 may be a regular expression.
172 statement takes care of all device matching.
173 For a partial list of variables, see below.
174 .It Ic media-type Qq Ar string ;
177 will match devices that have the given media type.
178 Valid media types are:
183 .It Ic subdevice Qq Ar string ;
184 This is shorthand for
185 .Dq Ic match Qo Li subdevice Qc Qq Ar string .
188 The following sub-statements are supported within the
191 .Bl -tag -width ".Ic directory"
192 .It Ic action Qq Ar command ;
194 .It Ic match Qo Ar variable Qc Qq Ar value ;
195 Matches the content of
201 may be a regular expression.
202 For a partial list of variables, see below.
205 The following sub-statements are supported within the
210 variable is available inside this statement and contains, a value, depending
211 on which system and subsystem that delivered the event.
212 .Bl -tag -width ".Ic directory"
213 .It Ic action Qq Ar command ;
214 Command to execute upon a successful match.
216 .Dq Li "/etc/rc.d/power_profile $notify" .
217 .It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ;
220 statements can exist within a
224 can be either a fixed string or a regular expression.
225 Below is a list of available systems, subsystems, and types.
226 .It Ic media-type Qq Ar string ;
229 .Ss Variables that can be used with the match statement
230 A partial list of variables and their possible values that can be used together
234 The variables are published by the bus based on characteristics of the device
235 that generated the event (for device events).
236 Variables for other classes of events are dependent on those events.
238 .Bl -tag -width ".Li manufacturer" -compact
242 The entire message from the current event.
244 The entire message from the current event, after the initial type character.
246 The time this event was processed, in seconds since 1970 dot fraction.
248 Device name of parent bus.
250 Device node path if one is created by the
256 Executable name (kernel).
258 Path to core file (kernel).
264 Device Sub-class (USB).
266 Name of attached/detached device.
268 Endpoint count (USB).
274 Interface Class (USB).
276 Interface Protocol (USB).
278 Interface Sub-class (USB).
280 Jail name for the process triggering the rule (RCTL).
282 Peripheral mode (USB).
284 Match the value of the
290 PID of the process triggering the rule (RCTL).
292 Hub port number (USB).
296 Hardware revision (USB).
298 Real UID of the process triggering the rule (RCTL).
310 Matches a subsystem of a system, see below.
312 Matches a system type, see below.
314 Type of notification, see below.
319 A partial list of systems, subsystems, and types used within the
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.
327 .Bl -column "System" "Subsystem" "1234567" -compact
328 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
330 Events related to the ACPI Subsystem.
331 .It Li ACPI Ta Li ACAD Ta Ta
332 AC line state ($notify=0x00 is offline, 0x01 is online).
333 .It Li ACPI Ta Li Button Ta Ta
334 Button state ($notify=0x00 is power, 0x01 is sleep).
335 .It Li ACPI Ta Li CMBAT Ta Ta
337 .It Li ACPI Ta Li Dock Ta Ta
338 Dock state ($notify=0x00 is undocked, 0x01 is docked).
339 .It Li ACPI Ta Li Lid Ta Ta
340 Lid state ($notify=0x00 is closed, 0x01 is open).
341 .It Li ACPI Ta Li PROCESSOR Ta Ta
342 Processor state/configuration ($notify=0x81 is a change in available Cx states).
343 .It Li ACPI Ta Li Resume Ta Ta
345 .It Li ACPI Ta Li Suspend Ta Ta
346 Suspend notification.
347 .It Li ACPI Ta Li Thermal Ta Ta
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
354 The power button on an Amiga has been pressed.
357 .Bl -column "System" "Subsystem" "1234567" -compact
358 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
360 Events related to the
363 .It Li CAM Ta Li periph Ta Ta
364 Events related to peripheral devices.
365 .It Li CAM Ta Li periph Ta Li error Ta
367 .It Li CAM Ta Li periph Ta Li timeout Ta
371 .Bl -column "System" "Subsystem" "1234567" -compact
372 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
374 Events related to the
377 .It CARP Ta Ar vhid@inet Ta Ta
380 contains the actual CARP vhid and the name of the network interface
381 on which the event took place.
382 .It CARP Ta Ar vhid@inet Ta MASTER Ta
383 Node become the master for a virtual host.
384 .It CARP Ta Ar vhid@inet Ta BACKUP Ta
385 Node become the backup for a virtual host.
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
391 Events related to the
394 .It Li coretemp Ta Li Thermal Ta Ta
395 Notification that the CPU core has reached critical temperature.
396 .It Li coretemp Ta Li Thermal Ta Li temperature Ta
397 String containing the temperature of the core that has become too hot.
400 .Bl -column "System" "Subsystem" "1234567" -compact
401 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
403 .It Li DEVFS Ta Li CDEV Ta Li CREATE Ta
407 .It Li DEVFS Ta Li CDEV Ta Li DESTROY Ta
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
416 Notification when the default VNET instance of the
418 interface is attached.
421 .Bl -column "System" "Subsystem" "1234567" -compact
422 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
424 Events related to the
427 The difference compared to
431 only includes disk-like devices.
432 .It Li GEOM Ta Li DEV Ta Li CREATE Ta
436 .It Li GEOM Ta Li DEV Ta Li DESTROY Ta
439 provider is destroyed.
440 .It Li GEOM Ta Li DEV Ta Li GEOM::physpath Ta
441 The physical path of a device has changed.
442 .It Li GEOM Ta Li DEV Ta Li GEOM::rotation_rate Ta
443 The rotation rate of the disk has changed.
444 .It Li GEOM Ta Li DEV Ta Li MEDIACHANGE Ta
445 Physical media has changed.
446 .It Li GEOM Ta Li DEV Ta Li SIZECHANGE Ta
449 provider size has changed.
452 .Bl -column "System" "Subsystem" "1234567" -compact
453 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
455 .It Li IFNET Ta Em inet Ta Ta
458 is the actual name of the network interface on which the event
460 .It Li IFNET Ta Em inet Ta Li LINK_UP Ta
461 Carrier status changed to UP.
462 .It Li IFNET Ta Em inet Ta Li LINK_DOWN Ta
463 Carrier status changed to DOWN.
464 .It Li IFNET Ta Em inet Ta Li ATTACH Ta
465 The network interface is attached to the system.
466 .It Li IFNET Ta Em inet Ta Li DETACH Ta
467 The network interface is detached from the system.
468 .It Li IFNET Ta Em inet Ta Li RENAME Ta
469 The network interface is renamed.
470 .It Li IFNET Ta Em inet Ta Li ADDR_ADD Ta
471 The network interface address added.
472 .It Li IFNET Ta Em inet Ta Li ADDR_DEL Ta
473 The network interface address removed.
476 .Bl -column "System" "Subsystem" "1234567" -compact
477 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
478 .It Li kern Ta Li power Ta Li resume Ta
479 Notification that the system has woken from the suspended state.
480 Note: this notification is deprecated and will be removed in
484 .Bl -column "System" "Subsystem" "1234567" -compact
485 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
486 .It Li kernel Ta Li signal Ta Li coredump Ta
487 Notification that a process has crashed and dumped core.
488 .It Li kernel Ta Li power Ta Li resume Ta
489 Notification that the system has woken from the suspended state.
492 .Bl -column "System" "Subsystem" "1234567" -compact
493 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
495 Notification of events from various types of Power Management Units.
496 .It Li PMU Ta Li "AC" Ta Ta
497 Notifications of AC power related events.
498 .It Li PMU Ta Li "AC" Ta Li overvoltage Ta
499 An over-voltage condition was detected on the AC power line.
500 .It Li PMU Ta Li "AC" Ta Li plugged Ta
501 Power has been applied to the AC power line.
502 .It Li PMU Ta Li "AC" Ta Li unplugged Ta
503 Power has been removed from the AC power line.
504 .It Li PMU Ta Li Battery Ta Ta
505 .It Li PMU Ta Li Battery Ta absent Ta
506 Battery is no longer absent.
507 .It Li PMU Ta Li Battery Ta charged Ta
508 The battery has become charged.
509 .It Li PMU Ta Li Battery Ta charging Ta
510 The battery has started charging.
511 .It Li PMU Ta Li Battery Ta disconnected Ta
512 The battery has been disconnected.
513 .It Li PMU Ta Li Battery Ta high-temp Ta
514 The battery reported a temperature over the limit.
515 .It Li PMU Ta Li Battery Ta low-temp Ta
516 The battery reported a temperature under the limit.
517 .It Li PMU Ta Li Battery Ta plugged Ta
518 The battery has become plugged (eg connected).
519 .It Li PMU Ta Li Battery Ta shutdown-threshold Ta
520 The power in the battery has fallen below the shutdown threshold.
521 .It Li PMU Ta Li Battery Ta warning-threshold Ta
522 The power in the battery has fallen below the warn the user threshold.
523 .It Li PMU Ta Li Button Ta pressed Ta
529 .It Li PMU Ta Li keys Ta Ta
530 One of the keys on the
532 keyboard has been pressed.
533 .It Li PMU Ta Li keys Ta brightness Ta
534 A brightness level change has been requested.
535 Direction is in the $notify variable.
536 .It Li PMU Ta Li keys Ta mute Ta
538 .It Li PMU Ta Li keys Ta volume Ta
539 A volume level change has been requested.
540 Direction is in the $notify variable.
541 .It Li PMU Ta Li keys Ta eject Ta
542 An ejection has been requested.
543 .It Li PMU Ta Li lid Ta close Ta
546 device has detected the lid closing.
547 .It Li PMU Ta Li lid Ta open Ta
550 device has detected the lid openinging.
551 .It Li PMU Ta Li POWER Ta ACLINE Ta
554 device has deteted an AC line state ($notify=0x00 is offline, 0x01 is online).
555 .It Li PMU Ta Li USB Ta overvoltage Ta
556 An over-voltage condition on the power lines for the USB power pins.
557 .It Li PMU Ta Li USB Ta plugged Ta
558 A device has been plugged into a USB device.
559 .It Li PMU Ta Li USB Ta undervoltage Ta
560 An under-voltage condition on the power lines for the USB power pins.
561 .It Li PMU Ta Li USB Ta unplugged Ta
562 A device has been unplugged into a USB device.
565 .Bl -column "System" "Subsystem" "1234567" -compact
566 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
568 Events related to the
571 .It Li RCTL Ta Li rule Ta Li matched Ta
572 A rule with action specified as "devctl" was triggered.
575 .Bl -column "System" "Subsystem" "1234567" -compact
576 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
578 Events related to the USB subsystem.
579 .It Li USB Ta Li DEVICE Ta Li ATTACH Ta
580 USB device is attached to the system.
581 .It Li USB Ta Li DEVICE Ta Li DETACH Ta
582 USB device is detached to the system.
583 .It Li USB Ta Li INTERFACE Ta Li ATTACH Ta
584 USB interface is attached to a device.
585 .It Li USB Ta Li INTERFACE Ta Li DETACH Ta
586 USB interface is detached from a device.
589 .Bl -column "System" "Subsystem" "1234567" -compact
590 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
592 Events from the vfs system.
593 .It Li VFS Ta Li FS Ta Ta
594 Events that change what is mounted to the system.
595 .It Li VFS Ta Li FS Ta Li MOUNT Ta
596 Notification of a filesystem is mounted for the first time.
597 .It Li VFS Ta Li FS Ta Li REMOUNT Ta
598 Notification of a filesystem is remounted (whether or not the options actually change).
599 .It Li VFS Ta Li FS Ta Li UNMOUNT Ta
600 Notification of a filesystem being unmounted.
603 .Bl -column "System" "Subsystem" "1234567" -compact
604 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
605 .It Li VT Ta BELL Ta RING Ta
606 Notification that the console bell has rung.
612 .Bl -column "System" "Subsystem" "1234567" -compact
613 .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
614 .It Li ZFS Ta ZFS Ta Ta
615 Events about the ZFS subsystem.
619 .Pa /etc/devd/zfs.conf
626 A link state change to UP on the interface
628 would result in the following notify event:
629 .Bd -literal -offset indent
630 system=IFNET subsystem=fxp0 type=LINK_UP
633 An AC line state change to
635 would result in the following event:
636 .Bd -literal -offset indent
637 system=ACPI subsystem=ACAD notify=0x00
640 Comments may appear anywhere that whitespace may appear in a
642 To appeal to programmers of all kinds, they can
643 be written in C, C++, or shell/Perl constructs.
645 C-style comments start with the two characters
647 (slash, star) and end with
650 Because they are completely delimited with these characters,
651 they can be used to comment only a portion of a line or to span
654 C-style comments cannot be nested.
655 For example, the following is
656 not valid because the entire comment ends with the first
658 .Bd -literal -offset indent
659 /* This is the start of a comment.
660 This is still part of the comment.
661 /* This is an incorrect attempt at nesting a comment. */
662 This is no longer in any comment. */
665 C++-style comments start with the two characters
667 (slash, slash) and continue to the end of the physical line.
668 They cannot be continued across multiple physical lines; to have
669 one logical comment span multiple lines, each line must use the
673 .Bd -literal -offset indent
674 // This is the start of a comment. The next line
675 // is a new comment, even though it is logically
676 // part of the previous comment.
678 .Ss Notes on Variable Expansion
679 To prevent issues with special shell characters, the following happens for each
694 variable is inserted into the buffer with all single quote characters
695 prefixed by a backslash.
700 for what this construct means.
701 It is safe in all context, except one: inside single quotes.
702 If foo=meta and bar=var, then a rule like the following:
703 .Bd -literal -offset indent -compact
704 action "echo '$foo $bar'";
706 will be presented to the shell via
709 .Bd -literal -offset indent -compact
710 echo '$'meta' $'var''
712 which produces the following output:
713 .Bd -literal -offset indent -compact
717 This is an unanticipated result.
718 A future version of this software will change this behavior.
719 Users are discouraged from using single quotes inside
721 value without due care.
723 The above should be written as
724 .Bd -literal -offset indent -compact
725 action "echo $foo' '$bar"
727 to produce a single argument to echo.
728 Given the above expansion, juxtaposing bare variables with
729 single quote expressions will produce the right output,
730 regardless of the value of the variable.
732 .Bl -tag -width ".Pa /etc/devd.conf" -compact
733 .It Pa /etc/devd.conf
741 # This will catch link down events on the interfaces fxp0 and ath0
744 match "system" "IFNET";
745 match "subsystem" "(fxp0|ath0)";
746 match "type" "LINK_DOWN";
747 action "logger $subsystem is DOWN";
751 # Match lid open/close events
752 # These can be combined to a single event, by passing the
753 # value of $notify to the external script.
756 match "system" "ACPI";
757 match "subsystem" "Lid";
758 match "notify" "0x00";
759 action "logger Lid closed, we can sleep now!";
763 match "system" "ACPI";
764 match "subsystem" "Lid";
765 match "notify" "0x01";
766 action "logger Lid opened, the sleeper must awaken!";
770 # Match a USB device type
773 match "system" "USB";
774 match "subsystem" "INTERFACE";
775 match "type" "ATTACH";
776 match "intclass" "0x0e";
777 action "logger USB video device attached";
781 # Try to configure ath and iwn devices with pccard_ether
782 # as they are attached.
785 device-name "(ath|iwn)[0-9]+";
786 action "/etc/pccard_ether $device-name start";
790 # Stop ath and iwn devices as they are detached from
794 device-name "(ath|iwn)[0-9]+";
795 action "/etc/pccard_ether $device-name stop";
801 has many additional examples.
809 The variable expansion's interaction with single quotes is
810 suboptimal and surprising.