devd.conf revision 139281
1241675Suqs# $FreeBSD: head/etc/devd.conf 139281 2004-12-25 00:12:27Z brueffer $
2241675Suqs#
3241675Suqs# Refer to devd.conf(5) and devd(8) man pages for the details on how to
4241675Suqs# run and configure devd.
5241675Suqs#
6241675Suqs
7241675Suqs# NB: All regular expressions have an implicit ^$ around them.
8241675Suqs# NB: device-name is shorthand for 'match device-name'
9241675Suqs
10241675Suqsoptions {
11241675Suqs	# Each directory directive adds a directory the list of directories
12241675Suqs	# that we scan for files.  Files are read-in in the order that they
13241675Suqs	# are returned from readdir(3).  The rule-sets are combined to
14241675Suqs	# create a DFA that's used to match events to actions.
15241675Suqs	directory "/etc/devd";
16241675Suqs	directory "/usr/local/etc/devd";
17241675Suqs	pid-file "/var/run/devd.pid";
18241675Suqs
19241675Suqs	# Setup some shorthand for regex that we use later in the file.
20241675Suqs	set ethernet-nic-regex
21241675Suqs		"(an|ar|ath|aue|awi|axe|bfe|bge|cm|cnw|cs|cue|dc|de|ed|el|em|\
22241675Suqs		ep|ex|fe|fxp|gem|hme|ie|kue|lge|lnc|my|nge|pcn|ray|re|rl|rue|\
23241675Suqs		sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|udav|vge|vr|vx|wb|wi|xe|xl)\
24241675Suqs		[0-9]+";
25241675Suqs	set scsi-controller-regex
26241675Suqs		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
27241675Suqs		ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
28241675Suqs		[0-9]+";
29241675Suqs};
30241675Suqs
31241675Suqs# Note that the attach/detach with the highest value wins, so that one can
32241675Suqs# override these general rules.
33241675Suqs
34241675Suqs#
35241675Suqs# For ethernet like devices, the default is to run dhclient.  Due to
36241675Suqs# a historical accident, this script is called pccard_ether.
37241675Suqs#
38241675Suqsattach 0 {
39241675Suqs	device-name "$ethernet-nic-regex";
40241675Suqs	action "/etc/pccard_ether $device-name start";
41241675Suqs};
42241675Suqs
43241675Suqsdetach 0 {
44241675Suqs	device-name "$ethernet-nic-regex";
45241675Suqs	action "/etc/pccard_ether $device-name stop";
46241675Suqs};
47241675Suqs
48241675Suqs# An entry like this might be in a different file, but is included here
49241675Suqs# as an example of how to override things.  Normally 'ed50' would match
50241675Suqs# the above attach/detach stuff, but the value of 100 makes it
51241675Suqs# hard wired to 1.2.3.4.
52241675Suqsattach 100 {
53241675Suqs	device-name "ed50";
54241675Suqs	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
55241675Suqs};
56241675Suqsdetach 100 {
57241675Suqs	device-name "ed50";
58241675Suqs};
59241675Suqs
60241675Suqs# When a USB keyboard arrives, attach it as the console keyboard.
61241675Suqsattach 100 {
62241675Suqs	device-name "ukbd0";
63241675Suqs	action "test -c /dev/kbd1 && kbdcontrol -k /dev/kbd1 < /dev/console";
64241675Suqs};
65241675Suqsdetach 100 {
66241675Suqs	device-name "ukbd0";
67241675Suqs	action "kbdcontrol -k /dev/kbd0 < /dev/console";
68241675Suqs};
69241675Suqs
70241675Suqs# The entry below starts moused when a mouse is plugged in. Moused
71241675Suqs# stops automatically (actually it bombs :) when the device disappears.
72241675Suqsattach 100 {
73241675Suqs	device-name "ums[0-9]+";
74241675Suqs	action "/etc/rc.d/moused start $device-name";
75241675Suqs};
76241675Suqs
77241675Suqs#
78241675Suqs# Rescan scsi device-names on attach, but not detach.
79241675Suqs#
80241675Suqsattach 0 {
81241675Suqs	device-name "$scsi-controller-regex";
82241675Suqs//	action "camcontrol rescan all";
83241675Suqs};
84241675Suqs
85241675Suqs# Don't even try to second guess what to do about drivers that don't
86241675Suqs# match here.  Instead, pass it off to syslog.  Commented out for the
87241675Suqs# moment, as pnpinfo isn't set in devd yet.
88241675Suqsnomatch 0 {
89241675Suqs#	action "logger Unknown device: $pnpinfo $location $bus";
90241675Suqs};
91241675Suqs
92241675Suqs# Switch power profiles when the AC line state changes.
93241675Suqsnotify 10 {
94241675Suqs	match "system"		"ACPI";
95241675Suqs	match "subsystem"	"ACAD";
96241675Suqs	action "/etc/rc.d/power_profile $notify";
97241675Suqs};
98241675Suqs
99241675Suqs# Notify all users before beginning emergency shutdown when we get
100241675Suqs# a _CRT or _HOT thermal event and we're going to power down the system
101241675Suqs# very soon.
102241675Suqsnotify 10 {
103241675Suqs	match "system"		"ACPI";
104241675Suqs	match "subsystem"	"Thermal";
105241675Suqs	match "notify"		"0xcc";
106241675Suqs	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
107241675Suqs};
108241675Suqs
109241675Suqs/* EXAMPLES TO END OF FILE
110241675Suqs
111241675Suqs# The following might be an example of something that a vendor might
112241675Suqs# install if you were to add their device.  This might reside in
113241675Suqs# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
114241675Suqs# example, a pccard ethernet-like device.  Students of history may
115241675Suqs# know other devices by this name, and will get the in-jokes in this
116241675Suqs# entry.
117241675Suqsnomatch 10 {
118241675Suqs	match "bus" "pccard[0-9]+";
119241675Suqs	match "manufacturer" "0x1234";
120241675Suqs	match "product" "0x2323";
121241675Suqs	action "kldload if_deqna";
122241675Suqs};
123241675Suqsattach 10 {
124241675Suqs	device-name "deqna[0-9]+";
125241675Suqs	action "/etc/pccard_ether $device-name start";
126241675Suqs};
127241675Suqsdetach 10 {
128241675Suqs	device-name "deqna[0-9]+";
129241675Suqs	action "/etc/pccard_ether $device-name stop";
130241675Suqs};
131241675Suqs
132241675Suqs# Examples of notify hooks.  A notify is a generic way for a kernel
133241675Suqs# subsystem to send event notification to userland.
134241675Suqs#
135241675Suqs# Here are some examples of ACPI notify handlers.  ACPI subsystems that
136241675Suqs# generate notifies include the AC adapter, power/sleep buttons,
137241675Suqs# control method batteries, lid switch, and thermal zones.
138241675Suqs#
139241675Suqs# Information returned is not always the same as the ACPI notify
140241675Suqs# events.  See the ACPI specification for more information about
141241675Suqs# notifies.  Here is the information returned for each subsystem:
142241675Suqs#
143241675Suqs# ACAD:		AC line state (0 is offline, 1 is online)
144241675Suqs# Button:	Button pressed (0 for power, 1 for sleep)
145241675Suqs# CMBAT:	ACPI battery events
146241675Suqs# Lid:		Lid state (0 is closed, 1 is open)
147241675Suqs# Thermal:	ACPI thermal zone events
148241675Suqs#
149241675Suqs# This example calls a script when the AC state changes, passing the
150241675Suqs# notify value as the first argument.  If the state is 0x00, it might
151241675Suqs# call some sysctls to implement economy mode.  If 0x01, it might set
152241675Suqs# the mode to performance.
153241675Suqsnotify 10 {
154241675Suqs	match "system"		"ACPI";
155241675Suqs	match "subsystem"	"ACAD";
156241675Suqs	action			"/etc/acpi_ac $notify";
157241675Suqs};
158241675Suqs*/
159241675Suqs