devd.conf revision 192198
1108983Simp# $FreeBSD: head/etc/devd.conf 192198 2009-05-16 15:12:56Z maxim $
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.
20148471Simp	#XXX Yes, these are gross -- imp
21108983Simp	set scsi-controller-regex
22139027Sbrueffer		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
23146969Smarius		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
24139027Sbrueffer		[0-9]+";
25108983Simp};
26108983Simp
27108983Simp# Note that the attach/detach with the highest value wins, so that one can
28108983Simp# override these general rules.
29108983Simp
30108983Simp#
31159126Sthompsa# Configure the interface on attach.  Due to a historical accident, this
32159126Sthompsa# script is called pccard_ether.
33108983Simp#
34187743Ssam# NB: DETACH events are ignored; the kernel should handle all cleanup
35187743Ssam#     (routes, arp cache) if you need to do something beware of races
36187743Ssam#     against immediate create of a device w/ the same name; e.g.
37187743Ssam#	ifconfig bridge0 destroy; ifconfig bridge0 create
38187743Ssam#
39159126Sthompsanotify 0 {
40159126Sthompsa	match "system"		"IFNET";
41159126Sthompsa	match "type"		"ATTACH";
42159126Sthompsa	action "/etc/pccard_ether $subsystem start";
43108983Simp};
44108983Simp
45147088Sbrooks#
46147088Sbrooks# Try to start dhclient on Ethernet like interfaces when the link comes
47147088Sbrooks# up.  Only devices that are configured to support DHCP will actually
48147088Sbrooks# run it.  No link down rule exists because dhclient automaticly exits
49147088Sbrooks# when the link goes down.
50147088Sbrooks#
51147088Sbrooksnotify 0 {
52147088Sbrooks	match "system"		"IFNET";
53147088Sbrooks	match "type"		"LINK_UP";
54148642Ssam	media-type		"ethernet";
55175683Smtm	action "/etc/rc.d/dhclient quietstart $subsystem";
56147088Sbrooks};
57147088Sbrooks
58148642Ssam#
59148642Ssam# Like Ethernet devices, but separate because
60148642Ssam# they have a different media type.  We may want
61148642Ssam# to exploit this later.
62148642Ssam#
63148642Ssamdetach 0 {
64148642Ssam	media-type "802.11";
65148642Ssam	action "/etc/pccard_ether $device-name stop";
66148642Ssam};
67148642Ssamattach 0 {
68148642Ssam	media-type "802.11";
69148642Ssam	action "/etc/pccard_ether $device-name start";
70148642Ssam};
71148642Ssamnotify 0 {
72148642Ssam	match "system"		"IFNET";
73148642Ssam	match "type"		"LINK_UP";
74148642Ssam	media-type		"802.11";
75175683Smtm	action "/etc/rc.d/dhclient quietstart $subsystem";
76148642Ssam};
77148642Ssam
78108983Simp# An entry like this might be in a different file, but is included here
79108983Simp# as an example of how to override things.  Normally 'ed50' would match
80108983Simp# the above attach/detach stuff, but the value of 100 makes it
81139281Sbrueffer# hard wired to 1.2.3.4.
82108983Simpattach 100 {
83108983Simp	device-name "ed50";
84108983Simp	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
85108983Simp};
86108983Simpdetach 100 {
87108983Simp	device-name "ed50";
88108983Simp};
89108983Simp
90152326Semax# When a USB Bluetooth dongle appears activate it
91152326Semaxattach 100 {
92152326Semax	device-name "ubt[0-9]+";
93175683Smtm	action "/etc/rc.d/bluetooth quietstart $device-name";
94152326Semax};
95152326Semaxdetach 100 {
96152326Semax	device-name "ubt[0-9]+";
97175683Smtm	action "/etc/rc.d/bluetooth quietstop $device-name";
98152326Semax};
99152326Semax
100139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard.
101134584Sbrooksattach 100 {
102134584Sbrooks	device-name "ukbd0";
103156782Semax	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
104134584Sbrooks};
105134584Sbrooksdetach 100 {
106134584Sbrooks	device-name "ukbd0";
107156331Semax	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
108134584Sbrooks};
109134584Sbrooks
110138175Siedowseattach 100 {
111138175Siedowse	device-name "ums[0-9]+";
112175683Smtm	action "/etc/rc.d/moused quietstart $device-name";
113138175Siedowse};
114138175Siedowse
115179804Skmacydetach 100 { 
116179804Skmacy        device-name "ums[0-9]+"; 
117179804Skmacy        action "/etc/rc.d/moused stop $device-name"; 
118179804Skmacy}; 
119179804Skmacy
120153300Siedowse# Firmware download into the ActiveWire board. After the firmware download is
121153300Siedowse# done the device detaches and reappears as something new and shiny
122153300Siedowse# automatically.
123153300Siedowseattach 100 {
124153300Siedowse	match "vendor"	"0x0854";
125153300Siedowse	match "product"	"0x0100";
126153300Siedowse	match "release"	"0x0000";
127153300Siedowse	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
128153300Siedowse};
129153300Siedowse
130153300Siedowse# Firmware download for Entrega Serial DB25 adapter.
131153300Siedowseattach 100 {
132153300Siedowse	match "vendor"	"0x1645";
133153300Siedowse	match "product"	"0x8001";
134153300Siedowse	match "release"	"0x0101";
135192198Smaxim	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";
136153300Siedowse};
137153300Siedowse
138153300Siedowse# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
139153300Siedowse# to date /usr/local/etc/palms. We override the 'listen' settings for port and
140153300Siedowse# type in /usr/local/etc/coldsync.conf.
141153300Siedowseattach 100 {
142153300Siedowse	device-name "ugen[0-9]+";
143153300Siedowse	match "vendor" "0x082d";
144153300Siedowse	match "product" "0x0100";
145153300Siedowse	match "release" "0x0100";
146153300Siedowse	action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb";
147153300Siedowse};
148153300Siedowse
149108983Simp#
150148471Simp# Rescan scsi device-names on attach, but not detach.  However, it is
151148471Simp# disabled by default due to reports of problems.
152108983Simp#
153108983Simpattach 0 {
154108983Simp	device-name "$scsi-controller-regex";
155131646Simp//	action "camcontrol rescan all";
156108983Simp};
157108983Simp
158108983Simp# Don't even try to second guess what to do about drivers that don't
159114799Simp# match here.  Instead, pass it off to syslog.  Commented out for the
160166754Simp# moment, as the pnpinfo variable isn't set in devd yet.  Individual
161166754Simp# variables within the bus supplied pnpinfo are set.
162119254Simpnomatch 0 {
163114852Simp#	action "logger Unknown device: $pnpinfo $location $bus";
164119254Simp};
165108983Simp
166166701Sjoerg# Various logging of unknown devices.
167166701Sjoergnomatch 10 {
168166701Sjoerg	match "bus" "uhub[0-9]+";
169166701Sjoerg	action "logger Unknown USB device: vendor $vendor product $product \
170166701Sjoerg		bus $bus";
171166701Sjoerg};
172166701Sjoerg
173166701Sjoerg# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
174166701Sjoerg# show the CIS info there.
175166701Sjoergnomatch 20 {
176166701Sjoerg	match "bus" "pccard[0-9]+";
177166701Sjoerg	match "manufacturer" "0xffffffff";
178166701Sjoerg	match "product" "0xffffffff";
179166701Sjoerg	action "logger Unknown PCCARD device: CISproduct $cisproduct \
180166701Sjoerg		CIS-vendor $cisvendor bus $bus";
181166701Sjoerg};
182166701Sjoerg
183166701Sjoergnomatch 10 {
184166701Sjoerg	match "bus" "pccard[0-9]+";
185166701Sjoerg	action "logger Unknown PCCARD device: manufacturer $manufacturer \
186166701Sjoerg		product $product CISproduct $cisproduct CIS-vendor \
187166701Sjoerg		$cisvendor bus $bus";
188166701Sjoerg};
189166701Sjoerg
190166701Sjoergnomatch 10 {
191166701Sjoerg	match "bus" "cardbus[0-9]+";
192166701Sjoerg	action "logger Unknown Cardbus device: device $device class $class \
193166701Sjoerg		vendor $vendor bus $bus";
194166701Sjoerg};
195166701Sjoerg
196139281Sbrueffer# Switch power profiles when the AC line state changes.
197123626Snjlnotify 10 {
198123626Snjl	match "system"		"ACPI";
199123626Snjl	match "subsystem"	"ACAD";
200125366Snjl	action "/etc/rc.d/power_profile $notify";
201123626Snjl};
202123626Snjl
203125366Snjl# Notify all users before beginning emergency shutdown when we get
204125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system
205125366Snjl# very soon.
206125366Snjlnotify 10 {
207125366Snjl	match "system"		"ACPI";
208125366Snjl	match "subsystem"	"Thermal";
209125366Snjl	match "notify"		"0xcc";
210125366Snjl	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
211125366Snjl};
212125366Snjl
213168495Spjd# Sample ZFS problem reports handling.
214168495Spjdnotify 10 {
215168495Spjd	match "system"		"ZFS";
216168495Spjd	match "type"		"zpool";
217168495Spjd	action "logger -p kern.err 'ZFS: failed to load zpool $pool'";
218168495Spjd};
219168495Spjd
220168495Spjdnotify 10 {
221168495Spjd	match "system"		"ZFS";
222168495Spjd	match "type"		"vdev";
223168497Spjd	action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'";
224168495Spjd};
225168495Spjd
226168495Spjdnotify 10 {
227168495Spjd	match "system"		"ZFS";
228168495Spjd	match "type"		"data";
229168495Spjd	action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'";
230168495Spjd};
231168495Spjd
232168495Spjdnotify 10 {
233168495Spjd	match "system"		"ZFS";
234168495Spjd	match "type"		"io";
235168495Spjd	action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'";
236168495Spjd};
237168495Spjd
238168495Spjdnotify 10 {
239168495Spjd	match "system"		"ZFS";
240168495Spjd	match "type"		"checksum";
241168495Spjd	action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'";
242168495Spjd};
243168495Spjd
244170976Snjl# User requested suspend, so perform preparation steps and then execute
245170976Snjl# the actual suspend process.
246170976Snjlnotify 10 {
247170976Snjl	match "system"		"ACPI";
248170976Snjl	match "subsystem"	"Suspend";
249170976Snjl	action "/etc/rc.suspend acpi $notify";
250170976Snjl};
251170976Snjlnotify 10 {
252170976Snjl	match "system"		"ACPI";
253170976Snjl	match "subsystem"	"Resume";
254170976Snjl	action "/etc/rc.resume acpi $notify";
255170976Snjl};
256170976Snjl
257108983Simp/* EXAMPLES TO END OF FILE
258108983Simp
259108983Simp# The following might be an example of something that a vendor might
260108983Simp# install if you were to add their device.  This might reside in
261108983Simp# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
262108983Simp# example, a pccard ethernet-like device.  Students of history may
263108983Simp# know other devices by this name, and will get the in-jokes in this
264108983Simp# entry.
265108983Simpnomatch 10 {
266108983Simp	match "bus" "pccard[0-9]+";
267108983Simp	match "manufacturer" "0x1234";
268108983Simp	match "product" "0x2323";
269108983Simp	action "kldload if_deqna";
270108983Simp};
271108983Simpattach 10 {
272108983Simp	device-name "deqna[0-9]+";
273108983Simp	action "/etc/pccard_ether $device-name start";
274108983Simp};
275108983Simpdetach 10 {
276108983Simp	device-name "deqna[0-9]+";
277108983Simp	action "/etc/pccard_ether $device-name stop";
278108983Simp};
279108983Simp
280121493Snjl# Examples of notify hooks.  A notify is a generic way for a kernel
281121493Snjl# subsystem to send event notification to userland.
282121493Snjl#
283121493Snjl# Here are some examples of ACPI notify handlers.  ACPI subsystems that
284121493Snjl# generate notifies include the AC adapter, power/sleep buttons,
285121493Snjl# control method batteries, lid switch, and thermal zones.
286121493Snjl#
287121493Snjl# Information returned is not always the same as the ACPI notify
288121493Snjl# events.  See the ACPI specification for more information about
289121493Snjl# notifies.  Here is the information returned for each subsystem:
290121493Snjl#
291121493Snjl# ACAD:		AC line state (0 is offline, 1 is online)
292121493Snjl# Button:	Button pressed (0 for power, 1 for sleep)
293121493Snjl# CMBAT:	ACPI battery events
294121493Snjl# Lid:		Lid state (0 is closed, 1 is open)
295170976Snjl# Suspend, Resume: Suspend and resume notification
296121493Snjl# Thermal:	ACPI thermal zone events
297121493Snjl#
298121493Snjl# This example calls a script when the AC state changes, passing the
299121493Snjl# notify value as the first argument.  If the state is 0x00, it might
300121493Snjl# call some sysctls to implement economy mode.  If 0x01, it might set
301121493Snjl# the mode to performance.
302121493Snjlnotify 10 {
303121493Snjl	match "system"		"ACPI";
304121493Snjl	match "subsystem"	"ACAD";
305121493Snjl	action			"/etc/acpi_ac $notify";
306121493Snjl};
307108983Simp*/
308