chiark / gitweb /
rules: Gentoo update
[elogind.git] / udev.7
1 .\"     Title: udev
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.73.1 <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 All udev configuration files are placed in
29 \fI/etc/udev/*\fR\. Every file consists of a set of lines of text\. All empty lines or lines beginning with \'#\' will be ignored\.
30 .SS "Configuration file"
31 .PP
32 udev expects its main configuration file at
33 \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:
34 .PP
35 \fBudev_root\fR
36 .RS 4
37 Specifies where to place the device nodes in the filesystem\. The default value is
38 \fI/dev\fR\.
39 .RE
40 .PP
41 \fBudev_rules\fR
42 .RS 4
43 The name of the udev rules file or directory to look for files with the suffix
44 \fI\.rules\fR\. Multiple rule files are read in lexical order\. The default value is
45 \fI/etc/udev/rules\.d\fR\.
46 .RE
47 .PP
48 \fBudev_log\fR
49 .RS 4
50 The logging priority\. Valid values are the numerical syslog priorities or their textual representations:
51 \fBerr\fR,
52 \fBinfo\fR
53 and
54 \fBdebug\fR\.
55 .RE
56 .SS "Rules files"
57 .PP
58 The udev rules are read from the files located in the
59 \fI/etc/udev/rules\.d\fR
60 directory or at the location specified value in the configuration file\. 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\.
61 .PP
62 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\.
63 .PP
64 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:
65 .PP
66 \fB==\fR
67 .RS 4
68 Compare for equality\.
69 .RE
70 .PP
71 \fB!=\fR
72 .RS 4
73 Compare for non\-equality\.
74 .RE
75 .PP
76 \fB=\fR
77 .RS 4
78 Assign a value to a key\. Keys that represent a list, are reset and only this single value is assigned\.
79 .RE
80 .PP
81 \fB+=\fR
82 .RS 4
83 Add the value to a key that holds a list of entries\.
84 .RE
85 .PP
86 \fB:=\fR
87 .RS 4
88 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules\.
89 .RE
90 .PP
91 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\.
92 .PP
93 \fBACTION\fR
94 .RS 4
95 Match the name of the event action\.
96 .RE
97 .PP
98 \fBDEVPATH\fR
99 .RS 4
100 Match the devpath of the event device\.
101 .RE
102 .PP
103 \fBKERNEL\fR
104 .RS 4
105 Match the name of the event device\.
106 .RE
107 .PP
108 \fBSUBSYSTEM\fR
109 .RS 4
110 Match the subsystem of the event device\.
111 .RE
112 .PP
113 \fBDRIVER\fR
114 .RS 4
115 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\.
116 .RE
117 .PP
118 \fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
119 .RS 4
120 Match sysfs attribute values of the event device\. Up to five
121 \fBATTR\fR
122 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\.
123 .RE
124 .PP
125 \fBKERNELS\fR
126 .RS 4
127 Search the devpath upwards for a matching device name\.
128 .RE
129 .PP
130 \fBSUBSYSTEMS\fR
131 .RS 4
132 Search the devpath upwards for a matching device subsystem name\.
133 .RE
134 .PP
135 \fBDRIVERS\fR
136 .RS 4
137 Search the devpath upwards for a matching device driver name\.
138 .RE
139 .PP
140 \fBATTRS{\fR\fB\fIfilename\fR\fR\fB}\fR
141 .RS 4
142 Search the devpath upwards for a device with matching sysfs attribute values\. Up to five
143 \fBATTRS\fR
144 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\.
145 .RE
146 .PP
147 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
148 .RS 4
149 Match against the value of an environment variable\. Up to five
150 \fBENV\fR
151 keys can be specified per rule\. Depending on the type of operator, this key is also used to export a variable to the environment\.
152 .RE
153 .PP
154 \fBTEST{\fR\fB\fIoctal mode mask\fR\fR\fB}\fR
155 .RS 4
156 Test the existence of a file\. An octal mode mask can be specified if needed\.
157 .RE
158 .PP
159 \fBPROGRAM\fR
160 .RS 4
161 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\.
162 .RE
163 .PP
164 \fBRESULT\fR
165 .RS 4
166 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\.
167 .RE
168 .PP
169 Most of the fields support a shell style pattern matching\. The following pattern characters are supported:
170 .PP
171 \fB*\fR
172 .RS 4
173 Matches zero, or any number of characters\.
174 .RE
175 .PP
176 \fB?\fR
177 .RS 4
178 Matches any single character\.
179 .RE
180 .PP
181 \fB[]\fR
182 .RS 4
183 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\.
184 .RE
185 .PP
186 The following keys can get values assigned:
187 .PP
188 \fBNAME\fR
189 .RS 4
190 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\.
191 .RE
192 .PP
193 \fBSYMLINK\fR
194 .RS 4
195 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\.
196 .RE
197 .PP
198 \fBOWNER, GROUP, MODE\fR
199 .RS 4
200 The permissions for the device node\. Every specified value overwrites the compiled\-in default value\.
201 .RE
202 .PP
203 \fBATTR{\fR\fB\fIkey\fR\fR\fB}\fR
204 .RS 4
205 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\.
206 .RE
207 .PP
208 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
209 .RS 4
210 Export a variable to the environment\. Depending on the type of operator, this key is also to match against an environment variable\.
211 .RE
212 .PP
213 \fBRUN\fR
214 .RS 4
215 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\.
216 .RE
217 .PP
218 \fBLABEL\fR
219 .RS 4
220 Named label where a GOTO can jump to\.
221 .RE
222 .PP
223 \fBGOTO\fR
224 .RS 4
225 Jumps to the next LABEL with a matching name
226 .RE
227 .PP
228 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
229 .RS 4
230 Import a set of variables into the event environment, depending on
231 \fItype\fR:
232 .PP
233 \fBprogram\fR
234 .RS 4
235 Execute an external program specified as the assigned value and import its output, which must be in environment key format\.
236 .RE
237 .PP
238 \fBfile\fR
239 .RS 4
240 Import a text file specified as the assigned value, which must be in environment key format\.
241 .RE
242 .PP
243 \fBparent\fR
244 .RS 4
245 Import the stored keys from the parent device by reading the database entry of the parent device\. The value assigned to
246 \fBIMPORT{parent}\fR
247 is used as a filter of key names to import (with the same shell\-style pattern matching used for comparisons)\.
248 .RE
249 .sp
250 If no option is given, udev will choose between
251 \fBprogram\fR
252 and
253 \fBfile\fR
254 based on the executable bit of the file permissions\.
255 .RE
256 .PP
257 \fBWAIT_FOR_SYSFS\fR
258 .RS 4
259 Wait for the specified sysfs file of the device to be created\. Can be used to fight against kernel sysfs timing issues\.
260 .RE
261 .PP
262 \fBOPTIONS\fR
263 .RS 4
264 Rule and device options:
265 .PP
266 \fBlast_rule\fR
267 .RS 4
268 Stops further rules application\. No later rules will have any effect\.
269 .RE
270 .PP
271 \fBignore_device\fR
272 .RS 4
273 Ignore this event completely\.
274 .RE
275 .PP
276 \fBignore_remove\fR
277 .RS 4
278 Do not remove the device node when the device goes away\. This may be useful as a workaround for broken device drivers\.
279 .RE
280 .PP
281 \fBlink_priority=\fR\fB\fIvalue\fR\fR
282 .RS 4
283 Specify the priority of the created symlinks\. Devices with higher priorities overwrite existing symlinks of other devices\.
284 .RE
285 .PP
286 \fBall_partitions\fR
287 .RS 4
288 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\.
289 .RE
290 .PP
291 \fBstring_escape=\fR\fB\fInone|replace\fR\fR
292 .RS 4
293 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\.
294 .RE
295 .RE
296 .PP
297 The
298 \fBNAME\fR,
299 \fBSYMLINK\fR,
300 \fBPROGRAM\fR,
301 \fBOWNER\fR,
302 \fBGROUP\fR
303 and
304 \fBRUN\fR
305 fields support simple printf\-like string substitutions\. The
306 \fBRUN\fR
307 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:
308 .PP
309 \fB$kernel\fR, \fB%k\fR
310 .RS 4
311 The kernel name for this device\.
312 .RE
313 .PP
314 \fB$number\fR, \fB%n\fR
315 .RS 4
316 The kernel number for this device\. For example, \'sda3\' has kernel number of \'3\'
317 .RE
318 .PP
319 \fB$devpath\fR, \fB%p\fR
320 .RS 4
321 The devpath of the device\.
322 .RE
323 .PP
324 \fB$id\fR, \fB%b\fR
325 .RS 4
326 The name of the device matched while searching the devpath upwards for
327 \fBSUBSYSTEMS\fR,
328 \fBKERNELS\fR,
329 \fBDRIVERS\fR
330 and
331 \fBATTRS\fR\.
332 .RE
333 .PP
334 \fB$driver\fR
335 .RS 4
336 The driver name of the device matched while searching the devpath upwards for
337 \fBSUBSYSTEMS\fR,
338 \fBKERNELS\fR,
339 \fBDRIVERS\fR
340 and
341 \fBATTRS\fR\.
342 .RE
343 .PP
344 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
345 .RS 4
346 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, all devices along the chain of parents are searched for a matching attribute\. If the attribute is a symlink, the last element of the symlink target is returned as the value\.
347 .RE
348 .PP
349 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
350 .RS 4
351 The value of an environment variable\.
352 .RE
353 .PP
354 \fB$major\fR, \fB%M\fR
355 .RS 4
356 The kernel major number for the device\.
357 .RE
358 .PP
359 \fB$minor\fR, \fB%m\fR
360 .RS 4
361 The kernel minor number for the device\.
362 .RE
363 .PP
364 \fB$result\fR, \fB%c\fR
365 .RS 4
366 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:
367 \fB%c{N}\fR\. If the number is followed by the \'+\' char this part plus all remaining parts of the result string are substituted:
368 \fB%c{N+}\fR
369 .RE
370 .PP
371 \fB$parent\fR, \fB%P\fR
372 .RS 4
373 The node name of the parent device\.
374 .RE
375 .PP
376 \fB$name\fR
377 .RS 4
378 The name of the device node\. The value is only set if an earlier rule assigned a value, or during a remove events\.
379 .RE
380 .PP
381 \fB$root\fR, \fB%r\fR
382 .RS 4
383 The udev_root value\.
384 .RE
385 .PP
386 \fB$sys\fR, \fB%S\fR
387 .RS 4
388 The sysfs mount point\.
389 .RE
390 .PP
391 \fB$tempnode\fR, \fB%N\fR
392 .RS 4
393 The name of a created temporary device node to provide access to the device from a external program before the real node is created\.
394 .RE
395 .PP
396 \fB%%\fR
397 .RS 4
398 The \'%\' character itself\.
399 .RE
400 .PP
401 \fB$$\fR
402 .RS 4
403 The \'$\' character itself\.
404 .RE
405 .PP
406 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
407 .SH "AUTHOR"
408 .PP
409 Written by Greg Kroah\-Hartman
410 <greg@kroah\.com>
411 and Kay Sievers
412 <kay\.sievers@vrfy\.org>\. With much help from Dan Stekloff
413 <dsteklof@us\.ibm\.com>
414 and many others\.
415 .SH "SEE ALSO"
416 .PP
417 \fBudevd\fR(8),
418 \fBudevadm\fR(8)