devd.conf revision 148642
1108983Simp# $FreeBSD: head/etc/devd.conf 148642 2005-08-02 18:28:31Z sam $ 2108983Simp# 3108983Simp# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4108983Simp# run and configure devd. 5108983Simp# 6108983Simp 7108983Simp# NB: All regular expressions have an implicit ^$ around them. 8108983Simp# NB: device-name is shorthand for 'match device-name' 9108983Simp 10108983Simpoptions { 11108983Simp # Each directory directive adds a directory the list of directories 12108983Simp # that we scan for files. Files are read-in in the order that they 13108983Simp # are returned from readdir(3). The rule-sets are combined to 14108983Simp # create a DFA that's used to match events to actions. 15108983Simp directory "/etc/devd"; 16108983Simp directory "/usr/local/etc/devd"; 17108983Simp pid-file "/var/run/devd.pid"; 18108983Simp 19108983Simp # Setup some shorthand for regex that we use later in the file. 20148471Simp #XXX Yes, these are gross -- imp 21108983Simp set scsi-controller-regex 22139027Sbrueffer "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 23146969Smarius esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 24139027Sbrueffer [0-9]+"; 25108983Simp}; 26108983Simp 27108983Simp# Note that the attach/detach with the highest value wins, so that one can 28108983Simp# override these general rules. 29108983Simp 30108983Simp# 31147088Sbrooks# For ethernet like devices start configuring the interface. Due to 32126905Scperciva# a historical accident, this script is called pccard_ether. 33108983Simp# 34108983Simpattach 0 { 35148642Ssam media-type "ethernet"; 36108983Simp action "/etc/pccard_ether $device-name start"; 37108983Simp}; 38108983Simp 39108983Simpdetach 0 { 40148642Ssam media-type "ethernet"; 41108983Simp action "/etc/pccard_ether $device-name stop"; 42108983Simp}; 43108983Simp 44147088Sbrooks# 45147088Sbrooks# Try to start dhclient on Ethernet like interfaces when the link comes 46147088Sbrooks# up. Only devices that are configured to support DHCP will actually 47147088Sbrooks# run it. No link down rule exists because dhclient automaticly exits 48147088Sbrooks# when the link goes down. 49147088Sbrooks# 50147088Sbrooksnotify 0 { 51147088Sbrooks match "system" "IFNET"; 52147088Sbrooks match "type" "LINK_UP"; 53148642Ssam media-type "ethernet"; 54147088Sbrooks action "/etc/rc.d/dhclient start $subsystem"; 55147088Sbrooks}; 56147088Sbrooks 57148642Ssam# 58148642Ssam# Like Ethernet devices, but separate because 59148642Ssam# they have a different media type. We may want 60148642Ssam# to exploit this later. 61148642Ssam# 62148642Ssamdetach 0 { 63148642Ssam media-type "802.11"; 64148642Ssam action "/etc/pccard_ether $device-name stop"; 65148642Ssam}; 66148642Ssamattach 0 { 67148642Ssam media-type "802.11"; 68148642Ssam action "/etc/pccard_ether $device-name start"; 69148642Ssam}; 70148642Ssamnotify 0 { 71148642Ssam match "system" "IFNET"; 72148642Ssam match "type" "LINK_UP"; 73148642Ssam media-type "802.11"; 74148642Ssam action "/etc/rc.d/dhclient start $subsystem"; 75148642Ssam}; 76148642Ssam 77108983Simp# An entry like this might be in a different file, but is included here 78108983Simp# as an example of how to override things. Normally 'ed50' would match 79108983Simp# the above attach/detach stuff, but the value of 100 makes it 80139281Sbrueffer# hard wired to 1.2.3.4. 81108983Simpattach 100 { 82108983Simp device-name "ed50"; 83108983Simp action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 84108983Simp}; 85108983Simpdetach 100 { 86108983Simp device-name "ed50"; 87108983Simp}; 88108983Simp 89139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard. 90134584Sbrooksattach 100 { 91134584Sbrooks device-name "ukbd0"; 92146086Sbrian action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart"; 93134584Sbrooks}; 94134584Sbrooksdetach 100 { 95134584Sbrooks device-name "ukbd0"; 96134584Sbrooks action "kbdcontrol -k /dev/kbd0 < /dev/console"; 97134584Sbrooks}; 98134584Sbrooks 99138175Siedowse# The entry below starts moused when a mouse is plugged in. Moused 100138175Siedowse# stops automatically (actually it bombs :) when the device disappears. 101138175Siedowseattach 100 { 102138175Siedowse device-name "ums[0-9]+"; 103138175Siedowse action "/etc/rc.d/moused start $device-name"; 104138175Siedowse}; 105138175Siedowse 106108983Simp# 107148471Simp# Rescan scsi device-names on attach, but not detach. However, it is 108148471Simp# disabled by default due to reports of problems. 109108983Simp# 110108983Simpattach 0 { 111108983Simp device-name "$scsi-controller-regex"; 112131646Simp// action "camcontrol rescan all"; 113108983Simp}; 114108983Simp 115108983Simp# Don't even try to second guess what to do about drivers that don't 116114799Simp# match here. Instead, pass it off to syslog. Commented out for the 117139281Sbrueffer# moment, as pnpinfo isn't set in devd yet. 118119254Simpnomatch 0 { 119114852Simp# action "logger Unknown device: $pnpinfo $location $bus"; 120119254Simp}; 121108983Simp 122139281Sbrueffer# Switch power profiles when the AC line state changes. 123123626Snjlnotify 10 { 124123626Snjl match "system" "ACPI"; 125123626Snjl match "subsystem" "ACAD"; 126125366Snjl action "/etc/rc.d/power_profile $notify"; 127123626Snjl}; 128123626Snjl 129125366Snjl# Notify all users before beginning emergency shutdown when we get 130125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system 131125366Snjl# very soon. 132125366Snjlnotify 10 { 133125366Snjl match "system" "ACPI"; 134125366Snjl match "subsystem" "Thermal"; 135125366Snjl match "notify" "0xcc"; 136125366Snjl action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 137125366Snjl}; 138125366Snjl 139108983Simp/* EXAMPLES TO END OF FILE 140108983Simp 141108983Simp# The following might be an example of something that a vendor might 142108983Simp# install if you were to add their device. This might reside in 143108983Simp# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 144108983Simp# example, a pccard ethernet-like device. Students of history may 145108983Simp# know other devices by this name, and will get the in-jokes in this 146108983Simp# entry. 147108983Simpnomatch 10 { 148108983Simp match "bus" "pccard[0-9]+"; 149108983Simp match "manufacturer" "0x1234"; 150108983Simp match "product" "0x2323"; 151108983Simp action "kldload if_deqna"; 152108983Simp}; 153108983Simpattach 10 { 154108983Simp device-name "deqna[0-9]+"; 155108983Simp action "/etc/pccard_ether $device-name start"; 156108983Simp}; 157108983Simpdetach 10 { 158108983Simp device-name "deqna[0-9]+"; 159108983Simp action "/etc/pccard_ether $device-name stop"; 160108983Simp}; 161108983Simp 162121493Snjl# Examples of notify hooks. A notify is a generic way for a kernel 163121493Snjl# subsystem to send event notification to userland. 164121493Snjl# 165121493Snjl# Here are some examples of ACPI notify handlers. ACPI subsystems that 166121493Snjl# generate notifies include the AC adapter, power/sleep buttons, 167121493Snjl# control method batteries, lid switch, and thermal zones. 168121493Snjl# 169121493Snjl# Information returned is not always the same as the ACPI notify 170121493Snjl# events. See the ACPI specification for more information about 171121493Snjl# notifies. Here is the information returned for each subsystem: 172121493Snjl# 173121493Snjl# ACAD: AC line state (0 is offline, 1 is online) 174121493Snjl# Button: Button pressed (0 for power, 1 for sleep) 175121493Snjl# CMBAT: ACPI battery events 176121493Snjl# Lid: Lid state (0 is closed, 1 is open) 177121493Snjl# Thermal: ACPI thermal zone events 178121493Snjl# 179121493Snjl# This example calls a script when the AC state changes, passing the 180121493Snjl# notify value as the first argument. If the state is 0x00, it might 181121493Snjl# call some sysctls to implement economy mode. If 0x01, it might set 182121493Snjl# the mode to performance. 183121493Snjlnotify 10 { 184121493Snjl match "system" "ACPI"; 185121493Snjl match "subsystem" "ACAD"; 186121493Snjl action "/etc/acpi_ac $notify"; 187121493Snjl}; 188108983Simp*/ 189