devd.conf revision 148471
1# $FreeBSD: head/etc/devd.conf 148471 2005-07-28 03:51:54Z imp $ 2# 3# Refer to devd.conf(5) and devd(8) man pages for the details on how to 4# run and configure devd. 5# 6 7# NB: All regular expressions have an implicit ^$ around them. 8# NB: device-name is shorthand for 'match device-name' 9 10options { 11 # Each directory directive adds a directory the list of directories 12 # that we scan for files. Files are read-in in the order that they 13 # are returned from readdir(3). The rule-sets are combined to 14 # create a DFA that's used to match events to actions. 15 directory "/etc/devd"; 16 directory "/usr/local/etc/devd"; 17 pid-file "/var/run/devd.pid"; 18 19 # Setup some shorthand for regex that we use later in the file. 20 #XXX Yes, these are gross -- imp 21 set ethernet-nic-regex 22 "(an|ar|ath|aue|awi|axe|bfe|bge|cdce|cm|cnw|cs|cue|dc|de|ed|el|\ 23 em|ep|ex|fe|fxp|gem|hme|ie|ipw|iwi|kue|lge|lnc|my|nge|pcn|ral|\ 24 ray|re|rl|rue|sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|udav|ural|vge|\ 25 vr|vx|wb|wi|xe|xl)\ 26 [0-9]+"; 27 set scsi-controller-regex 28 "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 29 esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 30 [0-9]+"; 31}; 32 33# Note that the attach/detach with the highest value wins, so that one can 34# override these general rules. 35 36# 37# For ethernet like devices start configuring the interface. Due to 38# a historical accident, this script is called pccard_ether. 39# 40attach 0 { 41 device-name "$ethernet-nic-regex"; 42 action "/etc/pccard_ether $device-name start"; 43}; 44 45detach 0 { 46 device-name "$ethernet-nic-regex"; 47 action "/etc/pccard_ether $device-name stop"; 48}; 49 50# 51# Try to start dhclient on Ethernet like interfaces when the link comes 52# up. Only devices that are configured to support DHCP will actually 53# run it. No link down rule exists because dhclient automaticly exits 54# when the link goes down. 55# 56notify 0 { 57 match "system" "IFNET"; 58 match "subsystem" "$ethernet-nic-regex"; 59 match "type" "LINK_UP"; 60 action "/etc/rc.d/dhclient start $subsystem"; 61}; 62 63# An entry like this might be in a different file, but is included here 64# as an example of how to override things. Normally 'ed50' would match 65# the above attach/detach stuff, but the value of 100 makes it 66# hard wired to 1.2.3.4. 67attach 100 { 68 device-name "ed50"; 69 action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 70}; 71detach 100 { 72 device-name "ed50"; 73}; 74 75# When a USB keyboard arrives, attach it as the console keyboard. 76attach 100 { 77 device-name "ukbd0"; 78 action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart"; 79}; 80detach 100 { 81 device-name "ukbd0"; 82 action "kbdcontrol -k /dev/kbd0 < /dev/console"; 83}; 84 85# The entry below starts moused when a mouse is plugged in. Moused 86# stops automatically (actually it bombs :) when the device disappears. 87attach 100 { 88 device-name "ums[0-9]+"; 89 action "/etc/rc.d/moused start $device-name"; 90}; 91 92# 93# Rescan scsi device-names on attach, but not detach. However, it is 94# disabled by default due to reports of problems. 95# 96attach 0 { 97 device-name "$scsi-controller-regex"; 98// action "camcontrol rescan all"; 99}; 100 101# Don't even try to second guess what to do about drivers that don't 102# match here. Instead, pass it off to syslog. Commented out for the 103# moment, as pnpinfo isn't set in devd yet. 104nomatch 0 { 105# action "logger Unknown device: $pnpinfo $location $bus"; 106}; 107 108# Switch power profiles when the AC line state changes. 109notify 10 { 110 match "system" "ACPI"; 111 match "subsystem" "ACAD"; 112 action "/etc/rc.d/power_profile $notify"; 113}; 114 115# Notify all users before beginning emergency shutdown when we get 116# a _CRT or _HOT thermal event and we're going to power down the system 117# very soon. 118notify 10 { 119 match "system" "ACPI"; 120 match "subsystem" "Thermal"; 121 match "notify" "0xcc"; 122 action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 123}; 124 125/* EXAMPLES TO END OF FILE 126 127# The following might be an example of something that a vendor might 128# install if you were to add their device. This might reside in 129# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 130# example, a pccard ethernet-like device. Students of history may 131# know other devices by this name, and will get the in-jokes in this 132# entry. 133nomatch 10 { 134 match "bus" "pccard[0-9]+"; 135 match "manufacturer" "0x1234"; 136 match "product" "0x2323"; 137 action "kldload if_deqna"; 138}; 139attach 10 { 140 device-name "deqna[0-9]+"; 141 action "/etc/pccard_ether $device-name start"; 142}; 143detach 10 { 144 device-name "deqna[0-9]+"; 145 action "/etc/pccard_ether $device-name stop"; 146}; 147 148# Examples of notify hooks. A notify is a generic way for a kernel 149# subsystem to send event notification to userland. 150# 151# Here are some examples of ACPI notify handlers. ACPI subsystems that 152# generate notifies include the AC adapter, power/sleep buttons, 153# control method batteries, lid switch, and thermal zones. 154# 155# Information returned is not always the same as the ACPI notify 156# events. See the ACPI specification for more information about 157# notifies. Here is the information returned for each subsystem: 158# 159# ACAD: AC line state (0 is offline, 1 is online) 160# Button: Button pressed (0 for power, 1 for sleep) 161# CMBAT: ACPI battery events 162# Lid: Lid state (0 is closed, 1 is open) 163# Thermal: ACPI thermal zone events 164# 165# This example calls a script when the AC state changes, passing the 166# notify value as the first argument. If the state is 0x00, it might 167# call some sysctls to implement economy mode. If 0x01, it might set 168# the mode to performance. 169notify 10 { 170 match "system" "ACPI"; 171 match "subsystem" "ACAD"; 172 action "/etc/acpi_ac $notify"; 173}; 174*/ 175