]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sbin/devd/devd.conf.5
MFC of 286750,tzdata8:
[FreeBSD/stable/8.git] / sbin / devd / devd.conf.5
1 .\"
2 .\" Copyright (c) 2002 M. Warner Losh
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. The name of the author may not be used to endorse or promote products
11 .\"    derived from this software without specific prior written permission.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .\" The section on comments was taken from named.conf.5, which has the
28 .\" following copyright:
29 .\" Copyright (c) 1999-2000 by Internet Software Consortium
30 .\"
31 .\" Permission to use, copy, modify, and distribute this software for any
32 .\" purpose with or without fee is hereby granted, provided that the above
33 .\" copyright notice and this permission notice appear in all copies.
34 .\"
35 .\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
36 .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
37 .\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
38 .\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
39 .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
40 .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
41 .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
42 .\" SOFTWARE.
43 .\"
44 .Dd March 4, 2013
45 .Dt DEVD.CONF 5
46 .Os
47 .Sh NAME
48 .Nm devd.conf
49 .Nd configuration file for
50 .Xr devd 8
51 .Sh DESCRIPTION
52 .Ss General Syntax
53 A
54 .Xr devd 8
55 configuration consists of two general features, statements
56 and comments.
57 All statements end with a semicolon.
58 Many statements can contain substatements, which are also
59 terminated with a semicolon.
60 .Pp
61 The following statements are supported:
62 .Bl -tag -width ".Ic options"
63 .It Ic attach
64 Specifies various matching criteria and actions to perform when
65 a newly attached device matches said criteria.
66 .It Ic detach
67 Specifies various matching criteria and actions to perform when
68 a newly detached device matches said criteria.
69 .It Ic nomatch
70 Specifies various matching criteria and actions to perform when
71 no device driver currently loaded in the kernel claims a (new)
72 device.
73 .It Ic notify
74 Specifies various matching criteria and actions to perform when the kernel
75 sends an event notification to userland.
76 .It Ic options
77 Specifies various options and parameters for the operation of
78 .Xr devd 8 .
79 .El
80 .Pp
81 Statements may occur in any order in the configuration file, and may be
82 repeated as often as required.
83 Further details on the syntax and meaning of each statement and their
84 substatements are explained below.
85 .Pp
86 Each statement, except
87 .Ic options
88 has a priority (an arbitrary number) associated with it, where
89 .Ql 0
90 is defined as the lowest priority.
91 If two statements match the same event, only the action of the statement with
92 highest priority will be executed.
93 In this way generic statements can be overridden for devices or
94 notifications that require special attention.
95 .Pp
96 The general syntax of a statement is:
97 .Pp
98 .Bd -literal -offset indent
99 statement priority {
100         substatement "value";
101         ...
102         substatement "value";
103 };
104 .Ed
105 .Ss Sub-statements
106 The following sub-statements are supported within the
107 .Ic options
108 statement.
109 .Bl -tag -width ".Ic directory"
110 .It Ic directory Qq Ar /some/path ;
111 Adds the given directory to the list of directories from which
112 .Xr devd 8
113 will read all files named "*.conf" as further
114 configuration files.
115 Any number of
116 .Ic directory
117 statements can be used.
118 .It Ic pid-file Qq Pa /var/run/devd.pid ;
119 Specifies PID file.
120 .It Ic set Ar regexp-name Qq Ar (some|regexp) ;
121 Creates a regular expression and assigns it to the variable
122 .Ar regexp-name .
123 The variable is available throughout the rest of
124 the configuration file.
125 If the string begins with
126 .Ql \&! ,
127 it matches if the regular expression formed by the rest of the string
128 does not match.
129 All regular expressions have an implicit
130 .Ql ^$
131 around them.
132 .El
133 .Pp
134 The following sub-statements are supported within the
135 .Ic attach
136 and
137 .Ic detach
138 statements.
139 .Bl -tag -width ".Ic directory"
140 .It Ic action Qq Ar command ;
141 Command to execute upon a successful match.
142 Example
143 .Dq Li "/etc/pccard_ether $device-name start" .
144 .It Ic class Qq Ar string ;
145 This is shorthand for
146 .Dq Ic match Qo Li class Qc Qq Ar string .
147 .It Ic device-name Qq string ;
148 This is shorthand for
149 .Dq Ic match Qo Li device-name Qc Qq Ar string .
150 This matches a device named
151 .Ar string ,
152 which is allowed to be a regular expression or a variable previously created
153 containing a regular expression.
154 The
155 .Dq Li device-name
156 variable
157 is available for later use with the
158 .Ic action
159 statement.
160 .It Ic match Qo Ar variable Qc Qq Ar value ;
161 Matches the content of
162 .Ar value
163 against
164 .Ar variable ;
165 the content of
166 .Ar value
167 may be a regular expression.
168 Not required during
169 .Ic attach
170 nor
171 .Ic detach
172 events since the
173 .Ic device-name
174 statement takes care of all device matching.
175 For a partial list of variables, see below.
176 .It Ic media-type Qq Ar string ;
177 For network devices,
178 .Ic media-type
179 will match devices that have the given media type.
180 Valid media types are:
181 .Dq Li Ethernet ,
182 .Dq Li Tokenring ,
183 .Dq Li FDDI ,
184 .Dq Li 802.11 ,
185 .Dq Li ATM ,
186 and
187 .Dq Li CARP .
188 .It Ic subdevice Qq Ar string ;
189 This is shorthand for
190 .Dq Ic match Qo Li subdevice Qc Qq Ar string .
191 .El
192 .Pp
193 The following sub-statements are supported within the
194 .Ic nomatch
195 statement.
196 .Bl -tag -width ".Ic directory"
197 .It Ic action Qq Ar command ;
198 Same as above.
199 .It Ic match Qo Ar variable Qc Qq Ar value ;
200 Matches the content of
201 .Ar value
202 against
203 .Ar variable ;
204 the content of
205 .Ar value
206 may be a regular expression.
207 For a partial list of variables, see below.
208 .El
209 .Pp
210 The following sub-statements are supported within the
211 .Ic notify
212 statement.
213 The
214 .Dq Li notify
215 variable is available inside this statement and contains, a value, depending
216 on which system and subsystem that delivered the event.
217 .Bl -tag -width ".Ic directory"
218 .It Ic action Qq Ar command ;
219 Command to execute upon a successful match.
220 Example
221 .Dq Li "/etc/rc.d/power_profile $notify" .
222 .It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ;
223 Any number of
224 .Ic match
225 statements can exist within a
226 .Ic notify
227 statement;
228 .Ar value
229 can be either a fixed string or a regular expression.
230 Below is a list of available systems, subsystems, and types.
231 .It Ic media-type Qq Ar string ;
232 See above.
233 .El
234 .Ss Variables that can be used with the match statement
235 A partial list of variables and their possible values that can be used together
236 with the
237 .Ic match
238 statement.
239 .Pp
240 .Bl -tag -width ".Li manufacturer" -compact
241 .It Ic Variable
242 .Ic Description
243 .It Li bus
244 Device name of parent bus.
245 .It Li cdev
246 Device node path if one is created by the
247 .Xr devfs 5
248 filesystem.
249 .It Li cisproduct
250 CIS-product.
251 .It Li cisvendor
252 CIS-vendor.
253 .It Li class
254 Device class.
255 .It Li device
256 Device ID.
257 .It Li devclass
258 Device Class (USB)
259 .It Li devsubclass
260 Device Sub-class (USB)
261 .It Li device-name
262 Name of attached/detached device.
263 .It Li endpoints
264 Endpoint count (USB)
265 .It Li function
266 Card functions.
267 .It Li interface
268 Interface ID (USB)
269 .It Li intclass
270 Interface Class (USB)
271 .It Li intprotocol
272 Interface Protocol  (USB)
273 .It Li intsubclass
274 Interface Sub-class (USB)
275 .It Li manufacturer
276 Manufacturer ID (pccard).
277 .It Li mode
278 Peripheral mode (USB)
279 .It Li notify
280 Match the value of the
281 .Dq Li notify
282 variable.
283 .It Li parent
284 Parent device
285 .It Li port
286 Hub port number (USB)
287 .It Li product
288 Product ID (pccard/USB).
289 .It Li release
290 Hardware revision (USB)
291 .It Li serial
292 Serial Number (USB).
293 .It Li slot
294 Card slot.
295 .It Li subvendor
296 Sub-vendor ID.
297 .It Li subdevice
298 Sub-device ID.
299 .It Li subsystem
300 Matches a subsystem of a system, see below.
301 .It Li system
302 Matches a system type, see below.
303 .It Li type
304 Type of notification, see below.
305 .It Li vendor
306 Vendor ID.
307 .El
308 .Ss Notify matching
309 A partial list of systems, subsystems, and types used within the
310 .Ic notify
311 mechanism.
312 .Pp
313 .Bl -tag -width ".Li coretemp" -compact
314 .It Sy System
315 .It Li ACPI
316 Events related to the ACPI subsystem.
317 .Bl -tag -width ".Sy Subsystem" -compact
318 .It Sy Subsystem
319 .It Li ACAD
320 AC line state ($notify=0x00 is offline, 0x01 is online).
321 .It Li Button
322 Button state ($notify=0x00 is power, 0x01 is sleep).
323 .It Li CMBAT
324 Battery events.
325 .It Li Lid
326 Lid state ($notify=0x00 is closed, 0x01 is open).
327 .It Li PROCESSOR
328 Processor state/configuration ($notify=0x81 is a change in available Cx states).
329 .It Li Thermal
330 Thermal zone events.
331 .El
332 .Pp
333 .It Li IFNET
334 Events related to the network subsystem.
335 .Bl -tag -width ".Sy Subsystem" -compact
336 .It Sy Subsystem
337 .It Ar interface
338 The
339 .Dq subsystem
340 is the actual name of the network interface on which the event
341 took place.
342 .Bl -tag -width ".Li LINK_DOWN" -compact
343 .It Sy Type
344 .It Li LINK_UP
345 Carrier status changed to UP.
346 .It Li LINK_DOWN
347 Carrier status changed to DOWN.
348 .It Li ATTACH
349 The network interface is attached to the system.
350 .It Li DETACH
351 The network interface is detached from the system.
352 .El
353 .El
354 .It Li DEVFS
355 Events related to the
356 .Xr devfs 5
357 filesystem.
358 .Bl -tag -width ".Sy Subsystem" -compact
359 .It Sy Subsystem
360 .It Li CDEV
361 .Bl -tag -width ".Li DESTROY" -compact
362 .It Sy Type
363 .It Li CREATE
364 The
365 .Xr devfs 5
366 node is created.
367 .It Li DESTROY
368 The
369 .Xr devfs 5
370 node is destroyed.
371 .El
372 .El
373 .It Li USB
374 Events related to the USB subsystem.
375 .Bl -tag -width ".Sy Subsystem" -compact
376 .It Sy Subsystem
377 .It Li DEVICE
378 .Bl -tag -width ".Li DETACH" -compact
379 .It Sy Type
380 .It Li ATTACH
381 USB device is attached to the system.
382 .It Li DETACH
383 USB device is detached from the system.
384 .El
385 .It Li INTERFACE
386 .Bl -tag -width ".Li DETACH" -compact
387 .It Sy Type
388 .It Li ATTACH
389 USB interface is attached from a device.
390 .It Li DETACH
391 USB interface is detached from a device.
392 .El
393 .El
394 .It Li coretemp
395 Events related to the
396 .Xr coretemp 4
397 device.
398 .Bl -tag -width ".Sy Subsystem" -compact
399 .It Sy Subsystem
400 .It Li Thermal
401 Notification that the CPU core has reached critical temperature.
402 .Bl -tag -width ".Ar temperature" -compact
403 .It Sy Type
404 .It Ar temperature
405 String containing the temperature of the core that has become too hot.
406 .El
407 .El
408 .It Li kern
409 Events related to the kernel.
410 .Bl -tag -width ".Sy Subsystem" -compact
411 .It Sy Subsystem
412 .It Li power
413 Information about the state of the system.
414 .Bl -tag -width ".li resume" -compact
415 .It Sy Type
416 .It Li resume
417 Notification that the system has woken from the suspended state.
418 .El
419 .El
420 .El
421 .Pp
422 A link state change to UP on the interface
423 .Dq Li fxp0
424 would result in the following notify event:
425 .Bd -literal -offset indent
426 system=IFNET, subsystem=fxp0, type=LINK_UP
427 .Ed
428 .Pp
429 An AC line state change to
430 .Dq offline
431 would result in the following event:
432 .Bd -literal -offset indent
433 system=ACPI, subsystem=ACAD, notify=0x00
434 .Ed
435 .Ss Comments
436 Comments may appear anywhere that whitespace may appear in a
437 configuration file.
438 To appeal to programmers of all kinds, they can
439 be written in C, C++, or shell/Perl constructs.
440 .Pp
441 C-style comments start with the two characters
442 .Ql /*
443 (slash, star) and end with
444 .Ql */
445 (star, slash).
446 Because they are completely delimited with these characters,
447 they can be used to comment only a portion of a line or to span
448 multiple lines.
449 .Pp
450 C-style comments cannot be nested.
451 For example, the following is
452 not valid because the entire comment ends with the first
453 .Ql */ :
454 .Bd -literal -offset indent
455 /* This is the start of a comment.
456    This is still part of the comment.
457 /* This is an incorrect attempt at nesting a comment. */
458    This is no longer in any comment. */
459 .Ed
460 .Pp
461 C++-style comments start with the two characters
462 .Ql //
463 (slash, slash) and continue to the end of the physical line.
464 They cannot be continued across multiple physical lines; to have
465 one logical comment span multiple lines, each line must use the
466 .Ql //
467 pair.
468 For example:
469 .Bd -literal -offset indent
470 // This is the start of a comment.  The next line
471 // is a new comment, even though it is logically
472 // part of the previous comment.
473 .Ed
474 .Sh FILES
475 .Bl -tag -width ".Pa /etc/devd.conf" -compact
476 .It Pa /etc/devd.conf
477 The
478 .Xr devd 8
479 configuration file.
480 .El
481 .Sh EXAMPLES
482 .Bd -literal
483 #
484 # This will catch link down events on the interfaces fxp0 and ath0
485 #
486 notify 0 {
487         match "system"                  "IFNET";
488         match "subsystem"               "(fxp0|ath0)";
489         match "type"                    "LINK_DOWN";
490         action "logger $subsystem is DOWN";
491 };
492
493 #
494 # Match lid open/close events
495 # These can be combined to a single event, by passing the
496 # value of $notify to the external script.
497 #
498 notify 0 {
499         match "system"                  "ACPI";
500         match "subsystem"               "Lid";
501         match "notify"                  "0x00";
502         action "logger Lid closed, we can sleep now!";
503 };
504
505 notify 0 {
506         match "system"                  "ACPI";
507         match "subsystem"               "Lid";
508         match "notify"                  "0x01";
509         action "logger Lid opened, the sleeper must awaken!";
510 };
511
512 #
513 # Match a USB device type
514 #
515 notify 0 {
516         match "system"                  "USB";
517         match "subsystem"               "INTERFACE";
518         match "type"                    "ATTACH";
519         match "intclass"                "0x0e";
520         action "logger USB video device attached";
521 };
522
523 #
524 # Try to configure ath and wi devices with pccard_ether
525 # as they are attached.
526 #
527 attach 0 {
528         device-name "(ath|wi)[0-9]+";
529         action "/etc/pccard_ether $device-name start";
530 };
531
532 #
533 # Stop ath and wi devices as they are detached from
534 # the system.
535 #
536 detach 0 {
537         device-name "(ath|wi)[0-9]+";
538         action "/etc/pccard_ether $device-name stop";
539 };
540 .Ed
541 .Pp
542 The installed
543 .Pa /etc/devd.conf
544 has many additional examples.
545 .Sh SEE ALSO
546 .Xr coretemp 4 ,
547 .Xr devfs 5 ,
548 .Xr devd 8