|
Lines 41-47
Link Here
|
| 41 |
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
41 |
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 42 |
.\" SOFTWARE. |
42 |
.\" SOFTWARE. |
| 43 |
.\" |
43 |
.\" |
| 44 |
.Dd October 17, 2002 |
44 |
.Dd August 20, 2005 |
| 45 |
.Dt DEVD.CONF 5 |
45 |
.Dt DEVD.CONF 5 |
| 46 |
.Os |
46 |
.Os |
| 47 |
.Sh NAME |
47 |
.Sh NAME |
|
Lines 61-78
Link Here
|
| 61 |
The following statements are supported: |
61 |
The following statements are supported: |
| 62 |
.Bl -tag -width ".Ic options" |
62 |
.Bl -tag -width ".Ic options" |
| 63 |
.It Ic options |
63 |
.It Ic options |
| 64 |
specifies various options and parameters for the operation of |
64 |
Specifies various options and parameters for the operation of |
| 65 |
.Xr devd 8 . |
65 |
.Xr devd 8 . |
| 66 |
.It Ic attach |
66 |
.It Ic attach |
| 67 |
specifies various matching criteria and actions to perform when |
67 |
Specifies various matching criteria and actions to perform when |
| 68 |
a newly attached device matches said criteria. |
68 |
a newly attached device matches said criteria. |
| 69 |
.It Ic detach |
69 |
.It Ic detach |
| 70 |
specifies various matching criteria and actions to perform when |
70 |
Specifies various matching criteria and actions to perform when |
| 71 |
a newly detached device matches said criteria. |
71 |
a newly detached device matches said criteria. |
| 72 |
.It Ic nomatch |
72 |
.It Ic nomatch |
| 73 |
specifies various matching criteria and actions to perform when |
73 |
Specifies various matching criteria and actions to perform when |
| 74 |
no device driver currently loaded in the kernel claims a (new) |
74 |
no device driver currently loaded in the kernel claims a (new) |
| 75 |
device. |
75 |
device. |
|
|
76 |
.It Ic notify |
| 77 |
Specifies various matching criteria and actions to perform when the kernel |
| 78 |
sends an event notification to userland. |
| 76 |
.El |
79 |
.El |
| 77 |
.Pp |
80 |
.Pp |
| 78 |
Statements may occur in any order in the configuration file, and may be |
81 |
Statements may occur in any order in the configuration file, and may be |
|
Lines 80-85
Link Here
|
| 80 |
Further details on the syntax and meaning of each statement and their |
83 |
Further details on the syntax and meaning of each statement and their |
| 81 |
substatements are explained below. |
84 |
substatements are explained below. |
| 82 |
.Pp |
85 |
.Pp |
|
|
86 |
Each statement, except |
| 87 |
.Dq options |
| 88 |
has a priority (an arbitrary number) associated with it, where |
| 89 |
.Ql 0 |
| 90 |
is defined as the lowest priority. |
| 91 |
If two statements match the same event, only the action of the statement with |
| 92 |
highest priority will be executed. |
| 93 |
In this way generic statements can be overridden for devices or |
| 94 |
notifications that require special attention. |
| 95 |
.Pp |
| 96 |
The general syntax of a statement is: |
| 97 |
.Pp |
| 98 |
.Bd -literal -offset indent |
| 99 |
statement priority { |
| 100 |
substatement "value"; |
| 101 |
... |
| 102 |
substatement "value"; |
| 103 |
}; |
| 104 |
.Ed |
| 105 |
.Pp |
| 106 |
.Ss Sub-statements |
| 107 |
The following sub-statements are supported within the |
| 108 |
.Dq options |
| 109 |
statement. |
| 110 |
.Bl -tag -width ".Ic directory" |
| 111 |
.It Ic directory \*q/some/path\*q; |
| 112 |
Adds the given directory to the list of directories from which |
| 113 |
.Xr devd 8 |
| 114 |
will read |
| 115 |
configuration files. Any number of |
| 116 |
.Dq directory |
| 117 |
statements can be used. |
| 118 |
.It Ic pid-file \*q/var/run/devd.pid\*q; |
| 119 |
Specifies pid file. |
| 120 |
.It Ic set regexp-name \*q(some|regexp)\*q; |
| 121 |
Creates a regular expression and assigns it to the variable |
| 122 |
.Va regexp-name |
| 123 |
; this variable is then avaiable throughout the rest of |
| 124 |
the configuration file. |
| 125 |
All regular expressions have an implicit |
| 126 |
.Ql Li ^$ |
| 127 |
around them. |
| 128 |
.El |
| 129 |
.Pp |
| 130 |
The following sub-statements are supported within the |
| 131 |
.Dq attach |
| 132 |
and |
| 133 |
.Dq detach |
| 134 |
statements. |
| 135 |
.Bl -tag -width ".Ic directory" |
| 136 |
.It Ic device-name \*qstring\*q; |
| 137 |
Actually a shorthand to |
| 138 |
.Dq match device-name |
| 139 |
Matches a device named |
| 140 |
.Va string |
| 141 |
; which are allowed to be a regular expression or a variable previously created |
| 142 |
containing a regular expression. |
| 143 |
The |
| 144 |
.Va device-name |
| 145 |
variable |
| 146 |
is avaiable for later use with the action-statement. |
| 147 |
.It Ic match \*qvariable\*q \*qvalue\*q; |
| 148 |
Matches the content of |
| 149 |
.Va value |
| 150 |
against |
| 151 |
.Va variable |
| 152 |
, the content of |
| 153 |
.Va value |
| 154 |
may be a regular expression. |
| 155 |
Not really needed during |
| 156 |
.Dq Li attach |
| 157 |
nor |
| 158 |
.Dq Li detach |
| 159 |
events since the |
| 160 |
.Dq Li device-name |
| 161 |
statement takes care of all device matching. |
| 162 |
For a partial list of variables, see below. |
| 163 |
.It Ic action \*qcommand\*q; |
| 164 |
Command to execute upon a successful match. |
| 165 |
Example |
| 166 |
.Ic /etc/pccard_ether $device-name start |
| 167 |
.El |
| 168 |
.Pp |
| 169 |
The following sub-statements are supported within the |
| 170 |
.Dq nomatch |
| 171 |
statement. |
| 172 |
.Bl -tag -width ".Ic directory" |
| 173 |
.It Ic match \*qvariable\*q \*qvalue\*q; |
| 174 |
Matches the content of |
| 175 |
.Va value |
| 176 |
against |
| 177 |
.Va variable |
| 178 |
, the content of |
| 179 |
.Va value |
| 180 |
may be a regular expression. |
| 181 |
For a partial list of variables, see below. |
| 182 |
.It Ic action \*qcommand\*q; |
| 183 |
Same as above. |
| 184 |
.El |
| 185 |
.Pp |
| 186 |
The following sub-statements are supported within the |
| 187 |
.Dq notify |
| 188 |
statement. |
| 189 |
The |
| 190 |
.Dq Li notify |
| 191 |
variable is avaiable inside this statement and contains, a value, depending |
| 192 |
on which system and subsystem that delivered the event. |
| 193 |
.Bl -tag -width ".Ic directory" |
| 194 |
.It Ic match \*qsystem|subsystem|type|notify\*q \*qvalue\*q; |
| 195 |
Any number of |
| 196 |
.Dq match |
| 197 |
statements can exists within a |
| 198 |
.Dq notify |
| 199 |
statement. |
| 200 |
.Va value |
| 201 |
can be either a fixed string or a regular expression. |
| 202 |
Below is a list of avaiable systems, subsystems, and types. |
| 203 |
.It Ic action \*qcommand\*q; |
| 204 |
Command to execute upon a successful match. Example |
| 205 |
.Ic /etc/rc.d/power_profile $notify |
| 206 |
.El |
| 207 |
.Ss Variables that can be used with the match statement |
| 208 |
A partial list of variables and their possible values that can be used together |
| 209 |
with the |
| 210 |
.Dq match |
| 211 |
statement. |
| 212 |
.Pp |
| 213 |
.Bl -tag -width "manufacturer" -compact |
| 214 |
.It Ic Variable |
| 215 |
.Ic Possible value |
| 216 |
.It system |
| 217 |
Matches a system type, see below |
| 218 |
.It subsystem |
| 219 |
Matches a subsystem of a system, see below |
| 220 |
.It type |
| 221 |
Type of notification, see below |
| 222 |
.It notify |
| 223 |
Match the value of the |
| 224 |
.Dq Li notify |
| 225 |
variable. |
| 226 |
.It device-name |
| 227 |
Name of attached/detached device |
| 228 |
.It bus |
| 229 |
pccard[0-9]+, cardbus[0-9]+ |
| 230 |
.It vendor |
| 231 |
Vendor ID |
| 232 |
.It device |
| 233 |
Device ID |
| 234 |
.It subvendor |
| 235 |
Sub-vendor ID |
| 236 |
.It subdevice |
| 237 |
Sub-device ID |
| 238 |
.It class |
| 239 |
Device class |
| 240 |
.It slot |
| 241 |
Card slot |
| 242 |
.It function |
| 243 |
Card functions |
| 244 |
.It manufacturer |
| 245 |
Manufacturer ID (pccard) |
| 246 |
.It product |
| 247 |
Product ID (pccard) |
| 248 |
.It cisvendor |
| 249 |
CIS-vendor |
| 250 |
.It cisproduct |
| 251 |
CIS-product |
| 252 |
.El |
| 253 |
.Ss Notify matching |
| 254 |
A Partial list of systems, subsystems, and types used within the |
| 255 |
.Dq notify |
| 256 |
mechanism. |
| 257 |
.Pp |
| 258 |
.Bl -tag -width "IFNET" -compact |
| 259 |
.It Ic System |
| 260 |
.It ACPI |
| 261 |
Events related to the ACPI subsystem. |
| 262 |
.Bl -tag -compact |
| 263 |
.It Ic Subsystem |
| 264 |
.It ACAD |
| 265 |
AC Line state ($notify=0x00 is offline, 0x01 is online). |
| 266 |
.It Button |
| 267 |
Button state ($notify=0x00 is power, 0x01 is sleep). |
| 268 |
.It CMBAT |
| 269 |
Battery events. |
| 270 |
.It Lid |
| 271 |
Lid state ($notify=0x00 is closed, 0x01 is open). |
| 272 |
.It Thermal |
| 273 |
Thermal zone events. |
| 274 |
.El |
| 275 |
.Pp |
| 276 |
.It IFNET |
| 277 |
Events related to the network subsystem. |
| 278 |
.Bl -tag -compact |
| 279 |
.It Ic Subsystem |
| 280 |
.It [interface] |
| 281 |
The |
| 282 |
.Dq subsystem |
| 283 |
is the actual name of the network interface on which the event |
| 284 |
took place. |
| 285 |
.Bl -tag -compact |
| 286 |
.It Ic Type |
| 287 |
.It LINK_UP |
| 288 |
Carrier status changed to UP. |
| 289 |
.It LINK_DOWN |
| 290 |
Carrier status changed to DOWN. |
| 291 |
.El |
| 292 |
.El |
| 293 |
.El |
| 294 |
.Pp |
| 295 |
A link state change to UP on the interface |
| 296 |
.Dq fxp0 |
| 297 |
would result in the following notify event: |
| 298 |
.Bd -literal -offset indent |
| 299 |
system=IFNET, subsystem=fxp0, type=LINK_UP |
| 300 |
.Ed |
| 301 |
.Pp |
| 302 |
An AC line state change to |
| 303 |
.Dq offline |
| 304 |
would result in the following event: |
| 305 |
.Bd -literal -offset indent |
| 306 |
system=ACPI, subsystem=ACAD, notify=0x00 |
| 307 |
.Ed |
| 308 |
.Ss Comments |
| 83 |
Comments may appear anywhere that whitespace may appear in a |
309 |
Comments may appear anywhere that whitespace may appear in a |
| 84 |
configuration file. |
310 |
configuration file. |
| 85 |
To appeal to programmers of all kinds, they can |
311 |
To appeal to programmers of all kinds, they can |
|
Lines 110-116
Link Here
|
| 110 |
(slash, slash) and continue to the end of the physical line. |
336 |
(slash, slash) and continue to the end of the physical line. |
| 111 |
They cannot be continued across multiple physical lines; to have |
337 |
They cannot be continued across multiple physical lines; to have |
| 112 |
one logical comment span multiple lines, each line must use the |
338 |
one logical comment span multiple lines, each line must use the |
| 113 |
.Ql // |
339 |
.Dq // |
| 114 |
pair. |
340 |
pair. |
| 115 |
For example: |
341 |
For example: |
| 116 |
.Bd -literal -offset indent |
342 |
.Bd -literal -offset indent |
|
Lines 118-123
Link Here
|
| 118 |
// is a new comment, even though it is logically |
344 |
// is a new comment, even though it is logically |
| 119 |
// part of the previous comment. |
345 |
// part of the previous comment. |
| 120 |
.Ed |
346 |
.Ed |
|
|
347 |
.Sh EXAMPLES |
| 348 |
.Bd -literal |
| 349 |
# |
| 350 |
# This will catch link down events on the interfaces fxp0 and ath0 |
| 351 |
# |
| 352 |
notify 0 { |
| 353 |
match "system" "IFNET"; |
| 354 |
match "subsystem" "(fxp0|ath0)"; |
| 355 |
match "type" "LINK_DOWN"; |
| 356 |
action "logger $subsystem is DOWN"; |
| 357 |
}; |
| 358 |
|
| 359 |
# |
| 360 |
# Match lid open/close events |
| 361 |
# These can be combined to a single event, by passing the |
| 362 |
# value of $notify to the external script. |
| 363 |
# |
| 364 |
notify 0 { |
| 365 |
match "system" "ACPI"; |
| 366 |
match "subsystem" "Lid"; |
| 367 |
match "notify" "0x00"; |
| 368 |
action "logger Lid closed, we can sleep now!"; |
| 369 |
}; |
| 370 |
|
| 371 |
notify 0 { |
| 372 |
match "system" "ACPI"; |
| 373 |
match "subsystem" "Lid"; |
| 374 |
match "notify" "0x01"; |
| 375 |
action "logger Lid opened, the sleeper must awaken!"; |
| 376 |
}; |
| 377 |
|
| 378 |
# |
| 379 |
# Try to configure ath and wi devices with pccard_ether |
| 380 |
# as they are attached. |
| 381 |
# |
| 382 |
attach 0 { |
| 383 |
device-name "(ath|wi)[0-9]+"; |
| 384 |
action "/etc/pccard_ether $device-name start"; |
| 385 |
}; |
| 386 |
|
| 387 |
# |
| 388 |
# Stop ath and wi devices as they are detached from |
| 389 |
# the system. |
| 390 |
# |
| 391 |
detach 0 { |
| 392 |
device-name "(ath|wi)[0-9]+"; |
| 393 |
action "/etc/pccard_ether $device-name stop"; |
| 394 |
}; |
| 395 |
.Ed |
| 396 |
.Pp |
| 397 |
The installed |
| 398 |
.Pa /etc/devd.conf |
| 399 |
has many additional examples. |
| 121 |
.Sh FILES |
400 |
.Sh FILES |
| 122 |
.Bl -tag -width ".Pa /etc/devd.conf" -compact |
401 |
.Bl -tag -width ".Pa /etc/devd.conf" -compact |
| 123 |
.It Pa /etc/devd.conf |
402 |
.It Pa /etc/devd.conf |