devd.conf revision 225861
150276Speter# $FreeBSD: head/etc/devd.conf 225861 2011-09-29 03:37:42Z wblock $ 250276Speter# 397049Speter# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4178866Srafan# run and configure devd. 5178866Srafan# 662449Speter 7184989Srafan# NB: All regular expressions have an implicit ^$ around them. 862449Speter# NB: device-name is shorthand for 'match device-name' 950276Speter 1050276Speteroptions { 1150276Speter # Each "directory" directive adds a directory to the list of 1250276Speter # directories that we scan for files. Files are loaded in the order 1350276Speter # that they are returned from readdir(3). The rule-sets are combined 1450276Speter # to create a DFA that's used to match events to actions. 1550276Speter directory "/etc/devd"; 1650276Speter directory "/usr/local/etc/devd"; 1750276Speter pid-file "/var/run/devd.pid"; 1850276Speter 1950276Speter # Setup some shorthand for regex that we use later in the file. 2050276Speter #XXX Yes, these are gross -- imp 21166124Srafan set scsi-controller-regex 22166124Srafan "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 2350276Speter esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 2450276Speter [0-9]+"; 2550276Speter}; 2650276Speter 2750276Speter# Note that the attach/detach with the highest value wins, so that one can 2850276Speter# override these general rules. 29166124Srafan 3097049Speter# 3197049Speter# Configure the interface on attach. Due to a historical accident, this 3297049Speter# script is called pccard_ether. 3350276Speter# 3450276Speter# NB: DETACH events are ignored; the kernel should handle all cleanup 3550276Speter# (routes, arp cache). Beware of races against immediate create 3650276Speter# of a device with the same name; e.g. 3750276Speter# ifconfig bridge0 destroy; ifconfig bridge0 create 3850276Speter# 3976726Speternotify 0 { 4050276Speter match "system" "IFNET"; 4162449Speter match "type" "ATTACH"; 4262449Speter action "/etc/pccard_ether $subsystem start"; 4362449Speter}; 4462449Speter 4562449Speter# 4676726Speter# Try to start dhclient on Ethernet-like interfaces when the link comes 4762449Speter# up. Only devices that are configured to support DHCP will actually 4862449Speter# run it. No link down rule exists because dhclient automatically exits 4976726Speter# when the link goes down. 5076726Speter# 5176726Speternotify 0 { 5262449Speter match "system" "IFNET"; 5376726Speter match "type" "LINK_UP"; 5476726Speter media-type "ethernet"; 5576726Speter action "/etc/rc.d/dhclient quietstart $subsystem"; 5676726Speter}; 5776726Speter 5876726Speter# 59178866Srafan# Like Ethernet devices, but separate because 60178866Srafan# they have a different media type. We may want 6176726Speter# to exploit this later. 6276726Speter# 6376726Speterdetach 0 { 6476726Speter media-type "802.11"; 6562449Speter action "/etc/pccard_ether $device-name stop"; 6662449Speter}; 6762449Speterattach 0 { 6862449Speter media-type "802.11"; 6962449Speter action "/etc/pccard_ether $device-name start"; 7076726Speter}; 7176726Speternotify 0 { 72166124Srafan match "system" "IFNET"; 7376726Speter match "type" "LINK_UP"; 74166124Srafan media-type "802.11"; 7562449Speter action "/etc/rc.d/dhclient quietstart $subsystem"; 76166124Srafan}; 7762449Speter 7862449Speter# An entry like this might be in a different file, but is included here 7962449Speter# as an example of how to override things. Normally 'ed50' would match 8062449Speter# the above attach/detach stuff, but the value of 100 makes it 8162449Speter# hard wired to 1.2.3.4. 8276726Speterattach 100 { 8362449Speter device-name "ed50"; 8462449Speter action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 8562449Speter}; 8662449Speterdetach 100 { 8762449Speter device-name "ed50"; 8862449Speter}; 8962449Speter 9062449Speter# When a USB Bluetooth dongle appears, activate it 9162449Speterattach 100 { 9262449Speter device-name "ubt[0-9]+"; 9362449Speter action "/etc/rc.d/bluetooth quietstart $device-name"; 94166124Srafan}; 9562449Speterdetach 100 { 96166124Srafan device-name "ubt[0-9]+"; 97166124Srafan action "/etc/rc.d/bluetooth quietstop $device-name"; 98166124Srafan}; 99166124Srafan 10062449Speter# Firmware downloader for Atheros AR3011 based USB Bluetooth devices 10176726Speter#attach 100 { 10276726Speter# match "vendor" "0x0cf3"; 10376726Speter# match "product" "0x3000"; 104166124Srafan# action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw"; 105166124Srafan#}; 106166124Srafan 107166124Srafan# When a USB keyboard arrives, attach it as the console keyboard. 108166124Srafanattach 100 { 109166124Srafan device-name "ukbd0"; 110166124Srafan action "/etc/rc.d/syscons setkeyboard /dev/ukbd0"; 111166124Srafan}; 112166124Srafandetach 100 { 113166124Srafan device-name "ukbd0"; 114166124Srafan action "/etc/rc.d/syscons setkeyboard /dev/kbd0"; 115166124Srafan}; 116166124Srafan 117166124Srafanattach 100 { 11897049Speter device-name "ums[0-9]+"; 119166124Srafan action "/etc/rc.d/moused quietstart $device-name"; 12097049Speter}; 12197049Speter 12297049Speterdetach 100 { 12376726Speter device-name "ums[0-9]+"; 12497049Speter action "/etc/rc.d/moused stop $device-name"; 12576726Speter}; 12676726Speter 12776726Speter# Firmware download into the ActiveWire board. After the firmware download is 12876726Speter# done, the device detaches and reappears as something new and shiny 129166124Srafan# automatically. 13076726Speterattach 100 { 13150276Speter match "vendor" "0x0854"; 13297049Speter match "product" "0x0100"; 13350276Speter match "release" "0x0000"; 13450276Speter action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name"; 13550276Speter}; 13650276Speter 13750276Speter# Firmware download for Entrega Serial DB25 adapter. 13850276Speterattach 100 { 13976726Speter match "vendor" "0x1645"; 14050276Speter match "product" "0x8001"; 14150276Speter match "release" "0x0101"; 14250276Speter 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"; 14350276Speter}; 14450276Speter 14562449Speter# This entry starts the ColdSync tool in daemon mode. Make sure you have an up 14697049Speter# to date /usr/local/etc/palms. We override the 'listen' settings for port and 14762449Speter# type in /usr/local/etc/coldsync.conf. 14862449Speternotify 100 { 14962449Speter match "system" "USB"; 15062449Speter match "subsystem" "DEVICE"; 15162449Speter match "type" "ATTACH"; 15262449Speter match "vendor" "0x082d"; 15397049Speter match "product" "0x0100"; 15497049Speter match "release" "0x0100"; 15597049Speter action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb"; 15697049Speter}; 15797049Speter 15897049Speter# 15997049Speter# Rescan scsi device-names on attach, but not detach. However, it is 160166124Srafan# disabled by default due to reports of problems. 16197049Speter# 16297049Speterattach 0 { 16397049Speter device-name "$scsi-controller-regex"; 164174993Srafan// action "camcontrol rescan all"; 16597049Speter}; 16662449Speter 16776726Speter# Don't even try to second guess what to do about drivers that don't 16876726Speter# match here. Instead, pass it off to syslog. Commented out for the 16997049Speter# moment, as the pnpinfo variable isn't set in devd yet. Individual 17097049Speter# variables within the bus supplied pnpinfo are set. 17197049Speternomatch 0 { 17276726Speter# action "logger Unknown device: $pnpinfo $location $bus"; 17376726Speter}; 17476726Speter 17576726Speter# Various logging of unknown devices. 17676726Speternomatch 10 { 17776726Speter match "bus" "uhub[0-9]+"; 17876726Speter action "logger Unknown USB device: vendor $vendor product $product \ 17976726Speter bus $bus"; 18076726Speter}; 18176726Speter 18276726Speter# Some PC-CARDs don't offer numerical manufacturer/product IDs, just 183184989Srafan# show the CIS info there. 18476726Speternomatch 20 { 18576726Speter match "bus" "pccard[0-9]+"; 18662449Speter match "manufacturer" "0xffffffff"; 187166124Srafan match "product" "0xffffffff"; 188166124Srafan action "logger Unknown PCCARD device: CISproduct $cisproduct \ 189166124Srafan CIS-vendor $cisvendor bus $bus"; 190166124Srafan}; 191166124Srafan 192166124Srafannomatch 10 { 193166124Srafan match "bus" "pccard[0-9]+"; 194166124Srafan action "logger Unknown PCCARD device: manufacturer $manufacturer \ 195166124Srafan product $product CISproduct $cisproduct CIS-vendor \ 196166124Srafan $cisvendor bus $bus"; 197166124Srafan}; 198166124Srafan 19962449Speternomatch 10 { 20062449Speter match "bus" "cardbus[0-9]+"; 20162449Speter action "logger Unknown Cardbus device: device $device class $class \ 20262449Speter vendor $vendor bus $bus"; 203166124Srafan}; 20497049Speter 205166124Srafan# Switch power profiles when the AC line state changes. 206166124Srafannotify 10 { 207166124Srafan match "system" "ACPI"; 208166124Srafan match "subsystem" "ACAD"; 209166124Srafan action "/etc/rc.d/power_profile $notify"; 210166124Srafan}; 211166124Srafan 212166124Srafan# Notify all users before beginning emergency shutdown when we get 213166124Srafan# a _CRT or _HOT thermal event and we're going to power down the system 214166124Srafan# very soon. 215166124Srafannotify 10 { 216166124Srafan match "system" "ACPI"; 217166124Srafan match "subsystem" "Thermal"; 218166124Srafan match "notify" "0xcc"; 219166124Srafan action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 22050276Speter}; 221166124Srafan 222184989Srafan# Sample ZFS problem reports handling. 22350276Speternotify 10 { 224166124Srafan match "system" "ZFS"; 225184989Srafan match "type" "zpool"; 226184989Srafan action "logger -p kern.err 'ZFS: failed to load zpool $pool'"; 227166124Srafan}; 228166124Srafan 229166124Srafannotify 10 { 230166124Srafan match "system" "ZFS"; 231166124Srafan match "type" "vdev"; 232166124Srafan action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'"; 233166124Srafan}; 234166124Srafan 235166124Srafannotify 10 { 236166124Srafan match "system" "ZFS"; 237166124Srafan match "type" "data"; 238166124Srafan action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'"; 239166124Srafan}; 240166124Srafan 241166124Srafannotify 10 { 242166124Srafan match "system" "ZFS"; 243166124Srafan match "type" "io"; 244166124Srafan action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; 245166124Srafan}; 246166124Srafan 247166124Srafannotify 10 { 248166124Srafan match "system" "ZFS"; 249166124Srafan match "type" "checksum"; 250166124Srafan action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; 251166124Srafan}; 252166124Srafan 253166124Srafan# User requested suspend, so perform preparation steps and then execute 254166124Srafan# the actual suspend process. 255166124Srafannotify 10 { 256166124Srafan match "system" "ACPI"; 257166124Srafan match "subsystem" "Suspend"; 258166124Srafan action "/etc/rc.suspend acpi $notify"; 259166124Srafan}; 260166124Srafannotify 10 { 261166124Srafan match "system" "ACPI"; 262166124Srafan match "subsystem" "Resume"; 263166124Srafan action "/etc/rc.resume acpi $notify"; 264166124Srafan}; 265166124Srafan 266166124Srafan/* EXAMPLES TO END OF FILE 26750276Speter 26850276Speter# An example of something that a vendor might install if you were to 26950276Speter# add their device. This might reside in /usr/local/etc/devd/deqna.conf. 27050276Speter# A deqna is, in this hypothetical example, a pccard ethernet-like device. 271166124Srafan# Students of history may know other devices by this name, and will get 272166124Srafan# the in-jokes in this entry. 27362449Speternomatch 10 { 27462449Speter match "bus" "pccard[0-9]+"; 27562449Speter match "manufacturer" "0x1234"; 27662449Speter match "product" "0x2323"; 27762449Speter action "kldload if_deqna"; 278166124Srafan}; 27950276Speterattach 10 { 28050276Speter device-name "deqna[0-9]+"; 281166124Srafan action "/etc/pccard_ether $device-name start"; 28250276Speter}; 28376726Speterdetach 10 { 284166124Srafan device-name "deqna[0-9]+"; 28550276Speter action "/etc/pccard_ether $device-name stop"; 28650276Speter}; 287166124Srafan 28897049Speter# Examples of notify hooks. A notify is a generic way for a kernel 28997049Speter# subsystem to send event notification to userland. 290166124Srafan 29162449Speter# Here are some examples of ACPI notify handlers. ACPI subsystems that 29262449Speter# generate notifies include the AC adapter, power/sleep buttons, 293166124Srafan# control method batteries, lid switch, and thermal zones. 294166124Srafan# 295166124Srafan# Information returned is not always the same as the ACPI notify 296166124Srafan# events. See the ACPI specification for more information about 297166124Srafan# notifies. Here is the information returned for each subsystem: 298184989Srafan# 299166124Srafan# ACAD: AC line state (0 is offline, 1 is online) 30050276Speter# Button: Button pressed (0 for power, 1 for sleep) 30150276Speter# CMBAT: ACPI battery events 302166124Srafan# Lid: Lid state (0 is closed, 1 is open) 303166124Srafan# RCTL: Resource limits 304166124Srafan# Suspend, Resume: Suspend and resume notification 305166124Srafan# Thermal: ACPI thermal zone events 30676726Speter# 30750276Speter# This example calls a script when the AC state changes, passing the 308166124Srafan# notify value as the first argument. If the state is 0x00, it might 30962449Speter# call some sysctls to implement economy mode. If 0x01, it might set 31050276Speter# the mode to performance. 31150276Speternotify 10 { 31250276Speter match "system" "ACPI"; 31350276Speter match "subsystem" "ACAD"; 31450276Speter action "/etc/acpi_ac $notify"; 31550276Speter}; 316166124Srafan 31762449Speter# This example works around a memory leak in PostgreSQL, restarting 31850276Speter# it when the "user:pgsql:swap:devctl=1G" rctl(8) rule gets triggered. 319166124Srafannotify 0 { 320166124Srafan match "system" "RCTL"; 321166124Srafan match "rule" "user:70:swap:.*"; 322166124Srafan action "/usr/local/etc/rc.d/postgresql restart" 323166124Srafan}; 324166124Srafan 325166124Srafan*/ 326166124Srafan