chiark / gitweb /
ignore rule with GOTO to a non-existent label
[elogind.git] / udev.7
1 .\"     Title: udev
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
4 .\"      Date: August 2005
5 .\"    Manual: udev
6 .\"    Source: udev
7 .\"
8 .TH "UDEV" "7" "August 2005" "udev" "udev"
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 udev - dynamic device management
15 .SH "DESCRIPTION"
16 .PP
17 udev provides a dynamic device directory containing only the files for actually present devices\. It creates or removes device node files in the
18 \fI/dev\fR
19 directory, or it renames network interfaces\.
20 .PP
21 Usually udev runs as
22 \fBudevd\fR(8)
23 and receives uevents directly from the kernel if a device is added or removed from the system\.
24 .PP
25 If udev receives a device event, it matches its configured rules against the available device attributes provided in sysfs to identify the device\. Rules that match may provide additional device information or specify a device node name and multiple symlink names and instruct udev to run additional programs as part of the device event handling\.
26 .SH "CONFIGURATION"
27 .PP
28 udev configuration files are placed in
29 \fI/etc/udev/\fR
30 and
31 \fI/lib/udev/\fR\. All empty lines, or lines beginning with \'#\' will be ignored\.
32 .SS "Configuration file"
33 .PP
34 udev expects its main configuration file at
35 \fI/etc/udev/udev\.conf\fR\. It consists of a set of variables allowing the user to override default udev values\. The following variables can be set:
36 .PP
37 \fBudev_root\fR
38 .RS 4
39 Specifies where to place the device nodes in the filesystem\. The default value is
40 \fI/dev\fR\.
41 .RE
42 .PP
43 \fBudev_log\fR
44 .RS 4
45 The logging priority\. Valid values are the numerical syslog priorities or their textual representations:
46 \fBerr\fR,
47 \fBinfo\fR
48 and
49 \fBdebug\fR\.
50 .RE
51 .SS "Rules files"
52 .PP
53 The udev rules are read from the files located in the default rules directory
54 \fI/lib/udev/rules\.d/\fR, the custom rules directory
55 \fI/etc/udev/rules\.d/\fR
56 and the temporary rules directory
57 \fI/dev/\.udev/rules\.d/\fR\. All rule files are sorted and processed in lexical order, regardless in which of these directories they live\. Every line in the rules file contains at least one key value pair\. There are two kind of keys, match and assignment keys\. If all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned\.
58 .PP
59 A matching rule may specify the name of the device node, add a symlink pointing to the node, or run a specified program as part of the event handling\. If no matching rule is found, the default device node name is used\.
60 .PP
61 A rule may consist of a list of one or more key value pairs separated by a comma\. Each key has a distinct operation, depending on the used operator\. Valid operators are:
62 .PP
63 \fB==\fR
64 .RS 4
65 Compare for equality\.
66 .RE
67 .PP
68 \fB!=\fR
69 .RS 4
70 Compare for non\-equality\.
71 .RE
72 .PP
73 \fB=\fR
74 .RS 4
75 Assign a value to a key\. Keys that represent a list, are reset and only this single value is assigned\.
76 .RE
77 .PP
78 \fB+=\fR
79 .RS 4
80 Add the value to a key that holds a list of entries\.
81 .RE
82 .PP
83 \fB:=\fR
84 .RS 4
85 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules\.
86 .RE
87 .PP
88 The following key names can be used to match against device properties\. Some of the keys also match against properties of the parent devices in sysfs, not only the device that has generated the event\. If multiple keys that match a parent device are specified in a single rule, all these keys must match at one and the same parent device\.
89 .PP
90 \fBACTION\fR
91 .RS 4
92 Match the name of the event action\.
93 .RE
94 .PP
95 \fBDEVPATH\fR
96 .RS 4
97 Match the devpath of the event device\.
98 .RE
99 .PP
100 \fBKERNEL\fR
101 .RS 4
102 Match the name of the event device\.
103 .RE
104 .PP
105 \fBNAME\fR
106 .RS 4
107 Match the name of the node or network interface\. It can be used once the NAME key has been set in one of the preceding rules\.
108 .RE
109 .PP
110 \fBSUBSYSTEM\fR
111 .RS 4
112 Match the subsystem of the event device\.
113 .RE
114 .PP
115 \fBDRIVER\fR
116 .RS 4
117 Match the driver name of the event device\. Only set for devices which are bound to a driver at the time the event is generated\.
118 .RE
119 .PP
120 \fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
121 .RS 4
122 Match sysfs attribute values of the event device\. Up to five
123 \fBATTR\fR
124 keys can be specified per rule\. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself\. Depending on the type of operator, this key is also used to set the value of a sysfs attribute\.
125 .RE
126 .PP
127 \fBKERNELS\fR
128 .RS 4
129 Search the devpath upwards for a matching device name\.
130 .RE
131 .PP
132 \fBSUBSYSTEMS\fR
133 .RS 4
134 Search the devpath upwards for a matching device subsystem name\.
135 .RE
136 .PP
137 \fBDRIVERS\fR
138 .RS 4
139 Search the devpath upwards for a matching device driver name\.
140 .RE
141 .PP
142 \fBATTRS{\fR\fB\fIfilename\fR\fR\fB}\fR
143 .RS 4
144 Search the devpath upwards for a device with matching sysfs attribute values\. Up to five
145 \fBATTRS\fR
146 keys can be specified per rule, but all of them must match on the same device\. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself\.
147 .RE
148 .PP
149 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
150 .RS 4
151 Match against the value of an environment variable\. Up to five
152 \fBENV\fR
153 keys can be specified per rule\. Depending on the type of operator, this key is also used to export a variable to the environment\.
154 .RE
155 .PP
156 \fBTEST{\fR\fB\fIoctal mode mask\fR\fR\fB}\fR
157 .RS 4
158 Test the existence of a file\. An octal mode mask can be specified if needed\.
159 .RE
160 .PP
161 \fBPROGRAM\fR
162 .RS 4
163 Execute external program\. The key is true, if the program returns with exit code zero\. The whole event environment is available to the executed program\. The program\'s output printed to stdout, is available in the RESULT key\.
164 .RE
165 .PP
166 \fBRESULT\fR
167 .RS 4
168 Match the returned string of the last PROGRAM call\. This key can be used in the same or in any later rule after a PROGRAM call\.
169 .RE
170 .PP
171 Most of the fields support a shell style pattern matching\. The following pattern characters are supported:
172 .PP
173 \fB*\fR
174 .RS 4
175 Matches zero, or any number of characters\.
176 .RE
177 .PP
178 \fB?\fR
179 .RS 4
180 Matches any single character\.
181 .RE
182 .PP
183 \fB[]\fR
184 .RS 4
185 Matches any single character specified within the brackets\. For example, the pattern string \'tty[SR]\' would match either \'ttyS\' or \'ttyR\'\. Ranges are also supported within this match with the \'\-\' character\. For example, to match on the range of all digits, the pattern [0\-9] would be used\. If the first character following the \'[\' is a \'!\', any characters not enclosed are matched\.
186 .RE
187 .PP
188 The following keys can get values assigned:
189 .PP
190 \fBNAME\fR
191 .RS 4
192 The name of the node to be created, or the name the network interface should be renamed to\. Only one rule can set the node name, all later rules with a NAME key will be ignored\.
193 .RE
194 .PP
195 \fBSYMLINK\fR
196 .RS 4
197 The name of a symlink targeting the node\. Every matching rule can add this value to the list of symlinks to be created along with the device node\. Multiple symlinks may be specified by separating the names by the space character\.
198 .RE
199 .PP
200 \fBOWNER, GROUP, MODE\fR
201 .RS 4
202 The permissions for the device node\. Every specified value overwrites the compiled\-in default value\.
203 .RE
204 .PP
205 \fBATTR{\fR\fB\fIkey\fR\fR\fB}\fR
206 .RS 4
207 The value that should be written to a sysfs attribute of the event device\. Depending on the type of operator, this key is also used to match against the value of a sysfs attribute\.
208 .RE
209 .PP
210 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
211 .RS 4
212 Export a variable to the environment\. Depending on the type of operator, this key is also to match against an environment variable\.
213 .RE
214 .PP
215 \fBRUN\fR
216 .RS 4
217 Add a program to the list of programs to be executed for a specific device\. This can only be used for very short running tasks\. Running an event process for a long period of time may block all further events for this or a dependent device\. Long running tasks need to be immediately detached from the event process itself\.
218 .sp
219 If the specifiefd string starts with
220 \fBsocket:\fR\fB\fIpath\fR\fR, all current event values will be passed to the specified socket, as a message in the same format the kernel sends an uevent\. If the first character of the specified path is an @ character, an abstract namespace socket is used, instead of an existing socket file\.
221 .RE
222 .PP
223 \fBLABEL\fR
224 .RS 4
225 Named label where a GOTO can jump to\.
226 .RE
227 .PP
228 \fBGOTO\fR
229 .RS 4
230 Jumps to the next LABEL with a matching name
231 .RE
232 .PP
233 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
234 .RS 4
235 Import a set of variables into the event environment, depending on
236 \fItype\fR:
237 .PP
238 \fBprogram\fR
239 .RS 4
240 Execute an external program specified as the assigned value and import its output, which must be in environment key format\.
241 .RE
242 .PP
243 \fBfile\fR
244 .RS 4
245 Import a text file specified as the assigned value, which must be in environment key format\.
246 .RE
247 .PP
248 \fBparent\fR
249 .RS 4
250 Import the stored keys from the parent device by reading the database entry of the parent device\. The value assigned to
251 \fBIMPORT{parent}\fR
252 is used as a filter of key names to import (with the same shell\-style pattern matching used for comparisons)\.
253 .RE
254 .sp
255 If no option is given, udev will choose between
256 \fBprogram\fR
257 and
258 \fBfile\fR
259 based on the executable bit of the file permissions\.
260 .RE
261 .PP
262 \fBWAIT_FOR\fR
263 .RS 4
264 Wait for a file to become available\.
265 .RE
266 .PP
267 \fBOPTIONS\fR
268 .RS 4
269 Rule and device options:
270 .PP
271 \fBlast_rule\fR
272 .RS 4
273 Stops further rules application\. No later rules will have any effect\.
274 .RE
275 .PP
276 \fBignore_device\fR
277 .RS 4
278 Ignore this event completely\.
279 .RE
280 .PP
281 \fBignore_remove\fR
282 .RS 4
283 Do not remove the device node when the device goes away\. This may be useful as a workaround for broken device drivers\.
284 .RE
285 .PP
286 \fBlink_priority=\fR\fB\fIvalue\fR\fR
287 .RS 4
288 Specify the priority of the created symlinks\. Devices with higher priorities overwrite existing symlinks of other devices\. The default is 0\.
289 .RE
290 .PP
291 \fBall_partitions\fR
292 .RS 4
293 Create the device nodes for all available partitions of a block device\. This may be useful for removable media devices where media changes are not detected\.
294 .RE
295 .PP
296 \fBevent_timeout=\fR
297 .RS 4
298 Number of seconds an event will wait for operations to finish, before it will terminate itself\.
299 .RE
300 .PP
301 \fBstring_escape=\fR\fB\fInone|replace\fR\fR
302 .RS 4
303 Usually control and other possibly unsafe characters are replaced in strings used for device naming\. The mode of replacement can be specified with this option\.
304 .RE
305 .RE
306 .PP
307 The
308 \fBNAME\fR,
309 \fBSYMLINK\fR,
310 \fBPROGRAM\fR,
311 \fBOWNER\fR,
312 \fBGROUP\fR,
313 \fBMODE\fR
314 and
315 \fBRUN\fR
316 fields support simple printf\-like string substitutions\. The
317 \fBRUN\fR
318 format chars gets applied after all rules have been processed, right before the program is executed\. It allows the use of the complete environment set by earlier matching rules\. For all other fields, substitutions are applied while the individual rule is being processed\. The available substitutions are:
319 .PP
320 \fB$kernel\fR, \fB%k\fR
321 .RS 4
322 The kernel name for this device\.
323 .RE
324 .PP
325 \fB$number\fR, \fB%n\fR
326 .RS 4
327 The kernel number for this device\. For example, \'sda3\' has kernel number of \'3\'
328 .RE
329 .PP
330 \fB$devpath\fR, \fB%p\fR
331 .RS 4
332 The devpath of the device\.
333 .RE
334 .PP
335 \fB$id\fR, \fB%b\fR
336 .RS 4
337 The name of the device matched while searching the devpath upwards for
338 \fBSUBSYSTEMS\fR,
339 \fBKERNELS\fR,
340 \fBDRIVERS\fR
341 and
342 \fBATTRS\fR\.
343 .RE
344 .PP
345 \fB$driver\fR
346 .RS 4
347 The driver name of the device matched while searching the devpath upwards for
348 \fBSUBSYSTEMS\fR,
349 \fBKERNELS\fR,
350 \fBDRIVERS\fR
351 and
352 \fBATTRS\fR\.
353 .RE
354 .PP
355 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
356 .RS 4
357 The value of a sysfs attribute found at the device, where all keys of the rule have matched\. If the matching device does not have such an attribute, follow the chain of parent devices and use the value of the first attribute that matches\. If the attribute is a symlink, the last element of the symlink target is returned as the value\.
358 .RE
359 .PP
360 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
361 .RS 4
362 The value of an environment variable\.
363 .RE
364 .PP
365 \fB$major\fR, \fB%M\fR
366 .RS 4
367 The kernel major number for the device\.
368 .RE
369 .PP
370 \fB$minor\fR, \fB%m\fR
371 .RS 4
372 The kernel minor number for the device\.
373 .RE
374 .PP
375 \fB$result\fR, \fB%c\fR
376 .RS 4
377 The string returned by the external program requested with PROGRAM\. A single part of the string, separated by a space character may be selected by specifying the part number as an attribute:
378 \fB%c{N}\fR\. If the number is followed by the \'+\' char this part plus all remaining parts of the result string are substituted:
379 \fB%c{N+}\fR
380 .RE
381 .PP
382 \fB$parent\fR, \fB%P\fR
383 .RS 4
384 The node name of the parent device\.
385 .RE
386 .PP
387 \fB$name\fR
388 .RS 4
389 The current name of the device node\. If not changed by a rule, it is the name of the kernel device\.
390 .RE
391 .PP
392 \fB$links\fR
393 .RS 4
394 The current list of symlinks, separated by a space character\. The value is only set if an earlier rule assigned a value, or during a remove events\.
395 .RE
396 .PP
397 \fB$root\fR, \fB%r\fR
398 .RS 4
399 The udev_root value\.
400 .RE
401 .PP
402 \fB$sys\fR, \fB%S\fR
403 .RS 4
404 The sysfs mount point\.
405 .RE
406 .PP
407 \fB$tempnode\fR, \fB%N\fR
408 .RS 4
409 The name of a created temporary device node to provide access to the device from a external program before the real node is created\.
410 .RE
411 .PP
412 \fB%%\fR
413 .RS 4
414 The \'%\' character itself\.
415 .RE
416 .PP
417 \fB$$\fR
418 .RS 4
419 The \'$\' character itself\.
420 .RE
421 .PP
422 The count of characters to be substituted may be limited by specifying the format length value\. For example, \'%3s{file}\' will only insert the first three characters of the sysfs attribute
423 .SH "AUTHOR"
424 .PP
425 Written by Greg Kroah\-Hartman
426 <greg@kroah\.com>
427 and Kay Sievers
428 <kay\.sievers@vrfy\.org>\. With much help from Dan Stekloff and many others\.
429 .SH "SEE ALSO"
430 .PP
431 \fBudevd\fR(8),
432 \fBudevadm\fR(8)