devd.conf revision 148471
155714Skris# $FreeBSD: head/etc/devd.conf 148471 2005-07-28 03:51:54Z imp $ 255714Skris# 355714Skris# Refer to devd.conf(5) and devd(8) man pages for the details on how to 455714Skris# run and configure devd. 555714Skris# 655714Skris 755714Skris# NB: All regular expressions have an implicit ^$ around them. 8280304Sjkim# NB: device-name is shorthand for 'match device-name' 955714Skris 1055714Skrisoptions { 1155714Skris # Each directory directive adds a directory the list of directories 1255714Skris # that we scan for files. Files are read-in in the order that they 1355714Skris # are returned from readdir(3). The rule-sets are combined to 1455714Skris # create a DFA that's used to match events to actions. 15280304Sjkim directory "/etc/devd"; 1655714Skris directory "/usr/local/etc/devd"; 1755714Skris pid-file "/var/run/devd.pid"; 1855714Skris 1955714Skris # Setup some shorthand for regex that we use later in the file. 2055714Skris #XXX Yes, these are gross -- imp 2155714Skris set ethernet-nic-regex 22280304Sjkim "(an|ar|ath|aue|awi|axe|bfe|bge|cdce|cm|cnw|cs|cue|dc|de|ed|el|\ 2355714Skris em|ep|ex|fe|fxp|gem|hme|ie|ipw|iwi|kue|lge|lnc|my|nge|pcn|ral|\ 2455714Skris ray|re|rl|rue|sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|udav|ural|vge|\ 2555714Skris vr|vx|wb|wi|xe|xl)\ 2655714Skris [0-9]+"; 2755714Skris set scsi-controller-regex 2855714Skris "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\ 2955714Skris esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\ 3055714Skris [0-9]+"; 3155714Skris}; 3255714Skris 3355714Skris# Note that the attach/detach with the highest value wins, so that one can 3455714Skris# override these general rules. 3555714Skris 3655714Skris# 37280304Sjkim# For ethernet like devices start configuring the interface. Due to 3855714Skris# a historical accident, this script is called pccard_ether. 3955714Skris# 40280304Sjkimattach 0 { 4155714Skris device-name "$ethernet-nic-regex"; 4255714Skris action "/etc/pccard_ether $device-name start"; 4355714Skris}; 4455714Skris 4555714Skrisdetach 0 { 4655714Skris device-name "$ethernet-nic-regex"; 4755714Skris action "/etc/pccard_ether $device-name stop"; 4855714Skris}; 4955714Skris 5055714Skris# 5155714Skris# Try to start dhclient on Ethernet like interfaces when the link comes 52280304Sjkim# up. Only devices that are configured to support DHCP will actually 5355714Skris# run it. No link down rule exists because dhclient automaticly exits 5455714Skris# when the link goes down. 5555714Skris# 5655714Skrisnotify 0 { 5755714Skris match "system" "IFNET"; 5855714Skris match "subsystem" "$ethernet-nic-regex"; 59280304Sjkim match "type" "LINK_UP"; 60280304Sjkim action "/etc/rc.d/dhclient start $subsystem"; 61280304Sjkim}; 62280304Sjkim 6355714Skris# An entry like this might be in a different file, but is included here 64109998Smarkm# as an example of how to override things. Normally 'ed50' would match 65280304Sjkim# the above attach/detach stuff, but the value of 100 makes it 6655714Skris# hard wired to 1.2.3.4. 6755714Skrisattach 100 { 6855714Skris device-name "ed50"; 6955714Skris action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 7055714Skris}; 7155714Skrisdetach 100 { 7255714Skris device-name "ed50"; 73160814Ssimon}; 74280304Sjkim 75160814Ssimon# When a USB keyboard arrives, attach it as the console keyboard. 7655714Skrisattach 100 { 77280304Sjkim device-name "ukbd0"; 7855714Skris action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart"; 7955714Skris}; 80280304Sjkimdetach 100 { 81280304Sjkim device-name "ukbd0"; 8255714Skris action "kbdcontrol -k /dev/kbd0 < /dev/console"; 83280304Sjkim}; 84280304Sjkim 85280304Sjkim# The entry below starts moused when a mouse is plugged in. Moused 86280304Sjkim# stops automatically (actually it bombs :) when the device disappears. 87280304Sjkimattach 100 { 88280304Sjkim device-name "ums[0-9]+"; 89109998Smarkm action "/etc/rc.d/moused start $device-name"; 90280304Sjkim}; 9155714Skris 9255714Skris# 93280304Sjkim# Rescan scsi device-names on attach, but not detach. However, it is 9455714Skris# disabled by default due to reports of problems. 9555714Skris# 96280304Sjkimattach 0 { 97280304Sjkim device-name "$scsi-controller-regex"; 98280304Sjkim// action "camcontrol rescan all"; 9955714Skris}; 10055714Skris 10155714Skris# Don't even try to second guess what to do about drivers that don't 10255714Skris# match here. Instead, pass it off to syslog. Commented out for the 10355714Skris# moment, as pnpinfo isn't set in devd yet. 10455714Skrisnomatch 0 { 10555714Skris# action "logger Unknown device: $pnpinfo $location $bus"; 10655714Skris}; 10755714Skris 10855714Skris# Switch power profiles when the AC line state changes. 10955714Skrisnotify 10 { 11055714Skris match "system" "ACPI"; 11155714Skris match "subsystem" "ACAD"; 11255714Skris action "/etc/rc.d/power_profile $notify"; 11355714Skris}; 11455714Skris 11555714Skris# Notify all users before beginning emergency shutdown when we get 11655714Skris# a _CRT or _HOT thermal event and we're going to power down the system 11755714Skris# very soon. 11855714Skrisnotify 10 { 11955714Skris match "system" "ACPI"; 12055714Skris match "subsystem" "Thermal"; 12155714Skris match "notify" "0xcc"; 12255714Skris action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 123280304Sjkim}; 124280304Sjkim 125280304Sjkim/* EXAMPLES TO END OF FILE 12655714Skris 12755714Skris# The following might be an example of something that a vendor might 128280304Sjkim# install if you were to add their device. This might reside in 12955714Skris# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 13055714Skris# example, a pccard ethernet-like device. Students of history may 13155714Skris# know other devices by this name, and will get the in-jokes in this 132280304Sjkim# entry. 133280304Sjkimnomatch 10 { 13455714Skris match "bus" "pccard[0-9]+"; 13555714Skris match "manufacturer" "0x1234"; 13655714Skris match "product" "0x2323"; 137280304Sjkim action "kldload if_deqna"; 138280304Sjkim}; 139280304Sjkimattach 10 { 140280304Sjkim device-name "deqna[0-9]+"; 141280304Sjkim action "/etc/pccard_ether $device-name start"; 14255714Skris}; 14355714Skrisdetach 10 { 14455714Skris device-name "deqna[0-9]+"; 145280304Sjkim action "/etc/pccard_ether $device-name stop"; 146280304Sjkim}; 147280304Sjkim 148280304Sjkim# Examples of notify hooks. A notify is a generic way for a kernel 149280304Sjkim# subsystem to send event notification to userland. 150280304Sjkim# 151280304Sjkim# Here are some examples of ACPI notify handlers. ACPI subsystems that 15255714Skris# generate notifies include the AC adapter, power/sleep buttons, 15355714Skris# control method batteries, lid switch, and thermal zones. 154280304Sjkim# 155280304Sjkim# Information returned is not always the same as the ACPI notify 15655714Skris# events. See the ACPI specification for more information about 15755714Skris# notifies. Here is the information returned for each subsystem: 158280304Sjkim# 159280304Sjkim# ACAD: AC line state (0 is offline, 1 is online) 16055714Skris# Button: Button pressed (0 for power, 1 for sleep) 161280304Sjkim# CMBAT: ACPI battery events 16255714Skris# Lid: Lid state (0 is closed, 1 is open) 163280304Sjkim# Thermal: ACPI thermal zone events 164280304Sjkim# 165280304Sjkim# This example calls a script when the AC state changes, passing the 166280304Sjkim# notify value as the first argument. If the state is 0x00, it might 167280304Sjkim# call some sysctls to implement economy mode. If 0x01, it might set 168280304Sjkim# the mode to performance. 169280304Sjkimnotify 10 { 170280304Sjkim match "system" "ACPI"; 171280304Sjkim match "subsystem" "ACAD"; 172280304Sjkim action "/etc/acpi_ac $notify"; 173280304Sjkim}; 17455714Skris*/ 175280304Sjkim