3 # Refer to devd.conf(5) and devd(8) man pages for the details on how to
4 # run and configure devd.
7 # NB: All regular expressions have an implicit ^$ around them.
8 # NB: device-name is shorthand for 'match device-name'
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";
19 # Setup some shorthand for regex that we use later in the file.
20 #XXX Yes, this is gross -- imp
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]+";
26 # Note that the attach/detach with the highest value wins, so that one can
27 # override these general rules.
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).
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
41 match "system" "IFNET";
42 match "subsystem" "!(usbus|wlan)[0-9]+";
43 match "type" "ATTACH";
44 action "/etc/pccard_ether $subsystem start";
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.
54 match "system" "IFNET";
55 match "type" "LINK_UP";
56 media-type "ethernet";
57 action "service dhclient quietstart $subsystem";
61 # Like Ethernet devices, but separate because 802.11 require spawning
65 device-name "$wifi-driver-regex";
66 action "/etc/pccard_ether $device-name startchildren";
69 device-name "$wifi-driver-regex";
70 action "/etc/pccard_ether $device-name stopchildren";
73 match "system" "IFNET";
74 match "type" "LINK_UP";
76 action "service dhclient quietstart $subsystem";
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.
85 action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
91 # When a USB Bluetooth dongle appears, activate it
93 device-name "ubt[0-9]+";
94 action "service bluetooth quietstart $device-name";
97 device-name "ubt[0-9]+";
98 action "service bluetooth quietstop $device-name";
101 # Firmware downloader for Atheros AR3011 based USB Bluetooth devices
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";
108 # When a USB keyboard arrives, attach it as the console keyboard.
111 action "service syscons setkeyboard /dev/ukbd0";
115 action "service syscons setkeyboard /dev/kbd0";
119 match "system" "DEVFS";
120 match "subsystem" "CDEV";
121 match "type" "CREATE";
122 match "cdev" "atp[0-9]+";
124 action "service moused quietstart $cdev";
128 match "system" "DEVFS";
129 match "subsystem" "CDEV";
130 match "type" "CREATE";
131 match "cdev" "ums[0-9]+";
133 action "service moused quietstart $cdev";
137 match "system" "DEVFS";
138 match "subsystem" "CDEV";
139 match "type" "CREATE";
140 match "cdev" "wsp[0-9]+";
142 action "service moused quietstart $cdev";
146 match "system" "DEVFS";
147 match "subsystem" "CDEV";
148 match "type" "DESTROY";
149 match "cdev" "ums[0-9]+";
151 action "service moused stop $cdev";
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.
159 # action "logger Unknown device: $pnpinfo $location $bus";
162 # Various logging of unknown devices.
164 match "bus" "uhub[0-9]+";
165 action "logger Unknown USB device: vendor $vendor product $product \
169 # Some Cardbus cards don't offer numerical manufacturer/product IDs, just
170 # show the CIS info there.
172 match "bus" "cardbus[0-9]+";
173 action "logger Unknown Cardbus device: device $device class $class \
174 vendor $vendor bus $bus";
177 # Switch power profiles when the AC line state changes.
179 match "system" "ACPI";
180 match "subsystem" "ACAD";
181 action "service power_profile $notify";
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
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!";
194 # User requested suspend, so perform preparation steps and then execute
195 # the actual suspend process.
197 match "system" "ACPI";
198 match "subsystem" "Suspend";
199 action "/etc/rc.suspend acpi $notify";
202 match "system" "ACPI";
203 match "subsystem" "Resume";
204 action "/etc/rc.resume acpi $notify";
207 /* EXAMPLES TO END OF FILE
209 # Examples of notify hooks. A notify is a generic way for a kernel
210 # subsystem to send event notification to userland.
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.
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:
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
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.
232 match "system" "ACPI";
233 match "subsystem" "ACAD";
234 action "/etc/acpi_ac $notify";
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.
240 match "system" "RCTL";
241 match "rule" "user:770:swap:.*";
242 action "service postgresql restart";
245 # Discard autofs caches, useful for the -media special map.
247 match "system" "GEOM";
248 match "subsystem" "DEV";
249 action "/usr/sbin/automount -c";
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.
258 match "system" "kernel";
259 match "subsystem" "signal";
260 match "type" "coredump";
261 action "logger $comm $core";
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).
268 match "system" "DEVFS";
269 match "subsystem" "CDEV";
270 match "type" "CREATE";
271 match "cdev" "ttyU[0-9]+";
272 action "/sbin/init q";