xref: /freebsd/sbin/devd/devd.conf (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
1# $FreeBSD$
2#
3# Refer to devd.conf(5) and devd(8) man pages for the details on how to
4# run and configure devd.
5#
6
7# NB: All regular expressions have an implicit ^$ around them.
8# NB: device-name is shorthand for 'match device-name'
9
10options {
11	# Each "directory" directive adds a directory to the list of
12	# directories that we scan for files.  Files are loaded in the order
13	# that they are returned from readdir(3).  The rule-sets are combined
14	# to create a DFA that's used to match events to actions.
15	directory "/etc/devd";
16	directory "/usr/local/etc/devd";
17	pid-file "/var/run/devd.pid";
18
19	# Setup some shorthand for regex that we use later in the file.
20	#XXX Yes, this is gross -- imp
21	set wifi-driver-regex
22		"(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|otus|\
23		ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+";
24};
25
26# Note that the attach/detach with the highest value wins, so that one can
27# override these general rules.
28
29#
30# Configure the interface on attach.  Due to a historical accident, this
31# script is called pccard_ether. We omit the usbus devices because those
32# devices are associated with the USB Bus and provide an ifnet device to
33# allow usb traffic to be captured with usbdump(8).
34#
35# NB: DETACH events are ignored; the kernel should handle all cleanup
36#     (routes, arp cache).  Beware of races against immediate create
37#     of a device with the same name; e.g.
38#     ifconfig bridge0 destroy; ifconfig bridge0 create
39#
40notify 0 {
41	match "system"		"IFNET";
42	match "subsystem"	"!(usbus|wlan)[0-9]+";
43	match "type"		"ATTACH";
44	action "/etc/pccard_ether $subsystem start";
45};
46
47#
48# Like Ethernet devices, but separate because 802.11 require spawning
49# wlan(4) interface.
50#
51attach 0 {
52	device-name "$wifi-driver-regex";
53	action "/etc/pccard_ether $device-name startchildren";
54};
55detach 0 {
56	device-name "$wifi-driver-regex";
57	action "/etc/pccard_ether $device-name stopchildren";
58};
59
60# An entry like this might be in a different file, but is included here
61# as an example of how to override things.  Normally 'ed50' would match
62# the above attach/detach stuff, but the value of 100 makes it
63# hard wired to 1.2.3.4.
64attach 100 {
65	device-name "ed50";
66	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
67};
68detach 100 {
69	device-name "ed50";
70};
71
72# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
73#attach 100 {
74#	match "vendor" "0x0cf3";
75#	match "product" "0x3000";
76#	action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
77#};
78
79# Don't even try to second guess what to do about drivers that don't
80# match here.  Instead, pass it off to syslog.  Commented out for the
81# moment, as the pnpinfo variable isn't set in devd yet.  Individual
82# variables within the bus supplied pnpinfo are set.
83nomatch 0 {
84#	action "logger Unknown device: $pnpinfo $location $bus";
85};
86
87# Various logging of unknown devices.
88nomatch 10 {
89	match "bus" "uhub[0-9]+";
90	action "logger Unknown USB device: vendor $vendor product $product \
91		bus $bus";
92};
93
94# Some Cardbus cards don't offer numerical manufacturer/product IDs, just
95# show the CIS info there.
96nomatch 10 {
97	match "bus" "cardbus[0-9]+";
98	action "logger Unknown Cardbus device: device $device class $class \
99		vendor $vendor bus $bus";
100};
101
102# Notify all users before beginning emergency shutdown when we get
103# a _CRT or _HOT thermal event and we're going to power down the system
104# very soon.
105notify 10 {
106	match "system"		"ACPI";
107	match "subsystem"	"Thermal";
108	match "notify"		"0xcc";
109	action "logger -p kern.emerg WARNING: system temperature too high, shutting down soon!";
110};
111
112# User requested suspend, so perform preparation steps and then execute
113# the actual suspend process.
114notify 10 {
115	match "system"		"ACPI";
116	match "subsystem"	"Suspend";
117	action "/etc/rc.suspend acpi $notify";
118};
119notify 10 {
120	match "system"		"ACPI";
121	match "subsystem"	"Resume";
122	action "/etc/rc.resume acpi $notify";
123};
124
125/* EXAMPLES TO END OF FILE
126
127# Examples of notify hooks.  A notify is a generic way for a kernel
128# subsystem to send event notification to userland.
129
130# Here are some examples of ACPI notify handlers.  ACPI subsystems that
131# generate notifies include the AC adapter, power/sleep buttons,
132# control method batteries, lid switch, and thermal zones.
133#
134# Information returned is not always the same as the ACPI notify
135# events.  See the ACPI specification for more information about
136# notifies.  Here is the information returned for each subsystem:
137#
138# ACAD:            AC line state (0 is offline, 1 is online)
139# Button:          Button pressed (0 for power, 1 for sleep)
140# CMBAT:           ACPI battery events
141# Lid:             Lid state (0 is closed, 1 is open)
142# Suspend, Resume: Suspend and resume notification
143# Thermal:         ACPI thermal zone events
144#
145# This example calls a script when the AC state changes, passing the
146# notify value as the first argument.  If the state is 0x00, it might
147# call some sysctls to implement economy mode.  If 0x01, it might set
148# the mode to performance.
149notify 10 {
150	match "system"		"ACPI";
151	match "subsystem"	"ACAD";
152	action			"/etc/acpi_ac $notify";
153};
154
155# This example works around a memory leak in PostgreSQL, restarting
156# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered.
157notify 0 {
158	match "system"		"RCTL";
159	match "rule"		"user:770:swap:.*";
160	action			"service postgresql restart";
161};
162
163# Discard autofs caches, useful for the -media special map.
164notify 100 {
165	match "system" "GEOM";
166	match "subsystem" "DEV";
167	action "/usr/sbin/automount -c";
168};
169
170# Handle userland coredumps.
171# This commented out handler makes it possible to run an
172# automated debugging session after the core dump is generated.
173# Replace action with a proper coredump handler, but be aware that
174# it will run with elevated privileges.
175notify 10 {
176	match "system"          "kernel";
177	match "subsystem"       "signal";
178	match "type"            "coredump";
179	action "logger $comm $core";
180};
181
182# Let the init(8) know there's a new USB serial interface it might
183# want to run getty(8) for.  This includes device-side tty created
184# by usb_template(4).
185notify 100 {
186	match "system"		"DEVFS";
187	match "subsystem"	"CDEV";
188	match "type"		"CREATE";
189	match "cdev"		"ttyU[0-9]+";
190	action "/sbin/init q";
191};
192
193*/
194