devd.conf revision 168497
122347Spst# $FreeBSD: head/etc/devd.conf 168497 2007-04-08 16:05:23Z pjd $
222347Spst#
329967Sache# Refer to devd.conf(5) and devd(8) man pages for the details on how to
492914Smarkm# run and configure devd.
522347Spst#
622347Spst
722347Spst# NB: All regular expressions have an implicit ^$ around them.
822347Spst# NB: device-name is shorthand for 'match device-name'
922347Spst
1022347Spstoptions {
1122347Spst	# Each directory directive adds a directory the list of directories
1222347Spst	# that we scan for files.  Files are read-in in the order that they
1322347Spst	# are returned from readdir(3).  The rule-sets are combined to
1422347Spst	# create a DFA that's used to match events to actions.
1522347Spst	directory "/etc/devd";
1622347Spst	directory "/usr/local/etc/devd";
1792914Smarkm	pid-file "/var/run/devd.pid";
1822347Spst
1922347Spst	# Setup some shorthand for regex that we use later in the file.
2022347Spst	#XXX Yes, these are gross -- imp
2122347Spst	set scsi-controller-regex
2222347Spst		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
2322347Spst		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
2422347Spst		[0-9]+";
2559121Skris};
2622347Spst
2722347Spst# Note that the attach/detach with the highest value wins, so that one can
2822347Spst# override these general rules.
2922347Spst
3022347Spst#
3122347Spst# Configure the interface on attach.  Due to a historical accident, this
3222347Spst# script is called pccard_ether.
3322347Spst#
3422347Spstnotify 0 {
3522347Spst	match "system"		"IFNET";
3622347Spst	match "type"		"ATTACH";
3722347Spst	action "/etc/pccard_ether $subsystem start";
3822347Spst};
3922347Spst
4092914Smarkmnotify 0 {
4122347Spst	match "system"		"IFNET";
4222347Spst	match "type"		"DETACH";
4322347Spst	action "/etc/pccard_ether $subsystem stop";
4422347Spst};
4522347Spst
4622347Spst#
4722347Spst# Try to start dhclient on Ethernet like interfaces when the link comes
4822347Spst# up.  Only devices that are configured to support DHCP will actually
4922347Spst# run it.  No link down rule exists because dhclient automaticly exits
5022347Spst# when the link goes down.
5122347Spst#
5222347Spstnotify 0 {
5322347Spst	match "system"		"IFNET";
5422347Spst	match "type"		"LINK_UP";
5522347Spst	media-type		"ethernet";
5622347Spst	action "/etc/rc.d/dhclient start $subsystem";
5722347Spst};
5822347Spst
5922347Spst#
6022347Spst# Like Ethernet devices, but separate because
6122347Spst# they have a different media type.  We may want
6222347Spst# to exploit this later.
6322347Spst#
6422347Spstdetach 0 {
6522347Spst	media-type "802.11";
6622347Spst	action "/etc/pccard_ether $device-name stop";
6722347Spst};
6822347Spstattach 0 {
6922347Spst	media-type "802.11";
7022347Spst	action "/etc/pccard_ether $device-name start";
7122347Spst};
7222347Spstnotify 0 {
7322347Spst	match "system"		"IFNET";
7422347Spst	match "type"		"LINK_UP";
7522347Spst	media-type		"802.11";
7622347Spst	action "/etc/rc.d/dhclient start $subsystem";
7722347Spst};
7822347Spst
7922347Spst# An entry like this might be in a different file, but is included here
8022347Spst# as an example of how to override things.  Normally 'ed50' would match
8122347Spst# the above attach/detach stuff, but the value of 100 makes it
8222347Spst# hard wired to 1.2.3.4.
8322347Spstattach 100 {
8422347Spst	device-name "ed50";
8522347Spst	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
8622347Spst};
8722347Spstdetach 100 {
8822347Spst	device-name "ed50";
8922347Spst};
9022347Spst
9122347Spst# When a USB Bluetooth dongle appears activate it
9222347Spstattach 100 {
9322347Spst	device-name "ubt[0-9]+";
9422347Spst	action "/etc/rc.d/bluetooth start $device-name";
9522347Spst};
9622347Spstdetach 100 {
9722347Spst	device-name "ubt[0-9]+";
9822347Spst	action "/etc/rc.d/bluetooth stop $device-name";
9922347Spst};
10022347Spst
10122347Spst# When a USB keyboard arrives, attach it as the console keyboard.
10222347Spstattach 100 {
10322347Spst	device-name "ukbd0";
10422347Spst	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
10522347Spst};
10622347Spstdetach 100 {
10722347Spst	device-name "ukbd0";
10822347Spst	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
10922347Spst};
11022347Spst
11122347Spst# The entry below starts moused when a mouse is plugged in. Moused
11222347Spst# stops automatically (actually it bombs :) when the device disappears.
11322347Spstattach 100 {
11422347Spst	device-name "ums[0-9]+";
11522347Spst	action "/etc/rc.d/moused start $device-name";
11622347Spst};
11722347Spst
11822347Spst# Firmware download into the ActiveWire board. After the firmware download is
11922347Spst# done the device detaches and reappears as something new and shiny
12022347Spst# automatically.
12122347Spstattach 100 {
12222347Spst	match "vendor"	"0x0854";
12322347Spst	match "product"	"0x0100";
12422347Spst	match "release"	"0x0000";
12522347Spst	action "/usr/local/bin/ezdownload -f /usr/local/share/usb/firmware/0854.0100.0_01.hex $device-name";
12622347Spst};
12722347Spst
12822347Spst# Firmware download for Entrega Serial DB25 adapter.
12922347Spstattach 100 {
13022347Spst	match "vendor"	"0x1645";
13122347Spst	match "product"	"0x8001";
13222347Spst	match "release"	"0x0101";
13322347Spst	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";
13422347Spst};
13522347Spst
13622347Spst# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
13722347Spst# to date /usr/local/etc/palms. We override the 'listen' settings for port and
13822347Spst# type in /usr/local/etc/coldsync.conf.
13922347Spstattach 100 {
14022347Spst	device-name "ugen[0-9]+";
14122347Spst	match "vendor" "0x082d";
14222347Spst	match "product" "0x0100";
14322347Spst	match "release" "0x0100";
14422347Spst	action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb";
14522347Spst};
14622347Spst
14722347Spst#
14822347Spst# Rescan scsi device-names on attach, but not detach.  However, it is
14922347Spst# disabled by default due to reports of problems.
15022347Spst#
15122347Spstattach 0 {
15222347Spst	device-name "$scsi-controller-regex";
15322347Spst//	action "camcontrol rescan all";
15422347Spst};
15522347Spst
15622347Spst# Don't even try to second guess what to do about drivers that don't
15722372Spst# match here.  Instead, pass it off to syslog.  Commented out for the
15822372Spst# moment, as the pnpinfo variable isn't set in devd yet.  Individual
15922347Spst# variables within the bus supplied pnpinfo are set.
16022347Spstnomatch 0 {
16122347Spst#	action "logger Unknown device: $pnpinfo $location $bus";
16222347Spst};
16322372Spst
16422347Spst# Various logging of unknown devices.
16522347Spstnomatch 10 {
16622347Spst	match "bus" "uhub[0-9]+";
16722347Spst	action "logger Unknown USB device: vendor $vendor product $product \
16822347Spst		bus $bus";
16922347Spst};
17022347Spst
17122347Spst# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
17222347Spst# show the CIS info there.
17322347Spstnomatch 20 {
17422347Spst	match "bus" "pccard[0-9]+";
17522347Spst	match "manufacturer" "0xffffffff";
17622347Spst	match "product" "0xffffffff";
17722347Spst	action "logger Unknown PCCARD device: CISproduct $cisproduct \
17822347Spst		CIS-vendor $cisvendor bus $bus";
179};
180
181nomatch 10 {
182	match "bus" "pccard[0-9]+";
183	action "logger Unknown PCCARD device: manufacturer $manufacturer \
184		product $product CISproduct $cisproduct CIS-vendor \
185		$cisvendor bus $bus";
186};
187
188nomatch 10 {
189	match "bus" "cardbus[0-9]+";
190	action "logger Unknown Cardbus device: device $device class $class \
191		vendor $vendor bus $bus";
192};
193
194# Switch power profiles when the AC line state changes.
195notify 10 {
196	match "system"		"ACPI";
197	match "subsystem"	"ACAD";
198	action "/etc/rc.d/power_profile $notify";
199};
200
201# Notify all users before beginning emergency shutdown when we get
202# a _CRT or _HOT thermal event and we're going to power down the system
203# very soon.
204notify 10 {
205	match "system"		"ACPI";
206	match "subsystem"	"Thermal";
207	match "notify"		"0xcc";
208	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
209};
210
211# Sample ZFS problem reports handling.
212notify 10 {
213	match "system"		"ZFS";
214	match "type"		"zpool";
215	action "logger -p kern.err 'ZFS: failed to load zpool $pool'";
216};
217
218notify 10 {
219	match "system"		"ZFS";
220	match "type"		"vdev";
221	action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'";
222};
223
224notify 10 {
225	match "system"		"ZFS";
226	match "type"		"data";
227	action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'";
228};
229
230notify 10 {
231	match "system"		"ZFS";
232	match "type"		"io";
233	action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'";
234};
235
236notify 10 {
237	match "system"		"ZFS";
238	match "type"		"checksum";
239	action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'";
240};
241
242/* EXAMPLES TO END OF FILE
243
244# The following might be an example of something that a vendor might
245# install if you were to add their device.  This might reside in
246# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
247# example, a pccard ethernet-like device.  Students of history may
248# know other devices by this name, and will get the in-jokes in this
249# entry.
250nomatch 10 {
251	match "bus" "pccard[0-9]+";
252	match "manufacturer" "0x1234";
253	match "product" "0x2323";
254	action "kldload if_deqna";
255};
256attach 10 {
257	device-name "deqna[0-9]+";
258	action "/etc/pccard_ether $device-name start";
259};
260detach 10 {
261	device-name "deqna[0-9]+";
262	action "/etc/pccard_ether $device-name stop";
263};
264
265# Examples of notify hooks.  A notify is a generic way for a kernel
266# subsystem to send event notification to userland.
267#
268# Here are some examples of ACPI notify handlers.  ACPI subsystems that
269# generate notifies include the AC adapter, power/sleep buttons,
270# control method batteries, lid switch, and thermal zones.
271#
272# Information returned is not always the same as the ACPI notify
273# events.  See the ACPI specification for more information about
274# notifies.  Here is the information returned for each subsystem:
275#
276# ACAD:		AC line state (0 is offline, 1 is online)
277# Button:	Button pressed (0 for power, 1 for sleep)
278# CMBAT:	ACPI battery events
279# Lid:		Lid state (0 is closed, 1 is open)
280# Thermal:	ACPI thermal zone events
281#
282# This example calls a script when the AC state changes, passing the
283# notify value as the first argument.  If the state is 0x00, it might
284# call some sysctls to implement economy mode.  If 0x01, it might set
285# the mode to performance.
286notify 10 {
287	match "system"		"ACPI";
288	match "subsystem"	"ACAD";
289	action			"/etc/acpi_ac $notify";
290};
291*/
292