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