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