devd.conf revision 261510
12061Sjkh# $FreeBSD: stable/9/etc/devd.conf 261510 2014-02-05 08:42:59Z hselasky $
250479Speter#
32061Sjkh# Refer to devd.conf(5) and devd(8) man pages for the details on how to
438666Sjb# run and configure devd.
532427Sjb#
6111131Sru
7111131Sru# NB: All regular expressions have an implicit ^$ around them.
838666Sjb# NB: device-name is shorthand for 'match device-name'
938666Sjb
1038666Sjboptions {
1138666Sjb	# Each "directory" directive adds a directory to the list of
1264049Salex	# directories that we scan for files.  Files are loaded in the order
1364049Salex	# that they are returned from readdir(3).  The rule-sets are combined
14116679Ssimokawa	# to create a DFA that's used to match events to actions.
1566071Smarkm	directory "/etc/devd";
16116679Ssimokawa	directory "/usr/local/etc/devd";
1773504Sobrien	pid-file "/var/run/devd.pid";
1838666Sjb
1932427Sjb	# Setup some shorthand for regex that we use later in the file.
2038666Sjb	#XXX Yes, these are gross -- imp
21108451Sschweikh	set scsi-controller-regex
2238666Sjb		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
2338666Sjb		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
2438666Sjb		[0-9]+";
2538666Sjb};
2617308Speter
2791606Skeramida# Note that the attach/detach with the highest value wins, so that one can
2819175Sbde# override these general rules.
2996205Sjwd
3096205Sjwd#
3138042Sbde# Configure the interface on attach.  Due to a historical accident, this
3296205Sjwd# script is called pccard_ether.
3396205Sjwd#
3438042Sbde# NB: DETACH events are ignored; the kernel should handle all cleanup
3596205Sjwd#     (routes, arp cache).  Beware of races against immediate create
3696205Sjwd#     of a device with the same name; e.g.
3717308Speter#	ifconfig bridge0 destroy; ifconfig bridge0 create
3896205Sjwd#
3996205Sjwdnotify 0 {
4017308Speter	match "system"		"IFNET";
4196205Sjwd	match "subsystem"	"!usbus[0-9]+";
4296205Sjwd	match "type"		"ATTACH";
4396205Sjwd	action "/etc/pccard_ether $subsystem start";
4496205Sjwd};
4596205Sjwd
4696205Sjwd#
4796205Sjwd# Try to start dhclient on Ethernet-like interfaces when the link comes
4896205Sjwd# up.  Only devices that are configured to support DHCP will actually
4996205Sjwd# run it.  No link down rule exists because dhclient automatically exits
5096205Sjwd# when the link goes down.
5196205Sjwd#
5296205Sjwdnotify 0 {
5398775Sdillon	match "system"		"IFNET";
5498723Sdillon	match "type"		"LINK_UP";
5598723Sdillon	media-type		"ethernet";
5698723Sdillon	action "/etc/rc.d/dhclient quietstart $subsystem";
5798723Sdillon};
5838666Sjb
5938666Sjb#
6017308Speter# Like Ethernet devices, but separate because
61123311Speter# they have a different media type.  We may want
62123311Speter# to exploit this later.
63123311Speter#
64123311Speterdetach 0 {
65142585Sru	media-type "802.11";
66142644Sru	action "/etc/pccard_ether $device-name stop";
67142644Sru};
68116679Ssimokawaattach 0 {
69120760Sru	media-type "802.11";
70128189Sdes	action "/etc/pccard_ether $device-name start";
71127360Sru};
72123311Speternotify 0 {
73137288Speter	match "system"		"IFNET";
74147425Sru	match "type"		"LINK_UP";
752061Sjkh	media-type		"802.11";
7697769Sru	action "/etc/rc.d/dhclient quietstart $subsystem";
7797252Sru};
78119579Sru
7997252Sru# An entry like this might be in a different file, but is included here
8095730Sru# as an example of how to override things.  Normally 'ed50' would match
8195793Sru# the above attach/detach stuff, but the value of 100 makes it
82111617Sru# hard wired to 1.2.3.4.
8395730Sruattach 100 {
84116679Ssimokawa	device-name "ed50";
8595730Sru	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
86116679Ssimokawa};
8795730Srudetach 100 {
88110035Sru	device-name "ed50";
89107516Sru};
90138921Sru
91138921Sru# When a USB Bluetooth dongle appears, activate it
92138921Sruattach 100 {
93133942Sru	device-name "ubt[0-9]+";
94133942Sru	action "/etc/rc.d/bluetooth quietstart $device-name";
95133942Sru};
96133942Srudetach 100 {
97110035Sru	device-name "ubt[0-9]+";
98117234Sru	action "/etc/rc.d/bluetooth quietstop $device-name";
99110035Sru};
100117229Sru
101117234Sru# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
10254324Smarcel#attach 100 {
10317308Speter#	match "vendor" "0x0cf3";
104119519Smarcel#	match "product" "0x3000";
105119519Smarcel#	action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
106119519Smarcel#};
107119519Smarcel
108119519Smarcel# When a USB keyboard arrives, attach it as the console keyboard.
109119519Smarcelattach 100 {
110119579Sru	device-name "ukbd0";
111119519Smarcel	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
112119519Smarcel};
113119519Smarceldetach 100 {
114119519Smarcel	device-name "ukbd0";
115119519Smarcel	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
116126031Sgad};
117126024Sgad
118126024Sgadnotify 100 {
119126024Sgad	match "system" "DEVFS";
120126024Sgad	match "subsystem" "CDEV";
121126024Sgad	match "type" "CREATE";
122126024Sgad	match "cdev" "atp[0-9]+";
123126024Sgad
124126024Sgad	action "/etc/rc.d/moused quietstart $cdev";
125126024Sgad};
126126024Sgad
127126024Sgadnotify 100 {
128126024Sgad	match "system" "DEVFS";
129126024Sgad	match "subsystem" "CDEV";
130126031Sgad	match "type" "CREATE";
131126024Sgad	match "cdev" "ums[0-9]+";
132126024Sgad
133126024Sgad	action "/etc/rc.d/moused quietstart $cdev";
134126024Sgad};
135126024Sgad
136126024Sgadnotify 100 {
137126024Sgad	match "system" "DEVFS";
138133376Sharti	match "subsystem" "CDEV";
139126024Sgad	match "type" "CREATE";
140126024Sgad	match "cdev" "wsp[0-9]+";
141126024Sgad
142126024Sgad	action "/etc/rc.d/moused quietstart $cdev";
143126024Sgad};
144125885Sgad
145125885Sgadnotify 100 {
14638666Sjb	match "system" "DEVFS";
14717308Speter	match "subsystem" "CDEV";
148119519Smarcel	match "type" "DESTROY";
149119579Sru	match "cdev" "ums[0-9]+";
150133376Sharti
151110035Sru	action "/etc/rc.d/moused stop $cdev";
1522302Spaul};
15339206Sjkh
15439206Sjkh# Firmware download into the ActiveWire board. After the firmware download is
15539206Sjkh# done, the device detaches and reappears as something new and shiny
156133945Sru# automatically.
157133945Sruattach 100 {
158132358Smarkm	match "vendor"	"0x0854";
15917308Speter	match "product"	"0x0100";
16054324Smarcel	match "release"	"0x0000";
16154324Smarcel	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
162132234Smarcel};
163132234Smarcel
164132234Smarcel# Firmware download for Entrega Serial DB25 adapter.
165132234Smarcelattach 100 {
16654324Smarcel	match "vendor"	"0x1645";
16754324Smarcel	match "product"	"0x8001";
16854324Smarcel	match "release"	"0x0101";
169118531Sru	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";
17054324Smarcel};
17154324Smarcel
17254324Smarcel# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
17354324Smarcel# to date /usr/local/etc/palms. We override the 'listen' settings for port and
17454324Smarcel# type in /usr/local/etc/coldsync.conf.
17554324Smarcelnotify 100 {
176133376Sharti	match "system"		"USB";
17754324Smarcel	match "subsystem"	"DEVICE";
178133376Sharti	match "type"		"ATTACH";
179133376Sharti	match "vendor"		"0x082d";
18054324Smarcel	match "product"		"0x0100";
18154324Smarcel	match "release"		"0x0100";
18254324Smarcel	action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb";
18354324Smarcel};
18454324Smarcel
185133376Sharti#
18654324Smarcel# Rescan scsi device-names on attach, but not detach.  However, it is
18754324Smarcel# disabled by default due to reports of problems.
18854324Smarcel#
189118531Sruattach 0 {
190118531Sru	device-name "$scsi-controller-regex";
19154324Smarcel//	action "camcontrol rescan all";
192132234Smarcel};
193132234Smarcel
194132234Smarcel# Don't even try to second guess what to do about drivers that don't
195132234Smarcel# match here.  Instead, pass it off to syslog.  Commented out for the
196132234Smarcel# moment, as the pnpinfo variable isn't set in devd yet.  Individual
197132588Skensmith# variables within the bus supplied pnpinfo are set.
198132358Smarkmnomatch 0 {
199132234Smarcel#	action "logger Unknown device: $pnpinfo $location $bus";
200132358Smarkm};
201132358Smarkm
202132358Smarkm# Various logging of unknown devices.
203132358Smarkmnomatch 10 {
204132234Smarcel	match "bus" "uhub[0-9]+";
205132234Smarcel	action "logger Unknown USB device: vendor $vendor product $product \
206132234Smarcel		bus $bus";
20754324Smarcel};
20854324Smarcel
20995730Sru# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
21095730Sru# show the CIS info there.
21195730Srunomatch 20 {
21295730Sru	match "bus" "pccard[0-9]+";
21395730Sru	match "manufacturer" "0xffffffff";
21495730Sru	match "product" "0xffffffff";
21595730Sru	action "logger Unknown PCCARD device: CISproduct $cisproduct \
21638666Sjb		CIS-vendor $cisvendor bus $bus";
217107374Sru};
21817308Speter
21955678Smarcelnomatch 10 {
220143032Sharti	match "bus" "pccard[0-9]+";
221138515Sharti	action "logger Unknown PCCARD device: manufacturer $manufacturer \
222117793Sru		product $product CISproduct $cisproduct CIS-vendor \
223110035Sru		$cisvendor bus $bus";
224110035Sru};
225110035Sru
2262061Sjkhnomatch 10 {
22717308Speter	match "bus" "cardbus[0-9]+";
228107516Sru	action "logger Unknown Cardbus device: device $device class $class \
229107374Sru		vendor $vendor bus $bus";
23055678Smarcel};
231107516Sru
232107516Sru# Switch power profiles when the AC line state changes.
233107516Srunotify 10 {
234107516Sru	match "system"		"ACPI";
235107516Sru	match "subsystem"	"ACAD";
236139112Sru	action "/etc/rc.d/power_profile $notify";
237107516Sru};
238107516Sru
239122204Skris# Notify all users before beginning emergency shutdown when we get
24055678Smarcel# a _CRT or _HOT thermal event and we're going to power down the system
24155678Smarcel# very soon.
242116696Srunotify 10 {
24355678Smarcel	match "system"		"ACPI";
244133376Sharti	match "subsystem"	"Thermal";
245107516Sru	match "notify"		"0xcc";
246107516Sru	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
247107516Sru};
248107516Sru
24955678Smarcel# Sample ZFS problem reports handling.
25055678Smarcelnotify 10 {
251111131Sru	match "system"		"ZFS";
252111131Sru	match "type"		"zpool";
253111131Sru	action "logger -p kern.err 'ZFS: failed to load zpool $pool'";
254133945Sru};
255111131Sru
256111131Srunotify 10 {
257133945Sru	match "system"		"ZFS";
258133945Sru	match "type"		"vdev";
259103985Sphk	action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'";
260103985Sphk};
261103985Sphk
262133945Srunotify 10 {
263133945Sru	match "system"		"ZFS";
264133945Sru	match "type"		"data";
265133945Sru	action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'";
266133945Sru};
267133945Sru
268111131Srunotify 10 {
269131876Sphk	match "system"		"ZFS";
270111131Sru	match "type"		"io";
271111131Sru	action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'";
272111131Sru};
273111131Sru
274111131Srunotify 10 {
275111131Sru	match "system"		"ZFS";
276111133Sru	match "type"		"checksum";
277103985Sphk	action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'";
278133945Sru};
279111131Sru
280103985Sphk# User requested suspend, so perform preparation steps and then execute
281111131Sru# the actual suspend process.
282133945Srunotify 10 {
283133945Sru	match "system"		"ACPI";
284133945Sru	match "subsystem"	"Suspend";
285103985Sphk	action "/etc/rc.suspend acpi $notify";
286118531Sru};
287118531Srunotify 10 {
288103985Sphk	match "system"		"ACPI";
289103985Sphk	match "subsystem"	"Resume";
290126485Sru	action "/etc/rc.resume acpi $notify";
291111131Sru};
292111131Sru
293103985Sphk/* EXAMPLES TO END OF FILE
294111131Sru
295131876Sphk# An example of something that a vendor might install if you were to
296111131Sru# add their device.  This might reside in /usr/local/etc/devd/deqna.conf.
297111131Sru# A deqna is, in this hypothetical example, a pccard ethernet-like device.
298111131Sru# Students of history may know other devices by this name, and will get
299103985Sphk# the in-jokes in this entry.
300133945Srunomatch 10 {
301	match "bus" "pccard[0-9]+";
302	match "manufacturer" "0x1234";
303	match "product" "0x2323";
304	action "kldload if_deqna";
305};
306attach 10 {
307	device-name "deqna[0-9]+";
308	action "/etc/pccard_ether $device-name start";
309};
310detach 10 {
311	device-name "deqna[0-9]+";
312	action "/etc/pccard_ether $device-name stop";
313};
314
315# Examples of notify hooks.  A notify is a generic way for a kernel
316# subsystem to send event notification to userland.
317
318# Here are some examples of ACPI notify handlers.  ACPI subsystems that
319# generate notifies include the AC adapter, power/sleep buttons,
320# control method batteries, lid switch, and thermal zones.
321#
322# Information returned is not always the same as the ACPI notify
323# events.  See the ACPI specification for more information about
324# notifies.  Here is the information returned for each subsystem:
325#
326# ACAD:		AC line state (0 is offline, 1 is online)
327# Button:	Button pressed (0 for power, 1 for sleep)
328# CMBAT:	ACPI battery events
329# Lid:		Lid state (0 is closed, 1 is open)
330# RCTL:		Resource limits
331# Suspend, Resume: Suspend and resume notification
332# Thermal:	ACPI thermal zone events
333#
334# This example calls a script when the AC state changes, passing the
335# notify value as the first argument.  If the state is 0x00, it might
336# call some sysctls to implement economy mode.  If 0x01, it might set
337# the mode to performance.
338notify 10 {
339	match "system"		"ACPI";
340	match "subsystem"	"ACAD";
341	action			"/etc/acpi_ac $notify";
342};
343
344# This example works around a memory leak in PostgreSQL, restarting
345# it when the "user:pgsql:swap:devctl=1G" rctl(8) rule gets triggered.
346notify 0 {
347	match "system"		"RCTL";
348	match "rule"		"user:70:swap:.*";
349	action			"/usr/local/etc/rc.d/postgresql restart"
350};
351
352*/
353