xref: /freebsd/sbin/devd/devd.conf (revision 29fc4075e69fd27de0cded313ac6000165d99f8b)
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|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|\
23		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# Try to start dhclient on Ethernet-like interfaces when the link comes
49# up.  Only devices that are configured to support DHCP will actually
50# run it.  No link down rule exists because dhclient automatically exits
51# when the link goes down.
52#
53notify 0 {
54	match "system"		"IFNET";
55	match "type"		"LINK_UP";
56	media-type		"ethernet";
57	action "service dhclient quietstart $subsystem";
58};
59
60#
61# Like Ethernet devices, but separate because 802.11 require spawning
62# wlan(4) interface.
63#
64attach 0 {
65	device-name "$wifi-driver-regex";
66	action "/etc/pccard_ether $device-name startchildren";
67};
68detach 0 {
69	device-name "$wifi-driver-regex";
70	action "/etc/pccard_ether $device-name stopchildren";
71};
72notify 0 {
73	match "system"		"IFNET";
74	match "type"		"LINK_UP";
75	media-type		"802.11";
76	action "service dhclient quietstart $subsystem";
77};
78
79# An entry like this might be in a different file, but is included here
80# as an example of how to override things.  Normally 'ed50' would match
81# the above attach/detach stuff, but the value of 100 makes it
82# hard wired to 1.2.3.4.
83attach 100 {
84	device-name "ed50";
85	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
86};
87detach 100 {
88	device-name "ed50";
89};
90
91# When a USB Bluetooth dongle appears, activate it
92attach 100 {
93	device-name "ubt[0-9]+";
94	action "service bluetooth quietstart $device-name";
95};
96detach 100 {
97	device-name "ubt[0-9]+";
98	action "service bluetooth quietstop $device-name";
99};
100
101# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
102#attach 100 {
103#	match "vendor" "0x0cf3";
104#	match "product" "0x3000";
105#	action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
106#};
107
108# When a USB keyboard arrives, attach it as the console keyboard.
109attach 100 {
110	device-name "ukbd0";
111	action "service syscons setkeyboard /dev/ukbd0";
112};
113detach 100 {
114	device-name "ukbd0";
115	action "service syscons setkeyboard /dev/kbd0";
116};
117
118notify 100 {
119	match "system" "DEVFS";
120	match "subsystem" "CDEV";
121	match "type" "CREATE";
122	match "cdev" "atp[0-9]+";
123
124	action "service moused quietstart $cdev";
125};
126
127notify 100 {
128	match "system" "DEVFS";
129	match "subsystem" "CDEV";
130	match "type" "CREATE";
131	match "cdev" "ums[0-9]+";
132
133	action "service moused quietstart $cdev";
134};
135
136notify 100 {
137	match "system" "DEVFS";
138	match "subsystem" "CDEV";
139	match "type" "CREATE";
140	match "cdev" "wsp[0-9]+";
141
142	action "service moused quietstart $cdev";
143};
144
145notify 100 {
146	match "system" "DEVFS";
147	match "subsystem" "CDEV";
148	match "type" "DESTROY";
149	match "cdev" "ums[0-9]+";
150
151	action "service moused stop $cdev";
152};
153
154# Don't even try to second guess what to do about drivers that don't
155# match here.  Instead, pass it off to syslog.  Commented out for the
156# moment, as the pnpinfo variable isn't set in devd yet.  Individual
157# variables within the bus supplied pnpinfo are set.
158nomatch 0 {
159#	action "logger Unknown device: $pnpinfo $location $bus";
160};
161
162# Various logging of unknown devices.
163nomatch 10 {
164	match "bus" "uhub[0-9]+";
165	action "logger Unknown USB device: vendor $vendor product $product \
166		bus $bus";
167};
168
169# Some Cardbus cards don't offer numerical manufacturer/product IDs, just
170# show the CIS info there.
171nomatch 10 {
172	match "bus" "cardbus[0-9]+";
173	action "logger Unknown Cardbus device: device $device class $class \
174		vendor $vendor bus $bus";
175};
176
177# Switch power profiles when the AC line state changes.
178notify 10 {
179	match "system"		"ACPI";
180	match "subsystem"	"ACAD";
181	action "service power_profile $notify";
182};
183
184# Notify all users before beginning emergency shutdown when we get
185# a _CRT or _HOT thermal event and we're going to power down the system
186# very soon.
187notify 10 {
188	match "system"		"ACPI";
189	match "subsystem"	"Thermal";
190	match "notify"		"0xcc";
191	action "logger -p kern.emerg WARNING: system temperature too high, shutting down soon!";
192};
193
194# User requested suspend, so perform preparation steps and then execute
195# the actual suspend process.
196notify 10 {
197	match "system"		"ACPI";
198	match "subsystem"	"Suspend";
199	action "/etc/rc.suspend acpi $notify";
200};
201notify 10 {
202	match "system"		"ACPI";
203	match "subsystem"	"Resume";
204	action "/etc/rc.resume acpi $notify";
205};
206
207/* EXAMPLES TO END OF FILE
208
209# Examples of notify hooks.  A notify is a generic way for a kernel
210# subsystem to send event notification to userland.
211
212# Here are some examples of ACPI notify handlers.  ACPI subsystems that
213# generate notifies include the AC adapter, power/sleep buttons,
214# control method batteries, lid switch, and thermal zones.
215#
216# Information returned is not always the same as the ACPI notify
217# events.  See the ACPI specification for more information about
218# notifies.  Here is the information returned for each subsystem:
219#
220# ACAD:            AC line state (0 is offline, 1 is online)
221# Button:          Button pressed (0 for power, 1 for sleep)
222# CMBAT:           ACPI battery events
223# Lid:             Lid state (0 is closed, 1 is open)
224# Suspend, Resume: Suspend and resume notification
225# Thermal:         ACPI thermal zone events
226#
227# This example calls a script when the AC state changes, passing the
228# notify value as the first argument.  If the state is 0x00, it might
229# call some sysctls to implement economy mode.  If 0x01, it might set
230# the mode to performance.
231notify 10 {
232	match "system"		"ACPI";
233	match "subsystem"	"ACAD";
234	action			"/etc/acpi_ac $notify";
235};
236
237# This example works around a memory leak in PostgreSQL, restarting
238# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered.
239notify 0 {
240	match "system"		"RCTL";
241	match "rule"		"user:770:swap:.*";
242	action			"service postgresql restart";
243};
244
245# Discard autofs caches, useful for the -media special map.
246notify 100 {
247	match "system" "GEOM";
248	match "subsystem" "DEV";
249	action "/usr/sbin/automount -c";
250};
251
252# Handle userland coredumps.
253# This commented out handler makes it possible to run an
254# automated debugging session after the core dump is generated.
255# Replace action with a proper coredump handler, but be aware that
256# it will run with elevated privileges.
257notify 10 {
258	match "system"          "kernel";
259	match "subsystem"       "signal";
260	match "type"            "coredump";
261	action "logger $comm $core";
262};
263
264# Let the init(8) know there's a new USB serial interface it might
265# want to run getty(8) for.  This includes device-side tty created
266# by usb_template(4).
267notify 100 {
268	match "system"		"DEVFS";
269	match "subsystem"	"CDEV";
270	match "type"		"CREATE";
271	match "cdev"		"ttyU[0-9]+";
272	action "/sbin/init q";
273};
274
275*/
276