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.\" The section on comments was taken from named.conf.5, which has the 25.\" following copyright: 26.\" Copyright (c) 1999-2000 by Internet Software Consortium 27.\" 28.\" Permission to use, copy, modify, and distribute this software for any 29.\" purpose with or without fee is hereby granted, provided that the above 30.\" copyright notice and this permission notice appear in all copies. 31.\" 32.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS 33.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 34.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE 35.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 36.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 37.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 38.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 39.\" SOFTWARE. 40.\" 41.Dd December 20, 2024 42.Dt DEVD.CONF 5 43.Os 44.Sh NAME 45.Nm devd.conf 46.Nd configuration file for 47.Xr devd 8 48.Sh DESCRIPTION 49.Ss General Syntax 50A 51.Xr devd 8 52configuration consists of two general features, statements 53and comments. 54All statements end with a semicolon. 55Many statements can contain substatements, which are also 56terminated with a semicolon. 57.Pp 58The following statements are supported: 59.Bl -tag -width ".Ic options" 60.It Ic attach 61Specifies various matching criteria and actions to perform when 62a newly attached device matches said criteria. 63.It Ic detach 64Specifies various matching criteria and actions to perform when 65a newly detached device matches said criteria. 66.It Ic nomatch 67Specifies various matching criteria and actions to perform when 68no device driver currently loaded in the kernel claims a (new) 69device. 70.It Ic notify 71Specifies various matching criteria and actions to perform when the kernel 72sends an event notification to userland. 73.It Ic options 74Specifies various options and parameters for the operation of 75.Xr devd 8 . 76.El 77.Pp 78Statements may occur in any order in the configuration file, and may be 79repeated as often as required. 80Further details on the syntax and meaning of each statement and their 81substatements are explained below. 82.Pp 83Each statement, except 84.Ic options 85has a priority (an arbitrary number) associated with it, where 86.Ql 0 87is defined as the lowest priority. 88If two statements match the same event, only the action of the statement with 89highest priority will be executed. 90In this way generic statements can be overridden for devices or 91notifications that require special attention. 92.Pp 93The general syntax of a statement is: 94.Bd -literal -offset indent 95statement priority { 96 substatement "value"; 97 ... 98 substatement "value"; 99}; 100.Ed 101.Ss Sub-statements 102The following sub-statements are supported within the 103.Ic options 104statement. 105.Bl -tag -width ".Ic directory" 106.It Ic directory Qq Ar /some/path ; 107Adds the given directory to the list of directories from which 108.Xr devd 8 109will read all files named "*.conf" as further 110configuration files. 111Any number of 112.Ic directory 113statements can be used. 114.It Ic pid-file Qq Pa /var/run/devd.pid ; 115Specifies PID file. 116.It Ic set Ar regexp-name Qq Ar (some|regexp) ; 117Creates a regular expression and assigns it to the variable 118.Ar regexp-name . 119The variable is available throughout the rest of 120the configuration file. 121If the string begins with 122.Ql \&! , 123it matches if the regular expression formed by the rest of the string 124does not match. 125All regular expressions have an implicit 126.Ql ^$ 127around them. 128.El 129.Pp 130The following sub-statements are supported within the 131.Ic attach 132and 133.Ic detach 134statements. 135.Bl -tag -width ".Ic directory" 136.It Ic action Qq Ar command ; 137Command to execute upon a successful match. 138Example 139.Dq Li "/etc/pccard_ether $device-name start" . 140.It Ic class Qq Ar string ; 141This is shorthand for 142.Dq Ic match Qo Li class Qc Qq Ar string . 143.It Ic device-name Qq string ; 144This is shorthand for 145.Dq Ic match Qo Li device-name Qc Qq Ar string . 146This matches a device named 147.Ar string , 148which is allowed to be a regular expression or a variable previously created 149containing a regular expression. 150The 151.Dq Li device-name 152variable 153is available for later use with the 154.Ic action 155statement. 156.It Ic match Qo Ar variable Qc Qq Ar value ; 157Matches the content of 158.Ar value 159against 160.Ar variable ; 161the content of 162.Ar value 163may be a regular expression. 164Not required during 165.Ic attach 166nor 167.Ic detach 168events since the 169.Ic device-name 170statement takes care of all device matching. 171For a partial list of variables, see below. 172.It Ic media-type Qq Ar string ; 173For network devices, 174.Ic media-type 175will match devices that have the given media type. 176Valid media types are: 177.Dq Li Ethernet , 178.Dq Li 802.11 , 179and 180.Dq Li ATM . 181.It Ic subdevice Qq Ar string ; 182This is shorthand for 183.Dq Ic match Qo Li subdevice Qc Qq Ar string . 184.El 185.Pp 186The following sub-statements are supported within the 187.Ic nomatch 188statement. 189.Bl -tag -width ".Ic directory" 190.It Ic action Qq Ar command ; 191Same as above. 192.It Ic match Qo Ar variable Qc Qq Ar value ; 193Matches the content of 194.Ar value 195against 196.Ar variable ; 197the content of 198.Ar value 199may be a regular expression. 200For a partial list of variables, see below. 201.El 202.Pp 203The following sub-statements are supported within the 204.Ic notify 205statement. 206The 207.Dq Li notify 208variable is available inside this statement and contains, a value, depending 209on which system and subsystem that delivered the event. 210.Bl -tag -width ".Ic directory" 211.It Ic action Qq Ar command ; 212Command to execute upon a successful match. 213Example 214.Dq Li "/etc/rc.d/power_profile $notify" . 215.It Ic match Qo Ar system | subsystem | type | notify Qc Qq Ar value ; 216Any number of 217.Ic match 218statements can exist within a 219.Ic notify 220statement; 221.Ar value 222can be either a fixed string or a regular expression. 223Below is a list of available systems, subsystems, and types. 224.It Ic media-type Qq Ar string ; 225See above. 226.El 227.Ss Variables that can be used with the match statement 228A partial list of variables and their possible values that can be used together 229with the 230.Ic match 231statement. 232The variables are published by the bus based on characteristics of the device 233that generated the event (for device events). 234Variables for other classes of events are dependent on those events. 235.Pp 236.Bl -tag -width ".Li manufacturer" -compact 237.It Ic Variable 238.Ic Description 239.It Li * 240The entire message from the current event. 241.It Li _ 242The entire message from the current event, after the initial type character. 243.It Li timestamp 244The time this event was processed, in seconds since 1970 dot fraction. 245.It Li bus 246Device name of parent bus. 247.It Li cdev 248Device node path if one is created by the 249.Xr devfs 5 250filesystem. 251.It Li class 252Device class. 253.It Li comm 254Executable name (kernel). 255.It Li core 256Path to core file (kernel). 257.It Li device 258Device ID. 259.It Li devclass 260Device Class (USB). 261.It Li devsubclass 262Device Sub-class (USB). 263.It Li device-name 264Name of attached/detached device. 265.It Li endpoints 266Endpoint count (USB). 267.It Li function 268Card functions. 269.It Li interface 270Interface ID (USB). 271.It Li intclass 272Interface Class (USB). 273.It Li intprotocol 274Interface Protocol (USB). 275.It Li intsubclass 276Interface Sub-class (USB). 277.It Li jail 278Jail name for the process triggering the rule (RCTL). 279.It Li mode 280Peripheral mode (USB). 281.It Li notify 282Match the value of the 283.Dq Li notify 284variable. 285.It Li parent 286Parent device. 287.It Li pid 288PID of the process triggering the rule (RCTL). 289.It Li port 290Hub port number (USB). 291.It Li product 292Product ID (USB). 293.It Li release 294Hardware revision (USB). 295.It Li ruid 296Real UID of the process triggering the rule (RCTL). 297.It Li rule 298Rule (RCTL). 299.It Li sernum 300Serial Number (USB). 301.It Li slot 302Card slot. 303.It Li subvendor 304Sub-vendor ID (PCI). 305.It Li subdevice 306Sub-device ID (PCI). 307.It Li subsystem 308Matches a subsystem of a system, see below. 309.It Li system 310Matches a system type, see below. 311.It Li type 312Type of notification, see below. 313.It Li vendor 314Vendor ID. 315.El 316.Ss Notify matching 317A partial list of systems, subsystems, and types used within the 318.Ic notify 319mechanism. 320.\" 321.\" Please keep these tables sorted. Also, please use the same parameters 322.\" for each of the tables so that things line up in columns nicely. 323.\" Please do not omit the type column for notifiers that omit it. 324.Pp 325.Bl -column "System" "Subsystem" "1234567" -compact 326.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 327.It Li ACPI Ta Ta Ta 328Events related to the ACPI Subsystem. 329.It Li ACPI Ta Li ACAD Ta Ta 330AC line state ($notify=0x00 is offline, 0x01 is online). 331.It Li ACPI Ta Li Button Ta Ta 332Button state ($notify=0x00 is power, 0x01 is sleep). 333.It Li ACPI Ta Li CMBAT Ta Ta 334Battery events. 335.It Li ACPI Ta Li Dock Ta Ta 336Dock state ($notify=0x00 is undocked, 0x01 is docked). 337.It Li ACPI Ta Li Lid Ta Ta 338Lid state ($notify=0x00 is closed, 0x01 is open). 339.It Li ACPI Ta Li PROCESSOR Ta Ta 340Processor state/configuration ($notify=0x81 is a change in available Cx states). 341.It Li ACPI Ta Li Resume Ta Ta 342Resume notification. 343.It Li ACPI Ta Li Suspend Ta Ta 344Suspend notification. 345.It Li ACPI Ta Li Thermal Ta Ta 346Thermal zone events. 347.El 348.Pp 349.Bl -column "System" "Subsystem" "1234567" -compact 350.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 351.It Li AEON Ta Li power Ta Li press Ta 352The power button on an Amiga has been pressed. 353.El 354.Pp 355.Bl -column "System" "Subsystem" "1234567" -compact 356.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 357.It Li CAM Ta Ta Ta 358Events related to the 359.Xr cam 4 360system. 361.It Li CAM Ta Li periph Ta Ta 362Events related to peripheral devices. 363.It Li CAM Ta Li periph Ta Li error Ta 364Generic errors. 365.It Li CAM Ta Li periph Ta Li timeout Ta 366Command timeouts. 367.El 368.Pp 369.Bl -column "System" "Subsystem" "1234567" -compact 370.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 371.It Li CARP Ta Ta Ta 372Events related to the 373.Xr carp 4 374protocol. 375.It CARP Ta Ar vhid@inet Ta Ta 376The 377.Dq subsystem 378contains the actual CARP vhid and the name of the network interface 379on which the event took place. 380.It CARP Ta Ar vhid@inet Ta MASTER Ta 381Node become the master for a virtual host. 382.It CARP Ta Ar vhid@inet Ta BACKUP Ta 383Node become the backup for a virtual host. 384.El 385.Pp 386.Bl -column "System" "Subsystem" "1234567" -compact 387.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 388.It Li coretemp Ta Ta Ta 389Events related to the 390.Xr coretemp 4 391device. 392.It Li coretemp Ta Li Thermal Ta Ta 393Notification that the CPU core has reached critical temperature. 394.It Li coretemp Ta Li Thermal Ta Li temperature Ta 395String containing the temperature of the core that has become too hot. 396.El 397.Pp 398.Bl -column "System" "Subsystem" "1234567" -compact 399.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 400.It Li DEVFS 401.It Li DEVFS Ta Li CDEV Ta Li CREATE Ta 402The 403.Xr devfs 5 404node is created. 405.It Li DEVFS Ta Li CDEV Ta Li DESTROY Ta 406The 407.Xr devfs 5 408node is destroyed. 409.El 410.Pp 411.Bl -column "System" "Subsystem" "1234567" -compact 412.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 413.It Li ETHERNET Ta Ar inet Ta IFATTACH Ta 414Notification when the default VNET instance of the 415.Em inet 416interface is attached. 417.El 418.Pp 419.Bl -column "System" "Subsystem" "1234567" -compact 420.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 421.It Li GEOM Ta Ta Ta 422Events related to the 423.Xr geom 4 424framework. 425The difference compared to 426.Li DEVFS 427is that 428.Li GEOM 429only includes disk-like devices. 430.It Li GEOM Ta Li DEV Ta Li CREATE Ta 431A 432.Xr geom 4 433provider is created. 434.It Li GEOM Ta Li DEV Ta Li DESTROY Ta 435A 436.Xr geom 4 437provider is destroyed. 438.It Li GEOM Ta Li DEV Ta Li GEOM::physpath Ta 439The physical path of a device has changed. 440.It Li GEOM Ta Li DEV Ta Li GEOM::rotation_rate Ta 441The rotation rate of the disk has changed. 442.It Li GEOM Ta Li DEV Ta Li MEDIACHANGE Ta 443Physical media has changed. 444.It Li GEOM Ta Li DEV Ta Li SIZECHANGE Ta 445A 446.Xr geom 4 447provider size has changed. 448.El 449.Pp 450.Bl -column "System" "Subsystem" "1234567" -compact 451.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 452.It Li IFNET 453.It Li IFNET Ta Em inet Ta Ta 454The 455.Dq subsystem 456is the actual name of the network interface on which the event 457took place. 458.It Li IFNET Ta Em inet Ta Li LINK_UP Ta 459Carrier status changed to UP. 460.It Li IFNET Ta Em inet Ta Li LINK_DOWN Ta 461Carrier status changed to DOWN. 462.It Li IFNET Ta Em inet Ta Li ATTACH Ta 463The network interface is attached to the system. 464.It Li IFNET Ta Em inet Ta Li DETACH Ta 465The network interface is detached from the system. 466.El 467.Pp 468.Bl -column "System" "Subsystem" "1234567" -compact 469.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 470.It Li kern Ta Li power Ta Li resume Ta 471Notification that the system has woken from the suspended state. 472Note: this notification is deprecated and will be removed in 473.Fx 14.0 . 474.El 475.Pp 476.Bl -column "System" "Subsystem" "1234567" -compact 477.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 478.It Li kernel Ta Li signal Ta Li coredump Ta 479Notification that a process has crashed and dumped core. 480.It Li kernel Ta Li power Ta Li resume Ta 481Notification that the system has woken from the suspended state. 482.El 483.Pp 484.Bl -column "System" "Subsystem" "1234567" -compact 485.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 486.It Li PMU Ta Ta Ta 487Notification of events from various types of Power Management Units. 488.It Li PMU Ta Li "AC" Ta Ta 489Notifications of AC power related events. 490.It Li PMU Ta Li "AC" Ta Li overvoltage Ta 491An over-voltage condition was detected on the AC power line. 492.It Li PMU Ta Li "AC" Ta Li plugged Ta 493Power has been applied to the AC power line. 494.It Li PMU Ta Li "AC" Ta Li unplugged Ta 495Power has been removed from the AC power line. 496.It Li PMU Ta Li Battery Ta Ta 497.It Li PMU Ta Li Battery Ta absent Ta 498Battery is no longer absent. 499.It Li PMU Ta Li Battery Ta charged Ta 500The battery has become charged. 501.It Li PMU Ta Li Battery Ta charging Ta 502The battery has started charging. 503.It Li PMU Ta Li Battery Ta disconnected Ta 504The battery has been disconnected. 505.It Li PMU Ta Li Battery Ta high-temp Ta 506The battery reported a temperature over the limit. 507.It Li PMU Ta Li Battery Ta low-temp Ta 508The battery reported a temperature under the limit. 509.It Li PMU Ta Li Battery Ta plugged Ta 510The battery has become plugged (eg connected). 511.It Li PMU Ta Li Battery Ta shutdown-threshold Ta 512The power in the battery has fallen below the shutdown threshold. 513.It Li PMU Ta Li Battery Ta warning-threshold Ta 514The power in the battery has fallen below the warn the user threshold. 515.It Li PMU Ta Li Button Ta pressed Ta 516A button on a 517.Xr adb 4 518or 519.Xr pmu 4 520has been pressed. 521.It Li PMU Ta Li keys Ta Ta 522One of the keys on the 523.Xr adb 4 524keyboard has been pressed. 525.It Li PMU Ta Li keys Ta brightness Ta 526A brightness level change has been requested. 527Direction is in the $notify variable. 528.It Li PMU Ta Li keys Ta mute Ta 529The mute key 530.It Li PMU Ta Li keys Ta volume Ta 531A volume level change has been requested. 532Direction is in the $notify variable. 533.It Li PMU Ta Li keys Ta eject Ta 534An ejection has been requested. 535.It Li PMU Ta Li lid Ta close Ta 536The 537.Xr pmc 4 538device has detected the lid closing. 539.It Li PMU Ta Li lid Ta open Ta 540The 541.Xr pmc 4 542device has detected the lid openinging. 543.It Li PMU Ta Li POWER Ta ACLINE Ta 544The 545.Xr pmc 4 546device has detected an AC line state ($notify=0x00 is offline, 0x01 is online). 547.It Li PMU Ta Li USB Ta overvoltage Ta 548An over-voltage condition on the power lines for the USB power pins. 549.It Li PMU Ta Li USB Ta plugged Ta 550A device has been plugged into a USB device. 551.It Li PMU Ta Li USB Ta undervoltage Ta 552An under-voltage condition on the power lines for the USB power pins. 553.It Li PMU Ta Li USB Ta unplugged Ta 554A device has been unplugged into a USB device. 555.El 556.Pp 557.Bl -column "System" "Subsystem" "1234567" -compact 558.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 559.It Li RCTL Ta Ta Ta 560Events related to the 561.Xr rctl 8 562framework. 563.It Li RCTL Ta Li rule Ta Li matched Ta 564A rule with action specified as "devctl" was triggered. 565.El 566.Pp 567.Bl -column "System" "Subsystem" "1234567" -compact 568.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 569.It Li USB Ta Ta Ta 570Events related to the USB subsystem. 571.It Li USB Ta Li DEVICE Ta Li ATTACH Ta 572USB device is attached to the system. 573.It Li USB Ta Li DEVICE Ta Li DETACH Ta 574USB device is detached to the system. 575.It Li USB Ta Li INTERFACE Ta Li ATTACH Ta 576USB interface is attached to a device. 577.It Li USB Ta Li INTERFACE Ta Li DETACH Ta 578USB interface is detached from a device. 579.El 580.Pp 581.Bl -column "System" "Subsystem" "1234567" -compact 582.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 583.It Li VFS Ta Ta Ta 584Events from the vfs system. 585.It Li VFS Ta Li FS Ta Ta 586Events that change what is mounted to the system. 587.It Li VFS Ta Li FS Ta Li MOUNT Ta 588Notification of a filesystem is mounted for the first time. 589.It Li VFS Ta Li FS Ta Li REMOUNT Ta 590Notification of a filesystem is remounted (whether or not the options actually change). 591.It Li VFS Ta Li FS Ta Li UNMOUNT Ta 592Notification of a filesystem being unmounted. 593.El 594.Pp 595.Bl -column "System" "Subsystem" "1234567" -compact 596.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 597.It Li VT Ta BELL Ta RING Ta 598Notification that the console bell has rung. 599See 600.Xr vt 4 601for details. 602.El 603.Pp 604.Bl -column "System" "Subsystem" "1234567" -compact 605.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" 606.It Li ZFS Ta ZFS Ta Ta 607Events about the ZFS subsystem. 608See 609.Xr zfsd 8 610and 611.Pa /etc/devd/zfs.conf 612for details. 613.El 614.Pp 615.\" 616.\" End of tables 617.\" 618A link state change to UP on the interface 619.Dq Li fxp0 620would result in the following notify event: 621.Bd -literal -offset indent 622system=IFNET subsystem=fxp0 type=LINK_UP 623.Ed 624.Pp 625An AC line state change to 626.Dq offline 627would result in the following event: 628.Bd -literal -offset indent 629system=ACPI subsystem=ACAD notify=0x00 630.Ed 631.Ss Comments 632Comments may appear anywhere that whitespace may appear in a 633configuration file. 634To appeal to programmers of all kinds, they can 635be written in C, C++, or shell/Perl constructs. 636.Pp 637C-style comments start with the two characters 638.Ql /* 639(slash, star) and end with 640.Ql */ 641(star, slash). 642Because they are completely delimited with these characters, 643they can be used to comment only a portion of a line or to span 644multiple lines. 645.Pp 646C-style comments cannot be nested. 647For example, the following is 648not valid because the entire comment ends with the first 649.Ql */ : 650.Bd -literal -offset indent 651/* This is the start of a comment. 652 This is still part of the comment. 653/* This is an incorrect attempt at nesting a comment. */ 654 This is no longer in any comment. */ 655.Ed 656.Pp 657C++-style comments start with the two characters 658.Ql // 659(slash, slash) and continue to the end of the physical line. 660They cannot be continued across multiple physical lines; to have 661one logical comment span multiple lines, each line must use the 662.Ql // 663pair. 664For example: 665.Bd -literal -offset indent 666// This is the start of a comment. The next line 667// is a new comment, even though it is logically 668// part of the previous comment. 669.Ed 670.Ss Notes on Variable Expansion 671Variables are expanded by preceding them by a 672.Dq $ 673sign. 674Any text immediately following that sign, starting with a letter, a minus sign 675.Dq - , 676an underscore 677.Dq _ , 678or an asterisk 679.Dq * 680is considered an internal variable, and expanded accordingly. 681If that variable does not exist, it silently expands to an empty string. 682Consequently, if the intention is to pass a 683.Xr sh 1 684variable, it must be surrounded by braces to prevent it from being 685considered an internal variable. 686.Pp 687See 688.Sx EXAMPLES 689for a detailed example. 690.Pp 691To prevent issues with special shell characters, the following happens for each 692variable 693.Ic $foo . 694.Bl -enum 695.It 696The characters 697.Dq $' 698are inserted. 699.It 700The string 701.Dq $foo 702is removed. 703.It 704The value of the 705.Ic foo 706variable is inserted into the buffer with all single quote characters 707prefixed by a backslash. 708.It 709A final 710.Dq ' 711is inserted. 712.El 713.Pp 714See 715.Xr sh 1 716for what this construct means. 717It is safe in all context, except one: inside single quotes. 718If foo=meta and bar=var, then a rule like the following: 719.Bd -literal -offset indent -compact 720action "echo '$foo $bar'"; 721.Ed 722will be presented to the shell via 723.Xr system 3 724as 725.Bd -literal -offset indent -compact 726echo '$'meta' $'var'' 727.Ed 728which produces the following output: 729.Bd -literal -offset indent -compact 730$meta $var 731.Ed 732as its output. 733This is an unanticipated result. 734A future version of this software will change this behavior. 735Users are discouraged from using single quotes inside 736.Ic action 737value without due care. 738.Pp 739The above should be written as 740.Bd -literal -offset indent -compact 741action "echo $foo' '$bar" 742.Ed 743to produce a single argument to echo. 744Given the above expansion, juxtaposing bare variables with 745single quote expressions will produce the right output, 746regardless of the value of the variable. 747.Sh FILES 748.Bl -tag -width ".Pa /etc/devd.conf" -compact 749.It Pa /etc/devd.conf 750The 751.Xr devd 8 752configuration file. 753.El 754.Sh EXAMPLES 755.Bd -literal 756# 757# This will catch link down events on the interfaces fxp0 and ath0 758# 759notify 0 { 760 match "system" "IFNET"; 761 match "subsystem" "(fxp0|ath0)"; 762 match "type" "LINK_DOWN"; 763 action "logger $subsystem is DOWN"; 764}; 765 766# 767# Match lid open/close events 768# These can be combined to a single event, by passing the 769# value of $notify to the external script. 770# 771notify 0 { 772 match "system" "ACPI"; 773 match "subsystem" "Lid"; 774 match "notify" "0x00"; 775 action "logger Lid closed, we can sleep now!"; 776}; 777 778notify 0 { 779 match "system" "ACPI"; 780 match "subsystem" "Lid"; 781 match "notify" "0x01"; 782 action "logger Lid opened, the sleeper must awaken!"; 783}; 784 785# 786# Match a USB device type 787# 788notify 0 { 789 match "system" "USB"; 790 match "subsystem" "INTERFACE"; 791 match "type" "ATTACH"; 792 match "intclass" "0x0e"; 793 action "logger USB video device attached"; 794}; 795 796# 797# Try to configure ath and iwn devices with pccard_ether 798# as they are attached. 799# 800attach 0 { 801 device-name "(ath|iwn)[0-9]+"; 802 action "/etc/pccard_ether $device-name start"; 803}; 804 805# 806# Stop ath and iwn devices as they are detached from 807# the system. 808# 809detach 0 { 810 device-name "(ath|iwn)[0-9]+"; 811 action "/etc/pccard_ether $device-name stop"; 812}; 813.Ed 814.Pp 815The following example illustrates the difference betwen internal and shell variables: 816.Bd -literal 817attach 20 { 818 device-name "umodem[0-9]+"; 819 match "vendor" "0x2047"; 820 match "product" "0x001(0|3|4)"; 821 match "interface" "0"; 822 action "cd /dev; p=$product; dn=$device-name; \\ 823 un=$(sysctl -n dev.umodem.${dn#umodem}.ttyname); \\ 824 chmod 666 cua${un}; ln -sf cua${un} mspfet${p#0x}"; 825}; 826.Ed 827.Pp 828.Dq product , 829and 830.Dq device-name 831are internal variables. 832Their contents are initially assigned to shell variables 833.Dq p , 834and 835.Dq dn , 836respectively. 837Then, variable 838.Dq dn 839is used inside a shell command substitution, assigning to shell variable 840.Dq un . 841Finally, this shell variable is used in two other shell statements, where 842it needs to be wrapped in braces in order to prevent it from being 843considered in internal variable to 844.Nm devd . 845.Pp 846The installed 847.Pa /etc/devd.conf 848has many additional examples. 849.Sh SEE ALSO 850.Xr cam 4 , 851.Xr coretemp 4 , 852.Xr devfs 5 , 853.Xr re_format 7 , 854.Xr devd 8 855.Sh BUGS 856The variable expansion's interaction with single quotes is 857suboptimal and surprising. 858