devd.conf revision 322848
1246074Sgabor# $FreeBSD: stable/10/etc/devd.conf 322848 2017-08-24 17:25:16Z will $ 2246074Sgabor# 3246074Sgabor# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4246074Sgabor# run and configure devd. 5246074Sgabor# 6246074Sgabor 7246074Sgabor# NB: All regular expressions have an implicit ^$ around them. 8246074Sgabor# NB: device-name is shorthand for 'match device-name' 9246074Sgabor 10246074Sgaboroptions { 11246074Sgabor # Each "directory" directive adds a directory to the list of 12246074Sgabor # directories that we scan for files. Files are loaded in the order 13246074Sgabor # that they are returned from readdir(3). The rule-sets are combined 14246074Sgabor # to create a DFA that's used to match events to actions. 15246074Sgabor directory "/etc/devd"; 16246074Sgabor directory "/usr/local/etc/devd"; 17246074Sgabor pid-file "/var/run/devd.pid"; 18246074Sgabor 19246074Sgabor # Setup some shorthand for regex that we use later in the file. 20246074Sgabor #XXX Yes, these are gross -- imp 21246074Sgabor set scsi-controller-regex 22246074Sgabor "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 23246074Sgabor esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 24246074Sgabor [0-9]+"; 25246074Sgabor}; 26276807Spfg 27246091Sdelphij# Note that the attach/detach with the highest value wins, so that one can 28246074Sgabor# override these general rules. 29246074Sgabor 30246074Sgabor# 31246074Sgabor# Configure the interface on attach. Due to a historical accident, this 32246074Sgabor# script is called pccard_ether. 33246074Sgabor# 34246074Sgabor# NB: DETACH events are ignored; the kernel should handle all cleanup 35246074Sgabor# (routes, arp cache). Beware of races against immediate create 36246074Sgabor# of a device with the same name; e.g. 37246074Sgabor# ifconfig bridge0 destroy; ifconfig bridge0 create 38246074Sgabor# 39246074Sgabornotify 0 { 40246074Sgabor match "system" "IFNET"; 41246074Sgabor match "subsystem" "!usbus[0-9]+"; 42246074Sgabor match "type" "ATTACH"; 43246074Sgabor action "/etc/pccard_ether $subsystem start"; 44246074Sgabor}; 45246074Sgabor 46246074Sgabor# 47246074Sgabor# Try to start dhclient on Ethernet-like interfaces when the link comes 48246074Sgabor# up. Only devices that are configured to support DHCP will actually 49246074Sgabor# run it. No link down rule exists because dhclient automatically exits 50246074Sgabor# when the link goes down. 51246074Sgabor# 52246074Sgabornotify 0 { 53246074Sgabor match "system" "IFNET"; 54246074Sgabor match "type" "LINK_UP"; 55246074Sgabor media-type "ethernet"; 56246074Sgabor action "/etc/rc.d/dhclient quietstart $subsystem"; 57246074Sgabor}; 58246074Sgabor 59246074Sgabor# 60246074Sgabor# Like Ethernet devices, but separate because 61246074Sgabor# they have a different media type. We may want 62246074Sgabor# to exploit this later. 63246074Sgabor# 64246074Sgabordetach 0 { 65246074Sgabor media-type "802.11"; 66246074Sgabor action "/etc/pccard_ether $device-name stop"; 67246074Sgabor}; 68246074Sgaborattach 0 { 69246074Sgabor media-type "802.11"; 70246074Sgabor action "/etc/pccard_ether $device-name start"; 71246074Sgabor}; 72246074Sgabornotify 0 { 73246074Sgabor match "system" "IFNET"; 74246074Sgabor match "type" "LINK_UP"; 75246074Sgabor media-type "802.11"; 76246074Sgabor action "/etc/rc.d/dhclient quietstart $subsystem"; 77246074Sgabor}; 78246074Sgabor 79246074Sgabor# An entry like this might be in a different file, but is included here 80246074Sgabor# as an example of how to override things. Normally 'ed50' would match 81246074Sgabor# the above attach/detach stuff, but the value of 100 makes it 82246074Sgabor# hard wired to 1.2.3.4. 83246074Sgaborattach 100 { 84246074Sgabor device-name "ed50"; 85246074Sgabor action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 86246074Sgabor}; 87246074Sgabordetach 100 { 88246074Sgabor device-name "ed50"; 89246074Sgabor}; 90246074Sgabor 91246074Sgabor# When a USB Bluetooth dongle appears, activate it 92246074Sgaborattach 100 { 93246074Sgabor device-name "ubt[0-9]+"; 94246074Sgabor action "/etc/rc.d/bluetooth quietstart $device-name"; 95246074Sgabor}; 96246074Sgabordetach 100 { 97246074Sgabor device-name "ubt[0-9]+"; 98246074Sgabor action "/etc/rc.d/bluetooth quietstop $device-name"; 99246074Sgabor}; 100246074Sgabor 101246074Sgabor# Firmware downloader for Atheros AR3011 based USB Bluetooth devices 102246074Sgabor#attach 100 { 103246074Sgabor# match "vendor" "0x0cf3"; 104246074Sgabor# match "product" "0x3000"; 105246074Sgabor# action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw"; 106246074Sgabor#}; 107246074Sgabor 108246074Sgabor# When a USB keyboard arrives, attach it as the console keyboard. 109246074Sgaborattach 100 { 110246074Sgabor device-name "ukbd0"; 111246074Sgabor action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; 112246074Sgabor}; 113246074Sgabordetach 100 { 114246074Sgabor device-name "ukbd0"; 115246074Sgabor action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; 116246074Sgabor}; 117246074Sgabor 118246074Sgabornotify 100 { 119246074Sgabor match "system" "DEVFS"; 120246074Sgabor match "subsystem" "CDEV"; 121246074Sgabor match "type" "CREATE"; 122246074Sgabor match "cdev" "atp[0-9]+"; 123246074Sgabor 124246074Sgabor action "/etc/rc.d/moused quietstart $cdev"; 125246074Sgabor}; 126246074Sgabor 127246074Sgabornotify 100 { 128246074Sgabor match "system" "DEVFS"; 129246074Sgabor match "subsystem" "CDEV"; 130246074Sgabor match "type" "CREATE"; 131246074Sgabor match "cdev" "ums[0-9]+"; 132246074Sgabor 133246074Sgabor action "/etc/rc.d/moused quietstart $cdev"; 134246074Sgabor}; 135246074Sgabor 136246074Sgabornotify 100 { 137246074Sgabor match "system" "DEVFS"; 138246074Sgabor match "subsystem" "CDEV"; 139246074Sgabor match "type" "CREATE"; 140246074Sgabor match "cdev" "wsp[0-9]+"; 141246074Sgabor 142246074Sgabor action "/etc/rc.d/moused quietstart $cdev"; 143246074Sgabor}; 144246074Sgabor 145246074Sgabornotify 100 { 146246074Sgabor match "system" "DEVFS"; 147246074Sgabor match "subsystem" "CDEV"; 148255894Sdelphij match "type" "DESTROY"; 149246074Sgabor match "cdev" "ums[0-9]+"; 150246074Sgabor 151246074Sgabor action "/etc/rc.d/moused stop $cdev"; 152246074Sgabor}; 153275840Spfg 154275840Spfg# Firmware download into the ActiveWire board. After the firmware download is 155246074Sgabor# done, the device detaches and reappears as something new and shiny 156246074Sgabor# automatically. 157246074Sgaborattach 100 { 158246074Sgabor match "vendor" "0x0854"; 159246074Sgabor match "product" "0x0100"; 160246074Sgabor match "release" "0x0000"; 161246074Sgabor action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; 162246074Sgabor}; 163246074Sgabor 164246074Sgabor# Firmware download for Entrega Serial DB25 adapter. 165246074Sgaborattach 100 { 166246074Sgabor match "vendor" "0x1645"; 167246074Sgabor match "product" "0x8001"; 168246074Sgabor match "release" "0x0101"; 169246074Sgabor action "if ! kldstat -n usio > /dev/null 2>&1 ; then kldload usio; fi; /usr/sbin/ezdownload -v -f /usr/share/usb/firmware/1645.8001.0101 /dev/$device-name"; 170246074Sgabor}; 171246074Sgabor 172246074Sgabor# This entry starts the ColdSync tool in daemon mode. Make sure you have an up 173246074Sgabor# to date /usr/local/etc/palms. We override the 'listen' settings for port and 174246074Sgabor# type in /usr/local/etc/coldsync.conf. 175246074Sgabornotify 100 { 176246074Sgabor match "system" "USB"; 177246074Sgabor match "subsystem" "DEVICE"; 178246074Sgabor match "type" "ATTACH"; 179246074Sgabor match "vendor" "0x082d"; 180246074Sgabor match "product" "0x0100"; 181246074Sgabor match "release" "0x0100"; 182246074Sgabor action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb"; 183246074Sgabor}; 184246074Sgabor 185246074Sgabor# 186246074Sgabor# Rescan SCSI device-names on attach, but not detach. However, it is 187246074Sgabor# disabled by default due to reports of problems. 188246074Sgabor# 189246074Sgaborattach 0 { 190246074Sgabor device-name "$scsi-controller-regex"; 191246074Sgabor// action "camcontrol rescan all"; 192246074Sgabor}; 193246074Sgabor 194246074Sgabor# Don't even try to second guess what to do about drivers that don't 195246074Sgabor# match here. Instead, pass it off to syslog. Commented out for the 196246074Sgabor# moment, as the pnpinfo variable isn't set in devd yet. Individual 197246074Sgabor# variables within the bus supplied pnpinfo are set. 198246074Sgabornomatch 0 { 199246074Sgabor# action "logger Unknown device: $pnpinfo $location $bus"; 200246074Sgabor}; 201246074Sgabor 202246074Sgabor# Various logging of unknown devices. 203246074Sgabornomatch 10 { 204246074Sgabor match "bus" "uhub[0-9]+"; 205246074Sgabor action "logger Unknown USB device: vendor $vendor product $product \ 206246074Sgabor bus $bus"; 207246074Sgabor}; 208246074Sgabor 209246074Sgabor# Some PC-CARDs don't offer numerical manufacturer/product IDs, just 210246074Sgabor# show the CIS info there. 211246074Sgabornomatch 20 { 212246074Sgabor match "bus" "pccard[0-9]+"; 213246074Sgabor match "manufacturer" "0xffffffff"; 214246091Sdelphij match "product" "0xffffffff"; 215246074Sgabor action "logger Unknown PCCARD device: CISproduct $cisproduct \ 216246074Sgabor CIS-vendor $cisvendor bus $bus"; 217246074Sgabor}; 218276807Spfg 219246091Sdelphijnomatch 10 { 220246074Sgabor match "bus" "pccard[0-9]+"; 221246074Sgabor action "logger Unknown PCCARD device: manufacturer $manufacturer \ 222246074Sgabor product $product CISproduct $cisproduct CIS-vendor \ 223246074Sgabor $cisvendor bus $bus"; 224276807Spfg}; 225246074Sgabor 226246074Sgabornomatch 10 { 227246074Sgabor match "bus" "cardbus[0-9]+"; 228246074Sgabor action "logger Unknown Cardbus device: device $device class $class \ 229246074Sgabor vendor $vendor bus $bus"; 230246074Sgabor}; 231246074Sgabor 232246074Sgabor# Switch power profiles when the AC line state changes. 233246074Sgabornotify 10 { 234246074Sgabor match "system" "ACPI"; 235246074Sgabor match "subsystem" "ACAD"; 236246074Sgabor action "/etc/rc.d/power_profile $notify"; 237246074Sgabor}; 238246074Sgabor 239246074Sgabor# Notify all users before beginning emergency shutdown when we get 240246074Sgabor# a _CRT or _HOT thermal event and we're going to power down the system 241246074Sgabor# very soon. 242253614Spfgnotify 10 { 243253614Spfg match "system" "ACPI"; 244253614Spfg match "subsystem" "Thermal"; 245253614Spfg match "notify" "0xcc"; 246246074Sgabor action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 247246074Sgabor}; 248246074Sgabor 249246074Sgabor# User requested suspend, so perform preparation steps and then execute 250255894Sdelphij# the actual suspend process. 251246074Sgabornotify 10 { 252246074Sgabor match "system" "ACPI"; 253246074Sgabor match "subsystem" "Suspend"; 254246074Sgabor action "/etc/rc.suspend acpi $notify"; 255246074Sgabor}; 256246074Sgabornotify 10 { 257246074Sgabor match "system" "ACPI"; 258246074Sgabor match "subsystem" "Resume"; 259246074Sgabor action "/etc/rc.resume acpi $notify"; 260246074Sgabor}; 261255894Sdelphij 262246074Sgabor/* EXAMPLES TO END OF FILE 263246074Sgabor 264246074Sgabor# An example of something that a vendor might install if you were to 265246074Sgabor# add their device. This might reside in /usr/local/etc/devd/deqna.conf. 266246074Sgabor# A deqna is, in this hypothetical example, a pccard ethernet-like device. 267246074Sgabor# Students of history may know other devices by this name, and will get 268246074Sgabor# the in-jokes in this entry. 269246074Sgabornomatch 10 { 270246074Sgabor match "bus" "pccard[0-9]+"; 271246074Sgabor match "manufacturer" "0x1234"; 272246074Sgabor match "product" "0x2323"; 273246074Sgabor action "kldload if_deqna"; 274246074Sgabor}; 275246074Sgaborattach 10 { 276246074Sgabor device-name "deqna[0-9]+"; 277246074Sgabor action "/etc/pccard_ether $device-name start"; 278246074Sgabor}; 279246074Sgabordetach 10 { 280246074Sgabor device-name "deqna[0-9]+"; 281246074Sgabor action "/etc/pccard_ether $device-name stop"; 282246074Sgabor}; 283246074Sgabor 284246074Sgabor# Examples of notify hooks. A notify is a generic way for a kernel 285246074Sgabor# subsystem to send event notification to userland. 286246074Sgabor 287246074Sgabor# Here are some examples of ACPI notify handlers. ACPI subsystems that 288246074Sgabor# generate notifies include the AC adapter, power/sleep buttons, 289246074Sgabor# control method batteries, lid switch, and thermal zones. 290246074Sgabor# 291246074Sgabor# Information returned is not always the same as the ACPI notify 292246074Sgabor# events. See the ACPI specification for more information about 293246074Sgabor# notifies. Here is the information returned for each subsystem: 294246074Sgabor# 295246074Sgabor# ACAD: AC line state (0 is offline, 1 is online) 296246074Sgabor# Button: Button pressed (0 for power, 1 for sleep) 297255894Sdelphij# CMBAT: ACPI battery events 298255894Sdelphij# Lid: Lid state (0 is closed, 1 is open) 299246074Sgabor# Suspend, Resume: Suspend and resume notification 300246074Sgabor# Thermal: ACPI thermal zone events 301246074Sgabor# 302246074Sgabor# This example calls a script when the AC state changes, passing the 303246074Sgabor# notify value as the first argument. If the state is 0x00, it might 304246074Sgabor# call some sysctls to implement economy mode. If 0x01, it might set 305246074Sgabor# the mode to performance. 306246074Sgabornotify 10 { 307246074Sgabor match "system" "ACPI"; 308246074Sgabor match "subsystem" "ACAD"; 309246074Sgabor action "/etc/acpi_ac $notify"; 310246074Sgabor}; 311250975Sgjb 312246074Sgabor# This example works around a memory leak in PostgreSQL, restarting 313246074Sgabor# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered. 314246074Sgabornotify 0 { 315246074Sgabor match "system" "RCTL"; 316246074Sgabor match "rule" "user:770:swap:.*"; 317246074Sgabor action "/usr/local/etc/rc.d/postgresql restart"; 318246074Sgabor}; 319246074Sgabor 320246074Sgabor# Discard autofs caches, useful for the -media special map. 321246074Sgabornotify 100 { 322246074Sgabor match "system" "GEOM"; 323246074Sgabor match "subsystem" "DEV"; 324246074Sgabor action "/usr/sbin/automount -c"; 325246074Sgabor}; 326246074Sgabor 327246074Sgabor# Handle userland coredumps. 328246074Sgabor# This commented out handler makes it possible to run an 329246074Sgabor# automated debugging session after the core dump is generated. 330246074Sgabor# Replace action with a proper coredump handler, but be aware that 331246074Sgabor# it will run with elevated privileges. 332246074Sgabornotify 10 { 333246074Sgabor match "system" "kernel"; 334246074Sgabor match "subsystem" "signal"; 335246074Sgabor match "type" "coredump"; 336246074Sgabor action "logger $comm $core"; 337246074Sgabor}; 338246074Sgabor 339246074Sgabor*/ 340246074Sgabor