1# $FreeBSD: stable/11/etc/devd.conf 363729 2020-07-31 11:14:11Z 0mp $
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, these are gross -- imp
21	set scsi-controller-regex
22		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
23		esp|ida|iir|ips|isp|mlx|mly|mpr|mps|mpt|ncr|ncv|nsp|stg|sym|\
24		trm|wds)[0-9]+";
25	set wifi-driver-regex
26		"(ath|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rum|run|\
27		uath|upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+";
28};
29
30# Note that the attach/detach with the highest value wins, so that one can
31# override these general rules.
32
33#
34# Configure the interface on attach.  Due to a historical accident, this
35# script is called pccard_ether.
36#
37# NB: DETACH events are ignored; the kernel should handle all cleanup
38#     (routes, arp cache).  Beware of races against immediate create
39#     of a device with the same name; e.g.
40#     ifconfig bridge0 destroy; ifconfig bridge0 create
41#
42notify 0 {
43	match "system"		"IFNET";
44	match "subsystem"	"!(usbus|wlan)[0-9]+";
45	match "type"		"ATTACH";
46	action "/etc/pccard_ether $subsystem start";
47};
48
49#
50# Try to start dhclient on Ethernet-like interfaces when the link comes
51# up.  Only devices that are configured to support DHCP will actually
52# run it.  No link down rule exists because dhclient automatically exits
53# when the link goes down.
54#
55notify 0 {
56	match "system"		"IFNET";
57	match "type"		"LINK_UP";
58	media-type		"ethernet";
59	action "/etc/rc.d/dhclient quietstart $subsystem";
60};
61
62#
63# Like Ethernet devices, but separate because 802.11 require spawning
64# wlan(4) interface.
65#
66attach 0 {
67	device-name "$wifi-driver-regex";
68	action "/etc/pccard_ether $device-name startchildren";
69};
70detach 0 {
71	device-name "$wifi-driver-regex";
72	action "/etc/pccard_ether $device-name stopchildren";
73};
74notify 0 {
75	match "system"		"IFNET";
76	match "type"		"LINK_UP";
77	media-type		"802.11";
78	action "/etc/rc.d/dhclient quietstart $subsystem";
79};
80
81# An entry like this might be in a different file, but is included here
82# as an example of how to override things.  Normally 'ed50' would match
83# the above attach/detach stuff, but the value of 100 makes it
84# hard wired to 1.2.3.4.
85attach 100 {
86	device-name "ed50";
87	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
88};
89detach 100 {
90	device-name "ed50";
91};
92
93# When a USB Bluetooth dongle appears, activate it
94attach 100 {
95	device-name "ubt[0-9]+";
96	action "/etc/rc.d/bluetooth quietstart $device-name";
97};
98detach 100 {
99	device-name "ubt[0-9]+";
100	action "/etc/rc.d/bluetooth quietstop $device-name";
101};
102
103# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
104#attach 100 {
105#	match "vendor" "0x0cf3";
106#	match "product" "0x3000";
107#	action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
108#};
109
110# When a USB keyboard arrives, attach it as the console keyboard.
111attach 100 {
112	device-name "ukbd0";
113	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
114};
115detach 100 {
116	device-name "ukbd0";
117	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
118};
119
120notify 100 {
121	match "system" "DEVFS";
122	match "subsystem" "CDEV";
123	match "type" "CREATE";
124	match "cdev" "atp[0-9]+";
125
126	action "/etc/rc.d/moused quietstart $cdev";
127};
128
129notify 100 {
130	match "system" "DEVFS";
131	match "subsystem" "CDEV";
132	match "type" "CREATE";
133	match "cdev" "ums[0-9]+";
134
135	action "/etc/rc.d/moused quietstart $cdev";
136};
137
138notify 100 {
139	match "system" "DEVFS";
140	match "subsystem" "CDEV";
141	match "type" "CREATE";
142	match "cdev" "wsp[0-9]+";
143
144	action "/etc/rc.d/moused quietstart $cdev";
145};
146
147notify 100 {
148	match "system" "DEVFS";
149	match "subsystem" "CDEV";
150	match "type" "DESTROY";
151	match "cdev" "ums[0-9]+";
152
153	action "/etc/rc.d/moused stop $cdev";
154};
155
156# This entry starts the ColdSync tool in daemon mode. Make sure you have an up
157# to date /usr/local/etc/palms. We override the 'listen' settings for port and
158# type in /usr/local/etc/coldsync.conf.
159notify 100 {
160	match "system"		"USB";
161	match "subsystem"	"DEVICE";
162	match "type"		"ATTACH";
163	match "vendor"		"0x082d";
164	match "product"		"0x0100";
165	match "release"		"0x0100";
166	action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb";
167};
168
169#
170# Rescan SCSI device-names on attach, but not detach.  However, it is
171# disabled by default due to reports of problems.
172#
173attach 0 {
174	device-name "$scsi-controller-regex";
175//	action "camcontrol rescan all";
176};
177
178# Don't even try to second guess what to do about drivers that don't
179# match here.  Instead, pass it off to syslog.  Commented out for the
180# moment, as the pnpinfo variable isn't set in devd yet.  Individual
181# variables within the bus supplied pnpinfo are set.
182nomatch 0 {
183#	action "logger Unknown device: $pnpinfo $location $bus";
184};
185
186# Various logging of unknown devices.
187nomatch 10 {
188	match "bus" "uhub[0-9]+";
189	action "logger Unknown USB device: vendor $vendor product $product \
190		bus $bus";
191};
192
193# Some PC-CARDs don't offer numerical manufacturer/product IDs, just
194# show the CIS info there.
195nomatch 20 {
196	match "bus" "pccard[0-9]+";
197	match "manufacturer" "0xffffffff";
198	match "product" "0xffffffff";
199	action "logger Unknown PCCARD device: CISproduct $cisproduct \
200		CIS-vendor $cisvendor bus $bus";
201};
202
203nomatch 10 {
204	match "bus" "pccard[0-9]+";
205	action "logger Unknown PCCARD device: manufacturer $manufacturer \
206		product $product CISproduct $cisproduct CIS-vendor \
207		$cisvendor bus $bus";
208};
209
210nomatch 10 {
211	match "bus" "cardbus[0-9]+";
212	action "logger Unknown Cardbus device: device $device class $class \
213		vendor $vendor bus $bus";
214};
215
216# Switch power profiles when the AC line state changes.
217notify 10 {
218	match "system"		"ACPI";
219	match "subsystem"	"ACAD";
220	action "/etc/rc.d/power_profile $notify";
221};
222
223# Notify all users before beginning emergency shutdown when we get
224# a _CRT or _HOT thermal event and we're going to power down the system
225# very soon.
226notify 10 {
227	match "system"		"ACPI";
228	match "subsystem"	"Thermal";
229	match "notify"		"0xcc";
230	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
231};
232
233# User requested suspend, so perform preparation steps and then execute
234# the actual suspend process.
235notify 10 {
236	match "system"		"ACPI";
237	match "subsystem"	"Suspend";
238	action "/etc/rc.suspend acpi $notify";
239};
240notify 10 {
241	match "system"		"ACPI";
242	match "subsystem"	"Resume";
243	action "/etc/rc.resume acpi $notify";
244};
245
246/* EXAMPLES TO END OF FILE
247
248# An example of something that a vendor might install if you were to
249# add their device.  This might reside in /usr/local/etc/devd/deqna.conf.
250# A deqna is, in this hypothetical example, a pccard ethernet-like device.
251# Students of history may know other devices by this name, and will get
252# the in-jokes in this entry.
253nomatch 10 {
254	match "bus" "pccard[0-9]+";
255	match "manufacturer" "0x1234";
256	match "product" "0x2323";
257	action "kldload -n if_deqna";
258};
259attach 10 {
260	device-name "deqna[0-9]+";
261	action "/etc/pccard_ether $device-name start";
262};
263detach 10 {
264	device-name "deqna[0-9]+";
265	action "/etc/pccard_ether $device-name stop";
266};
267
268# Examples of notify hooks.  A notify is a generic way for a kernel
269# subsystem to send event notification to userland.
270
271# Here are some examples of ACPI notify handlers.  ACPI subsystems that
272# generate notifies include the AC adapter, power/sleep buttons,
273# control method batteries, lid switch, and thermal zones.
274#
275# Information returned is not always the same as the ACPI notify
276# events.  See the ACPI specification for more information about
277# notifies.  Here is the information returned for each subsystem:
278#
279# ACAD:            AC line state (0 is offline, 1 is online)
280# Button:          Button pressed (0 for power, 1 for sleep)
281# CMBAT:           ACPI battery events
282# Lid:             Lid state (0 is closed, 1 is open)
283# Suspend, Resume: Suspend and resume notification
284# Thermal:         ACPI thermal zone events
285#
286# This example calls a script when the AC state changes, passing the
287# notify value as the first argument.  If the state is 0x00, it might
288# call some sysctls to implement economy mode.  If 0x01, it might set
289# the mode to performance.
290notify 10 {
291	match "system"		"ACPI";
292	match "subsystem"	"ACAD";
293	action			"/etc/acpi_ac $notify";
294};
295
296# This example works around a memory leak in PostgreSQL, restarting
297# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered.
298notify 0 {
299	match "system"		"RCTL";
300	match "rule"		"user:770:swap:.*";
301	action			"/usr/local/etc/rc.d/postgresql restart";
302};
303
304# Discard autofs caches, useful for the -media special map.
305notify 100 {
306	match "system" "GEOM";
307	match "subsystem" "DEV";
308	action "/usr/sbin/automount -c";
309};
310
311# Handle userland coredumps.
312# This commented out handler makes it possible to run an
313# automated debugging session after the core dump is generated.
314# Replace action with a proper coredump handler, but be aware that
315# it will run with elevated privileges.
316notify 10 {
317	match "system"          "kernel";
318	match "subsystem"       "signal";
319	match "type"            "coredump";
320	action "logger $comm $core";
321};
322
323*/
324