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
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:
185 .It Ic subdevice Qq Ar string ;
186 This is shorthand for
187 .Dq Ic match Qo Li subdevice Qc Qq Ar string .
190 The following sub-statements are supported within the
193 .Bl -tag -width ".Ic directory"
194 .It Ic action Qq Ar command ;
196 .It Ic match Qo Ar variable Qc Qq Ar value ;
197 Matches the content of
203 may be a regular expression.
204 For a partial list of variables, see below.
207 The following sub-statements are supported within the
212 variable is available inside this statement and contains, a value, depending
213 on which system and subsystem that delivered the event.
214 .Bl -tag -width ".Ic directory"
215 .It Ic action Qq Ar command ;
216 Command to execute upon a successful match.
218 .Dq Li "/etc/rc.d/power_profile $notify" .
219 .It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ;
222 statements can exist within a
226 can be either a fixed string or a regular expression.
227 Below is a list of available systems, subsystems, and types.
228 .It Ic media-type Qq Ar string ;
231 .Ss Variables that can be used with the match statement
232 A partial list of variables and their possible values that can be used together
236 The variables are published by the bus based on characteristics of the device
237 that generated the event (for device events).
238 Variables for other classes of events are dependent on those events.
240 .Bl -tag -width ".Li manufacturer" -compact
244 The entire message from the current event.
246 The entire message from the current event, after the initial type character.
248 The time this event was processed, in seconds since 1970 dot fraction.
250 Device name of parent bus.
252 Device node path if one is created by the
262 Executable name (kernel).
264 Path to core file (kernel).
270 Device Sub-class (USB).
272 Name of attached/detached device.
274 Endpoint count (USB).
280 Interface Class (USB).
282 Interface Protocol (USB).
284 Interface Sub-class (USB).
286 Jail name for the process triggering the rule (RCTL).
288 Manufacturer ID (pccard).
290 Peripheral mode (USB).
292 Match the value of the
298 PID of the process triggering the rule (RCTL).
300 Hub port number (USB).
302 Product ID (pccard/USB).
304 Hardware revision (USB).
306 Real UID of the process triggering the rule (RCTL).
318 Matches a subsystem of a system, see below.
320 Matches a system type, see below.
322 Type of notification, see below.
327 A partial list of systems, subsystems, and types used within the
331 .Bl -tag -width ".Li coretemp" -compact
334 Events related to the ACPI subsystem.
335 .Bl -tag -width ".Sy Subsystem" -compact
338 AC line state ($notify=0x00 is offline, 0x01 is online).
340 Button state ($notify=0x00 is power, 0x01 is sleep).
344 Dock state ($notify=0x00 is undocked, 0x01 is docked).
346 Lid state ($notify=0x00 is closed, 0x01 is open).
348 Processor state/configuration ($notify=0x81 is a change in available Cx states).
352 Suspend notification.
358 Events related to the
361 .Bl -tag -width ".Sy Subsystem" -compact
363 .It Ar vhid@interface
366 contains the actual CARP vhid and the name of the network interface
367 on which the event took place.
368 .Bl -tag -width ".Li MASTER" -compact
371 Node become the master for a virtual host.
373 Node become the backup for a virtual host.
378 Events related to the network subsystem.
379 .Bl -tag -width ".Sy Subsystem" -compact
384 is the actual name of the network interface on which the event
386 .Bl -tag -width ".Li LINK_DOWN" -compact
389 Carrier status changed to UP.
391 Carrier status changed to DOWN.
393 The network interface is attached to the system.
395 The network interface is detached from the system.
400 Events related to the
403 .Bl -tag -width ".Sy Subsystem" -compact
406 .Bl -tag -width ".Li DESTROY" -compact
420 Events related to the
423 The difference compared to
427 only includes disk-like devices.
428 .Bl -tag -width ".Sy Subsystem" -compact
431 .Bl -tag -width ".Li MEDIACHANGE" -compact
440 provider is destroyed.
441 .It Li GEOM::physpath
442 The physical path of a device has changed.
444 Physical media has changed.
448 provider size has changed.
453 Events related to the
456 .Bl -tag -width ".Sy Subsystem" -compact
459 .Bl -tag -width ".Li matched" -compact
462 A rule with action specified as "devctl" was triggered.
467 Events related to the USB subsystem.
468 .Bl -tag -width ".Sy Subsystem" -compact
471 .Bl -tag -width ".Li DETACH" -compact
474 USB device is attached to the system.
476 USB device is detached from the system.
479 .Bl -tag -width ".Li DETACH" -compact
482 USB interface is attached to a device.
484 USB interface is detached from a device.
489 Events related to the
492 .Bl -tag -width ".Sy Subsystem" -compact
495 Notification that the CPU core has reached critical temperature.
496 .Bl -tag -width ".Ar temperature" -compact
499 String containing the temperature of the core that has become too hot.
504 Events related to the kernel.
505 .Bl -tag -width ".Sy Subsystem" -compact
508 .Bl -tag -width ".li resume" -compact
511 Notification that the system has woken from the suspended state.
516 More events related to the kernel.
517 .Bl -tag -width ".Sy Subsystem" -compact
520 .Bl -tag -width ".li resume" -compact
523 Notification that a process has crashed and dumped core.
528 Events related to the
531 .Bl -tag -width ".Sy Subsystem" -compact
534 Events related to peripheral devices.
535 .Bl -tag -width ".li timeout" -compact
545 A link state change to UP on the interface
547 would result in the following notify event:
548 .Bd -literal -offset indent
549 system=IFNET, subsystem=fxp0, type=LINK_UP
552 An AC line state change to
554 would result in the following event:
555 .Bd -literal -offset indent
556 system=ACPI, subsystem=ACAD, notify=0x00
559 Comments may appear anywhere that whitespace may appear in a
561 To appeal to programmers of all kinds, they can
562 be written in C, C++, or shell/Perl constructs.
564 C-style comments start with the two characters
566 (slash, star) and end with
569 Because they are completely delimited with these characters,
570 they can be used to comment only a portion of a line or to span
573 C-style comments cannot be nested.
574 For example, the following is
575 not valid because the entire comment ends with the first
577 .Bd -literal -offset indent
578 /* This is the start of a comment.
579 This is still part of the comment.
580 /* This is an incorrect attempt at nesting a comment. */
581 This is no longer in any comment. */
584 C++-style comments start with the two characters
586 (slash, slash) and continue to the end of the physical line.
587 They cannot be continued across multiple physical lines; to have
588 one logical comment span multiple lines, each line must use the
592 .Bd -literal -offset indent
593 // This is the start of a comment. The next line
594 // is a new comment, even though it is logically
595 // part of the previous comment.
598 .Bl -tag -width ".Pa /etc/devd.conf" -compact
599 .It Pa /etc/devd.conf
607 # This will catch link down events on the interfaces fxp0 and ath0
610 match "system" "IFNET";
611 match "subsystem" "(fxp0|ath0)";
612 match "type" "LINK_DOWN";
613 action "logger $subsystem is DOWN";
617 # Match lid open/close events
618 # These can be combined to a single event, by passing the
619 # value of $notify to the external script.
622 match "system" "ACPI";
623 match "subsystem" "Lid";
624 match "notify" "0x00";
625 action "logger Lid closed, we can sleep now!";
629 match "system" "ACPI";
630 match "subsystem" "Lid";
631 match "notify" "0x01";
632 action "logger Lid opened, the sleeper must awaken!";
636 # Match a USB device type
639 match "system" "USB";
640 match "subsystem" "INTERFACE";
641 match "type" "ATTACH";
642 match "intclass" "0x0e";
643 action "logger USB video device attached";
647 # Try to configure ath and wi devices with pccard_ether
648 # as they are attached.
651 device-name "(ath|wi)[0-9]+";
652 action "/etc/pccard_ether $device-name start";
656 # Stop ath and wi devices as they are detached from
660 device-name "(ath|wi)[0-9]+";
661 action "/etc/pccard_ether $device-name stop";
667 has many additional examples.