]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/devd/devd.conf.5
Modernize a bit.
[FreeBSD/FreeBSD.git] / sbin / devd / devd.conf.5
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 .\" $FreeBSD$
25 .\"
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
29 .\"
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.
33 .\"
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
41 .\" SOFTWARE.
42 .\"
43 .Dd August 18, 2020
44 .Dt DEVD.CONF 5
45 .Os
46 .Sh NAME
47 .Nm devd.conf
48 .Nd configuration file for
49 .Xr devd 8
50 .Sh DESCRIPTION
51 .Ss General Syntax
52 A
53 .Xr devd 8
54 configuration consists of two general features, statements
55 and comments.
56 All statements end with a semicolon.
57 Many statements can contain substatements, which are also
58 terminated with a semicolon.
59 .Pp
60 The following statements are supported:
61 .Bl -tag -width ".Ic options"
62 .It Ic attach
63 Specifies various matching criteria and actions to perform when
64 a newly attached device matches said criteria.
65 .It Ic detach
66 Specifies various matching criteria and actions to perform when
67 a newly detached device matches said criteria.
68 .It Ic nomatch
69 Specifies various matching criteria and actions to perform when
70 no device driver currently loaded in the kernel claims a (new)
71 device.
72 .It Ic notify
73 Specifies various matching criteria and actions to perform when the kernel
74 sends an event notification to userland.
75 .It Ic options
76 Specifies various options and parameters for the operation of
77 .Xr devd 8 .
78 .El
79 .Pp
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.
84 .Pp
85 Each statement, except
86 .Ic options
87 has a priority (an arbitrary number) associated with it, where
88 .Ql 0
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.
94 .Pp
95 The general syntax of a statement is:
96 .Bd -literal -offset indent
97 statement priority {
98         substatement "value";
99         ...
100         substatement "value";
101 };
102 .Ed
103 .Ss Sub-statements
104 The following sub-statements are supported within the
105 .Ic options
106 statement.
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
110 .Xr devd 8
111 will read all files named "*.conf" as further
112 configuration files.
113 Any number of
114 .Ic directory
115 statements can be used.
116 .It Ic pid-file Qq Pa /var/run/devd.pid ;
117 Specifies PID file.
118 .It Ic set Ar regexp-name Qq Ar (some|regexp) ;
119 Creates a regular expression and assigns it to the variable
120 .Ar regexp-name .
121 The variable is available throughout the rest of
122 the configuration file.
123 If the string begins with
124 .Ql \&! ,
125 it matches if the regular expression formed by the rest of the string
126 does not match.
127 All regular expressions have an implicit
128 .Ql ^$
129 around them.
130 .El
131 .Pp
132 The following sub-statements are supported within the
133 .Ic attach
134 and
135 .Ic detach
136 statements.
137 .Bl -tag -width ".Ic directory"
138 .It Ic action Qq Ar command ;
139 Command to execute upon a successful match.
140 Example
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
149 .Ar string ,
150 which is allowed to be a regular expression or a variable previously created
151 containing a regular expression.
152 The
153 .Dq Li device-name
154 variable
155 is available for later use with the
156 .Ic action
157 statement.
158 .It Ic match Qo Ar variable Qc Qq Ar value ;
159 Matches the content of
160 .Ar value
161 against
162 .Ar variable ;
163 the content of
164 .Ar value
165 may be a regular expression.
166 Not required during
167 .Ic attach
168 nor
169 .Ic detach
170 events since the
171 .Ic device-name
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 ;
175 For network devices,
176 .Ic media-type
177 will match devices that have the given media type.
178 Valid media types are:
179 .Dq Li Ethernet ,
180 .Dq Li Tokenring ,
181 .Dq Li FDDI ,
182 .Dq Li 802.11 ,
183 and
184 .Dq Li ATM .
185 .It Ic subdevice Qq Ar string ;
186 This is shorthand for
187 .Dq Ic match Qo Li subdevice Qc Qq Ar string .
188 .El
189 .Pp
190 The following sub-statements are supported within the
191 .Ic nomatch
192 statement.
193 .Bl -tag -width ".Ic directory"
194 .It Ic action Qq Ar command ;
195 Same as above.
196 .It Ic match Qo Ar variable Qc Qq Ar value ;
197 Matches the content of
198 .Ar value
199 against
200 .Ar variable ;
201 the content of
202 .Ar value
203 may be a regular expression.
204 For a partial list of variables, see below.
205 .El
206 .Pp
207 The following sub-statements are supported within the
208 .Ic notify
209 statement.
210 The
211 .Dq Li notify
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.
217 Example
218 .Dq Li "/etc/rc.d/power_profile $notify" .
219 .It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ;
220 Any number of
221 .Ic match
222 statements can exist within a
223 .Ic notify
224 statement;
225 .Ar value
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 ;
229 See above.
230 .El
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
233 with the
234 .Ic match
235 statement.
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.
239 .Pp
240 .Bl -tag -width ".Li manufacturer" -compact
241 .It Ic Variable
242 .Ic Description
243 .It Li *
244 The entire message from the current event.
245 .It Li _
246 The entire message from the current event, after the initial type character.
247 .It Li timestamp
248 The time this event was processed, in seconds since 1970 dot fraction.
249 .It Li bus
250 Device name of parent bus.
251 .It Li cdev
252 Device node path if one is created by the
253 .Xr devfs 5
254 filesystem.
255 .It Li class
256 Device class.
257 .It Li comm
258 Executable name (kernel).
259 .It Li core
260 Path to core file (kernel).
261 .It Li device
262 Device ID.
263 .It Li devclass
264 Device Class (USB).
265 .It Li devsubclass
266 Device Sub-class (USB).
267 .It Li device-name
268 Name of attached/detached device.
269 .It Li endpoints
270 Endpoint count (USB).
271 .It Li function
272 Card functions.
273 .It Li interface
274 Interface ID (USB).
275 .It Li intclass
276 Interface Class (USB).
277 .It Li intprotocol
278 Interface Protocol (USB).
279 .It Li intsubclass
280 Interface Sub-class (USB).
281 .It Li jail
282 Jail name for the process triggering the rule (RCTL).
283 .It Li mode
284 Peripheral mode (USB).
285 .It Li notify
286 Match the value of the
287 .Dq Li notify
288 variable.
289 .It Li parent
290 Parent device.
291 .It Li pid
292 PID of the process triggering the rule (RCTL).
293 .It Li port
294 Hub port number (USB).
295 .It Li product
296 Product ID (USB).
297 .It Li release
298 Hardware revision (USB).
299 .It Li ruid
300 Real UID of the process triggering the rule (RCTL).
301 .It Li rule
302 Rule (RCTL).
303 .It Li sernum
304 Serial Number (USB).
305 .It Li slot
306 Card slot.
307 .It Li subvendor
308 Sub-vendor ID (PCI).
309 .It Li subdevice
310 Sub-device ID (PCI).
311 .It Li subsystem
312 Matches a subsystem of a system, see below.
313 .It Li system
314 Matches a system type, see below.
315 .It Li type
316 Type of notification, see below.
317 .It Li vendor
318 Vendor ID.
319 .El
320 .Ss Notify matching
321 A partial list of systems, subsystems, and types used within the
322 .Ic notify
323 mechanism.
324 .Pp
325 .Bl -tag -width ".Li coretemp" -compact
326 .It Sy System
327 .It Li ACPI
328 Events related to the ACPI subsystem.
329 .Bl -tag -width ".Sy Subsystem" -compact
330 .It Sy Subsystem
331 .It Li ACAD
332 AC line state ($notify=0x00 is offline, 0x01 is online).
333 .It Li Button
334 Button state ($notify=0x00 is power, 0x01 is sleep).
335 .It Li CMBAT
336 Battery events.
337 .It Li Dock
338 Dock state ($notify=0x00 is undocked, 0x01 is docked).
339 .It Li Lid
340 Lid state ($notify=0x00 is closed, 0x01 is open).
341 .It Li PROCESSOR
342 Processor state/configuration ($notify=0x81 is a change in available Cx states).
343 .It Li Resume
344 Resume notification.
345 .It Li Suspend
346 Suspend notification.
347 .It Li Thermal
348 Thermal zone events.
349 .El
350 .Pp
351 .It Li CARP
352 Events related to the
353 .Xr carp 4
354 protocol.
355 .Bl -tag -width ".Sy Subsystem" -compact
356 .It Sy Subsystem
357 .It Ar vhid@interface
358 The
359 .Dq subsystem
360 contains the actual CARP vhid and the name of the network interface
361 on which the event took place.
362 .Bl -tag -width ".Li MASTER" -compact
363 .It Sy Type
364 .It Li MASTER
365 Node become the master for a virtual host.
366 .It Li BACKUP
367 Node become the backup for a virtual host.
368 .El
369 .El
370 .Pp
371 .It Li IFNET
372 Events related to the network subsystem.
373 .Bl -tag -width ".Sy Subsystem" -compact
374 .It Sy Subsystem
375 .It Ar interface
376 The
377 .Dq subsystem
378 is the actual name of the network interface on which the event
379 took place.
380 .Bl -tag -width ".Li LINK_DOWN" -compact
381 .It Sy Type
382 .It Li LINK_UP
383 Carrier status changed to UP.
384 .It Li LINK_DOWN
385 Carrier status changed to DOWN.
386 .It Li ATTACH
387 The network interface is attached to the system.
388 .It Li DETACH
389 The network interface is detached from the system.
390 .El
391 .El
392 .Pp
393 .It Li DEVFS
394 Events related to the
395 .Xr devfs 5
396 filesystem.
397 .Bl -tag -width ".Sy Subsystem" -compact
398 .It Sy Subsystem
399 .It Li CDEV
400 .Bl -tag -width ".Li DESTROY" -compact
401 .It Sy Type
402 .It Li CREATE
403 The
404 .Xr devfs 5
405 node is created.
406 .It Li DESTROY
407 The
408 .Xr devfs 5
409 node is destroyed.
410 .El
411 .El
412 .Pp
413 .It Li GEOM
414 Events related to the
415 .Xr geom 4
416 framework.
417 The difference compared to
418 .Li DEVFS
419 is that
420 .Li GEOM
421 only includes disk-like devices.
422 .Bl -tag -width ".Sy Subsystem" -compact
423 .It Sy Subsystem
424 .It Li DEV
425 .Bl -tag -width ".Li MEDIACHANGE" -compact
426 .It Sy Type
427 .It Li CREATE
428 A
429 .Xr geom 4
430 provider is created.
431 .It Li DESTROY
432 A
433 .Xr geom 4
434 provider is destroyed.
435 .It Li GEOM::physpath
436 The physical path of a device has changed.
437 .It Li MEDIACHANGE
438 Physical media has changed.
439 .It Li SIZECHANGE
440 A
441 .Xr geom 4
442 provider size has changed.
443 .El
444 .El
445 .Pp
446 .It Li RCTL
447 Events related to the
448 .Xr rctl 8
449 framework.
450 .Bl -tag -width ".Sy Subsystem" -compact
451 .It Sy Subsystem
452 .It Li rule
453 .Bl -tag -width ".Li matched" -compact
454 .It Sy Type
455 .It Li matched
456 A rule with action specified as "devctl" was triggered.
457 .El
458 .El
459 .Pp
460 .It Li USB
461 Events related to the USB subsystem.
462 .Bl -tag -width ".Sy Subsystem" -compact
463 .It Sy Subsystem
464 .It Li DEVICE
465 .Bl -tag -width ".Li DETACH" -compact
466 .It Sy Type
467 .It Li ATTACH
468 USB device is attached to the system.
469 .It Li DETACH
470 USB device is detached from the system.
471 .El
472 .It Li INTERFACE
473 .Bl -tag -width ".Li DETACH" -compact
474 .It Sy Type
475 .It Li ATTACH
476 USB interface is attached to a device.
477 .It Li DETACH
478 USB interface is detached from a device.
479 .El
480 .El
481 .Pp
482 .It Li coretemp
483 Events related to the
484 .Xr coretemp 4
485 device.
486 .Bl -tag -width ".Sy Subsystem" -compact
487 .It Sy Subsystem
488 .It Li Thermal
489 Notification that the CPU core has reached critical temperature.
490 .Bl -tag -width ".Ar temperature" -compact
491 .It Sy Type
492 .It Ar temperature
493 String containing the temperature of the core that has become too hot.
494 .El
495 .El
496 .Pp
497 .It Li kern
498 Events related to the kernel.
499 .Bl -tag -width ".Sy Subsystem" -compact
500 .It Sy Subsystem
501 .It Li power
502 .Bl -tag -width ".li resume" -compact
503 .It Sy Type
504 .It Li resume
505 Notification that the system has woken from the suspended state.
506 .El
507 .El
508 .Pp
509 .It Li kernel
510 More events related to the kernel.
511 .Bl -tag -width ".Sy Subsystem" -compact
512 .It Sy Subsystem
513 .It Li signal
514 .Bl -tag -width ".li resume" -compact
515 .It Sy Type
516 .It Li coredump
517 Notification that a process has crashed and dumped core.
518 .El
519 .El
520 .Pp
521 .It Li CAM
522 Events related to the
523 .Xr cam 4
524 system.
525 .Bl -tag -width ".Sy Subsystem" -compact
526 .It Sy Subsystem
527 .It Li periph
528 Events related to peripheral devices.
529 .Bl -tag -width ".li timeout" -compact
530 .It Sy Type
531 .It Li error
532 Generic errors.
533 .It Li timeout
534 Command timeouts.
535 .El
536 .El
537 .El
538 .Pp
539 A link state change to UP on the interface
540 .Dq Li fxp0
541 would result in the following notify event:
542 .Bd -literal -offset indent
543 system=IFNET, subsystem=fxp0, type=LINK_UP
544 .Ed
545 .Pp
546 An AC line state change to
547 .Dq offline
548 would result in the following event:
549 .Bd -literal -offset indent
550 system=ACPI, subsystem=ACAD, notify=0x00
551 .Ed
552 .Ss Comments
553 Comments may appear anywhere that whitespace may appear in a
554 configuration file.
555 To appeal to programmers of all kinds, they can
556 be written in C, C++, or shell/Perl constructs.
557 .Pp
558 C-style comments start with the two characters
559 .Ql /*
560 (slash, star) and end with
561 .Ql */
562 (star, slash).
563 Because they are completely delimited with these characters,
564 they can be used to comment only a portion of a line or to span
565 multiple lines.
566 .Pp
567 C-style comments cannot be nested.
568 For example, the following is
569 not valid because the entire comment ends with the first
570 .Ql */ :
571 .Bd -literal -offset indent
572 /* This is the start of a comment.
573    This is still part of the comment.
574 /* This is an incorrect attempt at nesting a comment. */
575    This is no longer in any comment. */
576 .Ed
577 .Pp
578 C++-style comments start with the two characters
579 .Ql //
580 (slash, slash) and continue to the end of the physical line.
581 They cannot be continued across multiple physical lines; to have
582 one logical comment span multiple lines, each line must use the
583 .Ql //
584 pair.
585 For example:
586 .Bd -literal -offset indent
587 // This is the start of a comment.  The next line
588 // is a new comment, even though it is logically
589 // part of the previous comment.
590 .Ed
591 .Sh FILES
592 .Bl -tag -width ".Pa /etc/devd.conf" -compact
593 .It Pa /etc/devd.conf
594 The
595 .Xr devd 8
596 configuration file.
597 .El
598 .Sh EXAMPLES
599 .Bd -literal
600 #
601 # This will catch link down events on the interfaces fxp0 and ath0
602 #
603 notify 0 {
604         match "system"                  "IFNET";
605         match "subsystem"               "(fxp0|ath0)";
606         match "type"                    "LINK_DOWN";
607         action "logger $subsystem is DOWN";
608 };
609
610 #
611 # Match lid open/close events
612 # These can be combined to a single event, by passing the
613 # value of $notify to the external script.
614 #
615 notify 0 {
616         match "system"                  "ACPI";
617         match "subsystem"               "Lid";
618         match "notify"                  "0x00";
619         action "logger Lid closed, we can sleep now!";
620 };
621
622 notify 0 {
623         match "system"                  "ACPI";
624         match "subsystem"               "Lid";
625         match "notify"                  "0x01";
626         action "logger Lid opened, the sleeper must awaken!";
627 };
628
629 #
630 # Match a USB device type
631 #
632 notify 0 {
633         match "system"                  "USB";
634         match "subsystem"               "INTERFACE";
635         match "type"                    "ATTACH";
636         match "intclass"                "0x0e";
637         action "logger USB video device attached";
638 };
639
640 #
641 # Try to configure ath and iwn devices with pccard_ether
642 # as they are attached.
643 #
644 attach 0 {
645         device-name "(ath|iwn)[0-9]+";
646         action "/etc/pccard_ether $device-name start";
647 };
648
649 #
650 # Stop ath and iwn devices as they are detached from
651 # the system.
652 #
653 detach 0 {
654         device-name "(ath|iwn)[0-9]+";
655         action "/etc/pccard_ether $device-name stop";
656 };
657 .Ed
658 .Pp
659 The installed
660 .Pa /etc/devd.conf
661 has many additional examples.
662 .Sh SEE ALSO
663 .Xr cam 4 ,
664 .Xr coretemp 4 ,
665 .Xr devfs 5 ,
666 .Xr re_format 7 ,
667 .Xr devd 8