devd.conf revision 148642
166694Sscottl# $FreeBSD: head/etc/devd.conf 148642 2005-08-02 18:28:31Z sam $ 266694Sscottl# 366694Sscottl# Refer to devd.conf(5) and devd(8) man pages for the details on how to 466694Sscottl# run and configure devd. 566694Sscottl# 666694Sscottl 766694Sscottl# NB: All regular expressions have an implicit ^$ around them. 866694Sscottl# NB: device-name is shorthand for 'match device-name' 966694Sscottl 1066694Sscottloptions { 1166694Sscottl # Each directory directive adds a directory the list of directories 1266694Sscottl # that we scan for files. Files are read-in in the order that they 1366694Sscottl # are returned from readdir(3). The rule-sets are combined to 1466694Sscottl # create a DFA that's used to match events to actions. 1566694Sscottl directory "/etc/devd"; 1666694Sscottl directory "/usr/local/etc/devd"; 1766694Sscottl pid-file "/var/run/devd.pid"; 1866694Sscottl 1966694Sscottl # Setup some shorthand for regex that we use later in the file. 2066694Sscottl #XXX Yes, these are gross -- imp 2166694Sscottl set scsi-controller-regex 2266694Sscottl "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 2366694Sscottl esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 2466694Sscottl [0-9]+"; 2566694Sscottl}; 26195614Sjkim 2766694Sscottl# Note that the attach/detach with the highest value wins, so that one can 2866694Sscottl# override these general rules. 2966694Sscottl 3066694Sscottl# 3166694Sscottl# For ethernet like devices start configuring the interface. Due to 3266694Sscottl# a historical accident, this script is called pccard_ether. 33159703Sbrueffer# 34159703Sbruefferattach 0 { 35159703Sbrueffer media-type "ethernet"; 36159703Sbrueffer action "/etc/pccard_ether $device-name start"; 3766694Sscottl}; 3866694Sscottl 39111166Sscottldetach 0 { 40159703Sbrueffer media-type "ethernet"; 41159703Sbrueffer action "/etc/pccard_ether $device-name stop"; 42159703Sbrueffer}; 43159703Sbrueffer 44159703Sbrueffer# 45159703Sbrueffer# Try to start dhclient on Ethernet like interfaces when the link comes 46159703Sbrueffer# up. Only devices that are configured to support DHCP will actually 47159703Sbrueffer# run it. No link down rule exists because dhclient automaticly exits 48159703Sbrueffer# when the link goes down. 49159703Sbrueffer# 50159703Sbrueffernotify 0 { 5166694Sscottl match "system" "IFNET"; 5279727Sschweikh match "type" "LINK_UP"; 5366694Sscottl media-type "ethernet"; 54111166Sscottl action "/etc/rc.d/dhclient start $subsystem"; 55159703Sbrueffer}; 5666694Sscottl 5766694Sscottl# 5866694Sscottl# Like Ethernet devices, but separate because 5966694Sscottl# they have a different media type. We may want 60133608Sscottl# to exploit this later. 61133608Sscottl# 62133608Sscottldetach 0 { 63143346Sbrueffer media-type "802.11"; 64133608Sscottl action "/etc/pccard_ether $device-name stop"; 65133608Sscottl}; 66133608Sscottlattach 0 { 6766694Sscottl media-type "802.11"; 6866694Sscottl action "/etc/pccard_ether $device-name start"; 6966694Sscottl}; 7080359Sscottlnotify 0 { 7181238Sru match "system" "IFNET"; 7281238Sru match "type" "LINK_UP"; 7380359Sscottl media-type "802.11"; 7480359Sscottl action "/etc/rc.d/dhclient start $subsystem"; 7580359Sscottl}; 76165204Smpp 77133608Sscottl# An entry like this might be in a different file, but is included here 78111166Sscottl# as an example of how to override things. Normally 'ed50' would match 79111166Sscottl# the above attach/detach stuff, but the value of 100 makes it 80111447Sru# hard wired to 1.2.3.4. 81111447Sruattach 100 { 82111447Sru device-name "ed50"; 83111447Sru action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 84111447Sru}; 85111166Sscottldetach 100 { 8666694Sscottl device-name "ed50"; 87111166Sscottl}; 88111166Sscottl 89131570Ssimon# When a USB keyboard arrives, attach it as the console keyboard. 90131570Ssimonattach 100 { 91131570Ssimon device-name "ukbd0"; 92131570Ssimon action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart"; 93131570Ssimon}; 94131570Ssimondetach 100 { 95131570Ssimon device-name "ukbd0"; 96131570Ssimon action "kbdcontrol -k /dev/kbd0 < /dev/console"; 97131570Ssimon}; 98180072Semaste 99180072Semaste# The entry below starts moused when a mouse is plugged in. Moused 100180072Semaste# stops automatically (actually it bombs :) when the device disappears. 101180072Semasteattach 100 { 102180072Semaste device-name "ums[0-9]+"; 103180072Semaste action "/etc/rc.d/moused start $device-name"; 104180072Semaste}; 105180072Semaste 106174080Semaste# 107174080Semaste# Rescan scsi device-names on attach, but not detach. However, it is 108174080Semaste# disabled by default due to reports of problems. 109174080Semaste# 110174080Semasteattach 0 { 111174080Semaste device-name "$scsi-controller-regex"; 112174080Semaste// action "camcontrol rescan all"; 113174080Semaste}; 114174080Semaste 115174080Semaste# Don't even try to second guess what to do about drivers that don't 116174369Semaste# match here. Instead, pass it off to syslog. Commented out for the 117174369Semaste# moment, as pnpinfo isn't set in devd yet. 118174080Semastenomatch 0 { 119174080Semaste# action "logger Unknown device: $pnpinfo $location $bus"; 120174369Semaste}; 121174369Semaste 122174369Semaste# Switch power profiles when the AC line state changes. 123174369Semastenotify 10 { 124174369Semaste match "system" "ACPI"; 125174369Semaste match "subsystem" "ACAD"; 126174080Semaste action "/etc/rc.d/power_profile $notify"; 127174080Semaste}; 128174080Semaste 129174080Semaste# Notify all users before beginning emergency shutdown when we get 130171940Semaste# a _CRT or _HOT thermal event and we're going to power down the system 131171940Semaste# very soon. 132171940Semastenotify 10 { 133171940Semaste match "system" "ACPI"; 134159703Sbrueffer match "subsystem" "Thermal"; 135159703Sbrueffer match "notify" "0xcc"; 136159703Sbrueffer action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 137159703Sbrueffer}; 138159703Sbrueffer 139159703Sbrueffer/* EXAMPLES TO END OF FILE 140159703Sbrueffer 141159703Sbrueffer# The following might be an example of something that a vendor might 142159703Sbrueffer# install if you were to add their device. This might reside in 143159703Sbrueffer# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 144159703Sbrueffer# example, a pccard ethernet-like device. Students of history may 145159703Sbrueffer# know other devices by this name, and will get the in-jokes in this 146159703Sbrueffer# entry. 147159703Sbrueffernomatch 10 { 148139675Sbrueffer match "bus" "pccard[0-9]+"; 149139675Sbrueffer match "manufacturer" "0x1234"; 150159703Sbrueffer match "product" "0x2323"; 151159703Sbrueffer action "kldload if_deqna"; 152159703Sbrueffer}; 153159703Sbruefferattach 10 { 154159703Sbrueffer device-name "deqna[0-9]+"; 155159703Sbrueffer action "/etc/pccard_ether $device-name start"; 156139675Sbrueffer}; 157139675Sbruefferdetach 10 { 158159703Sbrueffer device-name "deqna[0-9]+"; 159159703Sbrueffer action "/etc/pccard_ether $device-name stop"; 160139675Sbrueffer}; 161139675Sbrueffer 162159703Sbrueffer# Examples of notify hooks. A notify is a generic way for a kernel 163159703Sbrueffer# subsystem to send event notification to userland. 164159703Sbrueffer# 165159703Sbrueffer# Here are some examples of ACPI notify handlers. ACPI subsystems that 166131570Ssimon# generate notifies include the AC adapter, power/sleep buttons, 167131570Ssimon# control method batteries, lid switch, and thermal zones. 168133608Sscottl# 169133608Sscottl# Information returned is not always the same as the ACPI notify 170139230Sscottl# events. See the ACPI specification for more information about 171139230Sscottl# notifies. Here is the information returned for each subsystem: 172138886Sbrueffer# 173138886Sbrueffer# ACAD: AC line state (0 is offline, 1 is online) 174159703Sbrueffer# Button: Button pressed (0 for power, 1 for sleep) 175159703Sbrueffer# CMBAT: ACPI battery events 176159703Sbrueffer# Lid: Lid state (0 is closed, 1 is open) 177159703Sbrueffer# Thermal: ACPI thermal zone events 178159703Sbrueffer# 179159703Sbrueffer# This example calls a script when the AC state changes, passing the 180159703Sbrueffer# notify value as the first argument. If the state is 0x00, it might 181159703Sbrueffer# call some sysctls to implement economy mode. If 0x01, it might set 182131570Ssimon# the mode to performance. 183131570Ssimonnotify 10 { 184131570Ssimon match "system" "ACPI"; 185131570Ssimon match "subsystem" "ACAD"; 186131570Ssimon action "/etc/acpi_ac $notify"; 187131570Ssimon}; 188131570Ssimon*/ 189131570Ssimon