devd.conf revision 179804
1133808Spjd# $FreeBSD: head/etc/devd.conf 179804 2008-06-15 13:25:23Z kmacy $
2133808Spjd#
3133808Spjd# Refer to devd.conf(5) and devd(8) man pages for the details on how to
4133808Spjd# run and configure devd.
5133808Spjd#
6133808Spjd
7133808Spjd# NB: All regular expressions have an implicit ^$ around them.
8133808Spjd# NB: device-name is shorthand for 'match device-name'
9133808Spjd
10133808Spjdoptions {
11133808Spjd	# Each directory directive adds a directory the list of directories
12133808Spjd	# that we scan for files.  Files are read-in in the order that they
13133808Spjd	# are returned from readdir(3).  The rule-sets are combined to
14133808Spjd	# create a DFA that's used to match events to actions.
15133808Spjd	directory "/etc/devd";
16133808Spjd	directory "/usr/local/etc/devd";
17133808Spjd	pid-file "/var/run/devd.pid";
18133808Spjd
19133808Spjd	# Setup some shorthand for regex that we use later in the file.
20133808Spjd	#XXX Yes, these are gross -- imp
21133808Spjd	set scsi-controller-regex
22133808Spjd		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
23133808Spjd		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
24133808Spjd		[0-9]+";
25133808Spjd};
26133808Spjd
27133808Spjd# Note that the attach/detach with the highest value wins, so that one can
28133808Spjd# override these general rules.
29133808Spjd
30133808Spjd#
31133808Spjd# Configure the interface on attach.  Due to a historical accident, this
32133808Spjd# script is called pccard_ether.
33133808Spjd#
34133808Spjdnotify 0 {
35133808Spjd	match "system"		"IFNET";
36133808Spjd	match "type"		"ATTACH";
37133808Spjd	action "/etc/pccard_ether $subsystem start";
38133808Spjd};
39133808Spjd
40133808Spjdnotify 0 {
41133808Spjd	match "system"		"IFNET";
42133808Spjd	match "type"		"DETACH";
43133808Spjd	action "/etc/pccard_ether $subsystem stop";
44133808Spjd};
45133808Spjd
46133808Spjd#
47133808Spjd# Try to start dhclient on Ethernet like interfaces when the link comes
48133808Spjd# up.  Only devices that are configured to support DHCP will actually
49133808Spjd# run it.  No link down rule exists because dhclient automaticly exits
50133808Spjd# when the link goes down.
51133808Spjd#
52133808Spjdnotify 0 {
53133808Spjd	match "system"		"IFNET";
54133808Spjd	match "type"		"LINK_UP";
55133808Spjd	media-type		"ethernet";
56133808Spjd	action "/etc/rc.d/dhclient quietstart $subsystem";
57133808Spjd};
58133808Spjd
59133808Spjd#
60133808Spjd# Like Ethernet devices, but separate because
61134124Spjd# they have a different media type.  We may want
62134124Spjd# to exploit this later.
63134168Spjd#
64134168Spjddetach 0 {
65133808Spjd	media-type "802.11";
66133808Spjd	action "/etc/pccard_ether $device-name stop";
67133808Spjd};
68133808Spjdattach 0 {
69133808Spjd	media-type "802.11";
70133808Spjd	action "/etc/pccard_ether $device-name start";
71133808Spjd};
72133808Spjdnotify 0 {
73133808Spjd	match "system"		"IFNET";
74133808Spjd	match "type"		"LINK_UP";
75133808Spjd	media-type		"802.11";
76133808Spjd	action "/etc/rc.d/dhclient quietstart $subsystem";
77133808Spjd};
78133808Spjd
79133808Spjd# An entry like this might be in a different file, but is included here
80134124Spjd# as an example of how to override things.  Normally 'ed50' would match
81134168Spjd# the above attach/detach stuff, but the value of 100 makes it
82133808Spjd# hard wired to 1.2.3.4.
83133808Spjdattach 100 {
84133808Spjd	device-name "ed50";
85133808Spjd	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
86133808Spjd};
87133808Spjddetach 100 {
88133808Spjd	device-name "ed50";
89133808Spjd};
90133808Spjd
91133808Spjd# When a USB Bluetooth dongle appears activate it
92133808Spjdattach 100 {
93133808Spjd	device-name "ubt[0-9]+";
94133808Spjd	action "/etc/rc.d/bluetooth quietstart $device-name";
95133808Spjd};
96133808Spjddetach 100 {
97133808Spjd	device-name "ubt[0-9]+";
98133808Spjd	action "/etc/rc.d/bluetooth quietstop $device-name";
99133808Spjd};
100133808Spjd
101133808Spjd# When a USB keyboard arrives, attach it as the console keyboard.
102133808Spjdattach 100 {
103133808Spjd	device-name "ukbd0";
104133808Spjd	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
105133808Spjd};
106133808Spjddetach 100 {
107133808Spjd	device-name "ukbd0";
108134168Spjd	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
109133808Spjd};
110133808Spjd
111134168Spjd# The entry below starts moused when a mouse is plugged in. Moused
112133808Spjd# stops automatically (actually it bombs :) when the device disappears.
113133808Spjdattach 100 {
114133808Spjd	device-name "ums[0-9]+";
115133960Spjd	action "/etc/rc.d/moused quietstart $device-name";
116133808Spjd};
117133808Spjd
118133808Spjddetach 100 { 
119133808Spjd        device-name "ums[0-9]+"; 
120133808Spjd        action "/etc/rc.d/moused stop $device-name"; 
121133808Spjd}; 
122133808Spjd
123133808Spjd# Firmware download into the ActiveWire board. After the firmware download is
124133808Spjd# done the device detaches and reappears as something new and shiny
125133808Spjd# automatically.
126133808Spjdattach 100 {
127133808Spjd	match "vendor"	"0x0854";
128133808Spjd	match "product"	"0x0100";
129133808Spjd	match "release"	"0x0000";
130133808Spjd	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
131133808Spjd};
132133808Spjd
133133808Spjd# Firmware download for Entrega Serial DB25 adapter.
134133808Spjdattach 100 {
135133808Spjd	match "vendor"	"0x1645";
136133808Spjd	match "product"	"0x8001";
137133808Spjd	match "release"	"0x0101";
138133808Spjd	action "if ! kldstat -n usio > /dev/null 2>&1 ; then kldload usio; fi /usr/sbin/ezdownload -v -f /usr/share/usb/firmware/1645.8001.0101 /dev/$device-name";
139133808Spjd};
140133808Spjd
141133808Spjd# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
142133808Spjd# to date /usr/local/etc/palms. We override the 'listen' settings for port and
143133808Spjd# type in /usr/local/etc/coldsync.conf.
144133808Spjdattach 100 {
145133808Spjd	device-name "ugen[0-9]+";
146133808Spjd	match "vendor" "0x082d";
147133808Spjd	match "product" "0x0100";
148133808Spjd	match "release" "0x0100";
149133808Spjd	action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb";
150134168Spjd};
151134124Spjd
152133808Spjd#
153133808Spjd# Rescan scsi device-names on attach, but not detach.  However, it is
154133808Spjd# disabled by default due to reports of problems.
155133808Spjd#
156133808Spjdattach 0 {
157133808Spjd	device-name "$scsi-controller-regex";
158133808Spjd//	action "camcontrol rescan all";
159133808Spjd};
160133808Spjd
161133808Spjd# Don't even try to second guess what to do about drivers that don't
162133808Spjd# match here.  Instead, pass it off to syslog.  Commented out for the
163133808Spjd# moment, as the pnpinfo variable isn't set in devd yet.  Individual
164133808Spjd# variables within the bus supplied pnpinfo are set.
165133808Spjdnomatch 0 {
166133808Spjd#	action "logger Unknown device: $pnpinfo $location $bus";
167133808Spjd};
168133808Spjd
169133808Spjd# Various logging of unknown devices.
170133808Spjdnomatch 10 {
171133808Spjd	match "bus" "uhub[0-9]+";
172133808Spjd	action "logger Unknown USB device: vendor $vendor product $product \
173133808Spjd		bus $bus";
174133808Spjd};
175133808Spjd
176133808Spjd# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
177133808Spjd# show the CIS info there.
178133808Spjdnomatch 20 {
179133808Spjd	match "bus" "pccard[0-9]+";
180133808Spjd	match "manufacturer" "0xffffffff";
181133808Spjd	match "product" "0xffffffff";
182133808Spjd	action "logger Unknown PCCARD device: CISproduct $cisproduct \
183133808Spjd		CIS-vendor $cisvendor bus $bus";
184133808Spjd};
185133808Spjd
186133808Spjdnomatch 10 {
187133808Spjd	match "bus" "pccard[0-9]+";
188133808Spjd	action "logger Unknown PCCARD device: manufacturer $manufacturer \
189133808Spjd		product $product CISproduct $cisproduct CIS-vendor \
190133808Spjd		$cisvendor bus $bus";
191133808Spjd};
192133808Spjd
193133808Spjdnomatch 10 {
194134124Spjd	match "bus" "cardbus[0-9]+";
195134124Spjd	action "logger Unknown Cardbus device: device $device class $class \
196134124Spjd		vendor $vendor bus $bus";
197134124Spjd};
198134124Spjd
199134124Spjd# Switch power profiles when the AC line state changes.
200134124Spjdnotify 10 {
201134168Spjd	match "system"		"ACPI";
202134168Spjd	match "subsystem"	"ACAD";
203134168Spjd	action "/etc/rc.d/power_profile $notify";
204134168Spjd};
205134168Spjd
206134168Spjd# Notify all users before beginning emergency shutdown when we get
207134168Spjd# a _CRT or _HOT thermal event and we're going to power down the system
208134168Spjd# very soon.
209134168Spjdnotify 10 {
210134168Spjd	match "system"		"ACPI";
211134168Spjd	match "subsystem"	"Thermal";
212133808Spjd	match "notify"		"0xcc";
213133808Spjd	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
214133808Spjd};
215133808Spjd
216133808Spjd# Sample ZFS problem reports handling.
217133808Spjdnotify 10 {
218133808Spjd	match "system"		"ZFS";
219133808Spjd	match "type"		"zpool";
220133808Spjd	action "logger -p kern.err 'ZFS: failed to load zpool $pool'";
221133808Spjd};
222133808Spjd
223133808Spjdnotify 10 {
224133808Spjd	match "system"		"ZFS";
225133808Spjd	match "type"		"vdev";
226133808Spjd	action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'";
227133808Spjd};
228133808Spjd
229133808Spjdnotify 10 {
230133808Spjd	match "system"		"ZFS";
231133808Spjd	match "type"		"data";
232133808Spjd	action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'";
233133808Spjd};
234133808Spjd
235133808Spjdnotify 10 {
236133808Spjd	match "system"		"ZFS";
237133808Spjd	match "type"		"io";
238133808Spjd	action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'";
239133808Spjd};
240133808Spjd
241133808Spjdnotify 10 {
242133808Spjd	match "system"		"ZFS";
243133808Spjd	match "type"		"checksum";
244133808Spjd	action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'";
245133808Spjd};
246133808Spjd
247133808Spjd# User requested suspend, so perform preparation steps and then execute
248133808Spjd# the actual suspend process.
249133808Spjdnotify 10 {
250133808Spjd	match "system"		"ACPI";
251133808Spjd	match "subsystem"	"Suspend";
252133808Spjd	action "/etc/rc.suspend acpi $notify";
253133808Spjd};
254133808Spjdnotify 10 {
255133808Spjd	match "system"		"ACPI";
256133808Spjd	match "subsystem"	"Resume";
257133808Spjd	action "/etc/rc.resume acpi $notify";
258133808Spjd};
259133808Spjd
260133808Spjd/* EXAMPLES TO END OF FILE
261133808Spjd
262133808Spjd# The following might be an example of something that a vendor might
263133808Spjd# install if you were to add their device.  This might reside in
264133808Spjd# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
265133808Spjd# example, a pccard ethernet-like device.  Students of history may
266133808Spjd# know other devices by this name, and will get the in-jokes in this
267133808Spjd# entry.
268133808Spjdnomatch 10 {
269133808Spjd	match "bus" "pccard[0-9]+";
270133808Spjd	match "manufacturer" "0x1234";
271133808Spjd	match "product" "0x2323";
272133808Spjd	action "kldload if_deqna";
273133808Spjd};
274133808Spjdattach 10 {
275133808Spjd	device-name "deqna[0-9]+";
276133808Spjd	action "/etc/pccard_ether $device-name start";
277133808Spjd};
278133808Spjddetach 10 {
279133808Spjd	device-name "deqna[0-9]+";
280133808Spjd	action "/etc/pccard_ether $device-name stop";
281133808Spjd};
282133808Spjd
283133808Spjd# Examples of notify hooks.  A notify is a generic way for a kernel
284133808Spjd# subsystem to send event notification to userland.
285133808Spjd#
286133808Spjd# Here are some examples of ACPI notify handlers.  ACPI subsystems that
287133808Spjd# generate notifies include the AC adapter, power/sleep buttons,
288133808Spjd# control method batteries, lid switch, and thermal zones.
289133808Spjd#
290133808Spjd# Information returned is not always the same as the ACPI notify
291133808Spjd# events.  See the ACPI specification for more information about
292133808Spjd# notifies.  Here is the information returned for each subsystem:
293133808Spjd#
294133808Spjd# ACAD:		AC line state (0 is offline, 1 is online)
295133808Spjd# Button:	Button pressed (0 for power, 1 for sleep)
296133808Spjd# CMBAT:	ACPI battery events
297133808Spjd# Lid:		Lid state (0 is closed, 1 is open)
298133808Spjd# Suspend, Resume: Suspend and resume notification
299133808Spjd# Thermal:	ACPI thermal zone events
300133808Spjd#
301133808Spjd# This example calls a script when the AC state changes, passing the
302133808Spjd# notify value as the first argument.  If the state is 0x00, it might
303133808Spjd# call some sysctls to implement economy mode.  If 0x01, it might set
304133808Spjd# the mode to performance.
305133808Spjdnotify 10 {
306133808Spjd	match "system"		"ACPI";
307133808Spjd	match "subsystem"	"ACAD";
308133808Spjd	action			"/etc/acpi_ac $notify";
309133808Spjd};
310133808Spjd*/
311133808Spjd