devd.conf revision 125366
1108983Simp# $FreeBSD: head/etc/devd.conf 125366 2004-02-03 04:18:56Z njl $ 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. 20108983Simp set ethernet-nic-regex 21119917Swpaul "(an|ar|ath|aue|awi|bfe|bge|cm|cnw|cs|cue|dc|de|ed|el|em|ep|\ 22119917Swpaul ex|fe|fxp|gem|gx|hme|ie|kue|lge|lnc|my|nge|pcn|ray|re|rl|rue|\ 23108983Simp sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|vr|vx|wb|wi|xe|xl)[0-9]+"; 24108983Simp set scsi-controller-regex 25108983Simp "(adv|advw|aic|aha|ahb|ahc|ahd|bt|ct|iir|isp|mly|mpt|ncv|nsp|\ 26108983Simp stg|sym|wds)[0-9]+"; 27108983Simp}; 28108983Simp 29108983Simp# Note that the attach/detach with the highest value wins, so that one can 30108983Simp# override these general rules. 31108983Simp 32108983Simp# 33108983Simp# For ethernet like devices, the default is to run dhclient. Due to 34108983Simp# a historical accident, the name of this script it called pccard_ether 35108983Simp# 36108983Simpattach 0 { 37108983Simp device-name "$ethernet-nic-regex"; 38108983Simp action "/etc/pccard_ether $device-name start"; 39108983Simp}; 40108983Simp 41108983Simpdetach 0 { 42108983Simp device-name "$ethernet-nic-regex"; 43108983Simp action "/etc/pccard_ether $device-name stop"; 44108983Simp}; 45108983Simp 46108983Simp# An entry like this might be in a different file, but is included here 47108983Simp# as an example of how to override things. Normally 'ed50' would match 48108983Simp# the above attach/detach stuff, but the value of 100 makes it 49108983Simp# ed50 is hard wired to 1.2.3.4 50108983Simpattach 100 { 51108983Simp device-name "ed50"; 52108983Simp action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 53108983Simp}; 54108983Simpdetach 100 { 55108983Simp device-name "ed50"; 56108983Simp}; 57108983Simp 58108983Simp# 59108983Simp# Rescan scsi device-names on attach, but not detach. 60108983Simp# 61108983Simpattach 0 { 62108983Simp device-name "$scsi-controller-regex"; 63108983Simp action "camcontrol rescan all"; 64108983Simp}; 65108983Simp 66108983Simp# Don't even try to second guess what to do about drivers that don't 67114799Simp# match here. Instead, pass it off to syslog. Commented out for the 68114799Simp# moment, as pnpinfo isn't set in devd yet 69119254Simpnomatch 0 { 70114852Simp# action "logger Unknown device: $pnpinfo $location $bus"; 71119254Simp}; 72108983Simp 73123626Snjl# Switch power profiles when the AC line state changes 74123626Snjlnotify 10 { 75123626Snjl match "system" "ACPI"; 76123626Snjl match "subsystem" "ACAD"; 77125366Snjl action "/etc/rc.d/power_profile $notify"; 78123626Snjl}; 79123626Snjl 80125366Snjl# Notify all users before beginning emergency shutdown when we get 81125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system 82125366Snjl# very soon. 83125366Snjlnotify 10 { 84125366Snjl match "system" "ACPI"; 85125366Snjl match "subsystem" "Thermal"; 86125366Snjl match "notify" "0xcc"; 87125366Snjl action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 88125366Snjl}; 89125366Snjl 90108983Simp/* EXAMPLES TO END OF FILE 91108983Simp 92108983Simp# The following might be an example of something that a vendor might 93108983Simp# install if you were to add their device. This might reside in 94108983Simp# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 95108983Simp# example, a pccard ethernet-like device. Students of history may 96108983Simp# know other devices by this name, and will get the in-jokes in this 97108983Simp# entry. 98108983Simpnomatch 10 { 99108983Simp match "bus" "pccard[0-9]+"; 100108983Simp match "manufacturer" "0x1234"; 101108983Simp match "product" "0x2323"; 102108983Simp action "kldload if_deqna"; 103108983Simp}; 104108983Simpattach 10 { 105108983Simp device-name "deqna[0-9]+"; 106108983Simp action "/etc/pccard_ether $device-name start"; 107108983Simp}; 108108983Simpdetach 10 { 109108983Simp device-name "deqna[0-9]+"; 110108983Simp action "/etc/pccard_ether $device-name stop"; 111108983Simp}; 112108983Simp 113121493Snjl# Examples of notify hooks. A notify is a generic way for a kernel 114121493Snjl# subsystem to send event notification to userland. 115121493Snjl# 116121493Snjl# Here are some examples of ACPI notify handlers. ACPI subsystems that 117121493Snjl# generate notifies include the AC adapter, power/sleep buttons, 118121493Snjl# control method batteries, lid switch, and thermal zones. 119121493Snjl# 120121493Snjl# Information returned is not always the same as the ACPI notify 121121493Snjl# events. See the ACPI specification for more information about 122121493Snjl# notifies. Here is the information returned for each subsystem: 123121493Snjl# 124121493Snjl# ACAD: AC line state (0 is offline, 1 is online) 125121493Snjl# Button: Button pressed (0 for power, 1 for sleep) 126121493Snjl# CMBAT: ACPI battery events 127121493Snjl# Lid: Lid state (0 is closed, 1 is open) 128121493Snjl# Thermal: ACPI thermal zone events 129121493Snjl# 130121493Snjl# This example calls a script when the AC state changes, passing the 131121493Snjl# notify value as the first argument. If the state is 0x00, it might 132121493Snjl# call some sysctls to implement economy mode. If 0x01, it might set 133121493Snjl# the mode to performance. 134121493Snjlnotify 10 { 135121493Snjl match "system" "ACPI"; 136121493Snjl match "subsystem" "ACAD"; 137121493Snjl action "/etc/acpi_ac $notify"; 138121493Snjl}; 139108983Simp*/ 140