devd.conf revision 139281
11817Sdg# $FreeBSD: head/etc/devd.conf 139281 2004-12-25 00:12:27Z brueffer $
21817Sdg#
31817Sdg# Refer to devd.conf(5) and devd(8) man pages for the details on how to
41817Sdg# run and configure devd.
51817Sdg#
61817Sdg
71817Sdg# NB: All regular expressions have an implicit ^$ around them.
81817Sdg# NB: device-name is shorthand for 'match device-name'
91817Sdg
101817Sdgoptions {
111817Sdg	# Each directory directive adds a directory the list of directories
121817Sdg	# that we scan for files.  Files are read-in in the order that they
131817Sdg	# are returned from readdir(3).  The rule-sets are combined to
141817Sdg	# create a DFA that's used to match events to actions.
151817Sdg	directory "/etc/devd";
161817Sdg	directory "/usr/local/etc/devd";
171817Sdg	pid-file "/var/run/devd.pid";
181817Sdg
191817Sdg	# Setup some shorthand for regex that we use later in the file.
201817Sdg	set ethernet-nic-regex
211817Sdg		"(an|ar|ath|aue|awi|axe|bfe|bge|cm|cnw|cs|cue|dc|de|ed|el|em|\
221817Sdg		ep|ex|fe|fxp|gem|hme|ie|kue|lge|lnc|my|nge|pcn|ray|re|rl|rue|\
231817Sdg		sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|udav|vge|vr|vx|wb|wi|xe|xl)\
241817Sdg		[0-9]+";
251817Sdg	set scsi-controller-regex
261817Sdg		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
271817Sdg		ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
281817Sdg		[0-9]+";
2950477Speter};
301817Sdg
311817Sdg# Note that the attach/detach with the highest value wins, so that one can
324Srgrimes# override these general rules.
334Srgrimes
3491497Smarkm#
3591497Smarkm# For ethernet like devices, the default is to run dhclient.  Due to
364Srgrimes# a historical accident, this script is called pccard_ether.
374Srgrimes#
38719Swollmanattach 0 {
394479Sbde	device-name "$ethernet-nic-regex";
40719Swollman	action "/etc/pccard_ether $device-name start";
41143063Sjoerg};
42143063Sjoerg
43143063Sjoergdetach 0 {
44143063Sjoerg	device-name "$ethernet-nic-regex";
45181775Skmacy	action "/etc/pccard_ether $device-name stop";
46181775Skmacy};
47181775Skmacy
48184040Skmacy# An entry like this might be in a different file, but is included here
49181775Skmacy# as an example of how to override things.  Normally 'ed50' would match
50181775Skmacy# the above attach/detach stuff, but the value of 100 makes it
51181775Skmacy# hard wired to 1.2.3.4.
52197693Skmacyattach 100 {
53197693Skmacy	device-name "ed50";
54181775Skmacy	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
55181775Skmacy};
56103778Speterdetach 100 {
5793264Sdillon	device-name "ed50";
58220627Sjkim};
59220627Sjkim
60220627Sjkim# When a USB keyboard arrives, attach it as the console keyboard.
6138392Sdfrattach 100 {
62220627Sjkim	device-name "ukbd0";
63220627Sjkim	action "test -c /dev/kbd1 && kbdcontrol -k /dev/kbd1 < /dev/console";
64220627Sjkim};
6538392Sdfrdetach 100 {
66143063Sjoerg	device-name "ukbd0";
674Srgrimes	action "kbdcontrol -k /dev/kbd0 < /dev/console";
6815122Sbde};
6915122Sbde
703102Sdg# The entry below starts moused when a mouse is plugged in. Moused
714479Sbde# stops automatically (actually it bombs :) when the device disappears.
723102Sdgattach 100 {
733102Sdg	device-name "ums[0-9]+";
7455672Sbde	action "/etc/rc.d/moused start $device-name";
7555672Sbde};
7655672Sbde
7755672Sbde#
7855672Sbde# Rescan scsi device-names on attach, but not detach.
79194115Sed#
8055672Sbdeattach 0 {
8155672Sbde	device-name "$scsi-controller-regex";
8255672Sbde//	action "camcontrol rescan all";
8355672Sbde};
8455672Sbde
8555672Sbde# Don't even try to second guess what to do about drivers that don't
8655672Sbde# match here.  Instead, pass it off to syslog.  Commented out for the
8755672Sbde# moment, as pnpinfo isn't set in devd yet.
88194115Sednomatch 0 {
8955672Sbde#	action "logger Unknown device: $pnpinfo $location $bus";
9055672Sbde};
9155672Sbde
923102Sdg# Switch power profiles when the AC line state changes.
93195940Skibnotify 10 {
94195940Skib	match "system"		"ACPI";
95195940Skib	match "subsystem"	"ACAD";
96195940Skib	action "/etc/rc.d/power_profile $notify";
97195940Skib};
98195940Skib
99195940Skib# Notify all users before beginning emergency shutdown when we get
100238311Sjhb# a _CRT or _HOT thermal event and we're going to power down the system
101238311Sjhb# very soon.
102238311Sjhbnotify 10 {
103238311Sjhb	match "system"		"ACPI";
104238311Sjhb	match "subsystem"	"Thermal";
105238311Sjhb	match "notify"		"0xcc";
106238311Sjhb	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
1074479Sbde};
1083102Sdg
109181775Skmacy/* EXAMPLES TO END OF FILE
110181775Skmacy
111181775Skmacy# The following might be an example of something that a vendor might
112184040Skmacy# install if you were to add their device.  This might reside in
113181775Skmacy# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
1143102Sdg# example, a pccard ethernet-like device.  Students of history may
1153102Sdg# know other devices by this name, and will get the in-jokes in this
1163102Sdg# entry.
11794386Sdwmalonenomatch 10 {
11894386Sdwmalone	match "bus" "pccard[0-9]+";
11994386Sdwmalone	match "manufacturer" "0x1234";
12094386Sdwmalone	match "product" "0x2323";
12194386Sdwmalone	action "kldload if_deqna";
12294386Sdwmalone};
12394386Sdwmaloneattach 10 {
12494386Sdwmalone	device-name "deqna[0-9]+";
125146170Snectar	action "/etc/pccard_ether $device-name start";
126146170Snectar};
127146170Snectardetach 10 {
128146170Snectar	device-name "deqna[0-9]+";
129146170Snectar	action "/etc/pccard_ether $device-name stop";
130146170Snectar};
131146170Snectar
132146170Snectar# Examples of notify hooks.  A notify is a generic way for a kernel
1334479Sbde# subsystem to send event notification to userland.
1343102Sdg#
135181775Skmacy# Here are some examples of ACPI notify handlers.  ACPI subsystems that
136181775Skmacy# generate notifies include the AC adapter, power/sleep buttons,
137184040Skmacy# control method batteries, lid switch, and thermal zones.
13810342Sbde#
139181775Skmacy# Information returned is not always the same as the ACPI notify
1403102Sdg# events.  See the ACPI specification for more information about
1413102Sdg# notifies.  Here is the information returned for each subsystem:
142197647Savg#
143223796Sjkim# ACAD:		AC line state (0 is offline, 1 is online)
144178299Sjeff# Button:	Button pressed (0 for power, 1 for sleep)
145223796Sjkim# CMBAT:	ACPI battery events
146223796Sjkim# Lid:		Lid state (0 is closed, 1 is open)
147223796Sjkim# Thermal:	ACPI thermal zone events
148178299Sjeff#
149178299Sjeff# This example calls a script when the AC state changes, passing the
150197647Savg# notify value as the first argument.  If the state is 0x00, it might
151223796Sjkim# call some sysctls to implement economy mode.  If 0x01, it might set
152178299Sjeff# the mode to performance.
153223796Sjkimnotify 10 {
154223796Sjkim	match "system"		"ACPI";
155178299Sjeff	match "subsystem"	"ACAD";
156178299Sjeff	action			"/etc/acpi_ac $notify";
157195940Skib};
158238972Skib*/
159238972Skib