chiark / gitweb /
man: fix typo
[elogind.git] / udev.7
1 .\"     Title: udev
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.72.0 <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 form 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 consists 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 \fBPROGRAM\fR
155 .RS 4
156 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.
157 .RE
158 .PP
159 \fBRESULT\fR
160 .RS 4
161 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.
162 .RE
163 .PP
164 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
165 .PP
166 \fB*\fR
167 .RS 4
168 Matches zero, or any number of characters.
169 .RE
170 .PP
171 \fB?\fR
172 .RS 4
173 Matches any single character.
174 .RE
175 .PP
176 \fB[]\fR
177 .RS 4
178 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.
179 .RE
180 .PP
181 The following keys can get values assigned:
182 .PP
183 \fBNAME\fR
184 .RS 4
185 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.
186 .RE
187 .PP
188 \fBSYMLINK\fR
189 .RS 4
190 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.
191 .RE
192 .PP
193 \fBOWNER, GROUP, MODE\fR
194 .RS 4
195 The permissions for the device node. Every specified value overwrites the compiled\-in default value.
196 .RE
197 .PP
198 \fBATTR{\fR\fB\fIkey\fR\fR\fB}\fR
199 .RS 4
200 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.
201 .RE
202 .PP
203 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
204 .RS 4
205 Export a variable to the environment. Depending on the type of operator, this key is also to match against an environment variable.
206 .RE
207 .PP
208 \fBRUN\fR
209 .RS 4
210 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.
211 .RE
212 .PP
213 \fBLABEL\fR
214 .RS 4
215 Named label where a GOTO can jump to.
216 .RE
217 .PP
218 \fBGOTO\fR
219 .RS 4
220 Jumps to the next LABEL with a matching name
221 .RE
222 .PP
223 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
224 .RS 4
225 Import a set of variables into the event environment, depending on
226 \fItype\fR:
227 .RS 4
228 .PP
229 \fBprogram\fR
230 .RS 4
231 Execute an external program specified as the assigned value and import its output, which must be in environment key format.
232 .RE
233 .PP
234 \fBfile\fR
235 .RS 4
236 Import a text file specified as the assigned value, which must be in environment key format.
237 .RE
238 .PP
239 \fBparent\fR
240 .RS 4
241 Import the stored keys from the parent device by reading the database entry of the parent device. The value assigned to
242 \fBIMPORT{parent}\fR
243 is used as a filter of key names to import (with the same shell\-style pattern matching used for comparisons).
244 .RE
245 .RE
246 .IP "" 4
247 If no option is given, udev will choose between
248 \fBprogram\fR
249 and
250 \fBfile\fR
251 based on the executable bit of of the file permissions.
252 .RE
253 .PP
254 \fBWAIT_FOR_SYSFS\fR
255 .RS 4
256 Wait for the specified sysfs file of the device to be created. Can be used to fight against kernel sysfs timing issues.
257 .RE
258 .PP
259 \fBOPTIONS\fR
260 .RS 4
261 \fBlast_rule\fR
262 stops further rules application. No later rules will have any effect.
263 \fBignore_device\fR
264 will ignore this event completely.
265 \fBignore_remove\fR
266 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers.
267 \fBall_partitions\fR
268 will 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.
269 .RE
270 .PP
271 The
272 \fBNAME\fR,
273 \fBSYMLINK\fR,
274 \fBPROGRAM\fR,
275 \fBOWNER\fR,
276 \fBGROUP\fR
277 and
278 \fBRUN\fR
279 fields support simple printf\-like string substitutions. The
280 \fBRUN\fR
281 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:
282 .PP
283 \fB$kernel\fR, \fB%k\fR
284 .RS 4
285 The kernel name for this device.
286 .RE
287 .PP
288 \fB$number\fR, \fB%n\fR
289 .RS 4
290 The kernel number for this device. For example, 'sda3' has kernel number of '3'
291 .RE
292 .PP
293 \fB$devpath\fR, \fB%p\fR
294 .RS 4
295 The devpath of the device.
296 .RE
297 .PP
298 \fB$id\fR, \fB%b\fR
299 .RS 4
300 The name of the device matched while searching the devpath upwards for
301 \fBSUBSYSTEMS\fR,
302 \fBKERNELS\fR,
303 \fBDRIVERS\fR
304 and
305 \fBATTRS\fR.
306 .RE
307 .PP
308 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
309 .RS 4
310 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.
311 .RE
312 .PP
313 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
314 .RS 4
315 The value of an environment variable.
316 .RE
317 .PP
318 \fB$major\fR, \fB%M\fR
319 .RS 4
320 The kernel major number for the device.
321 .RE
322 .PP
323 \fB$minor\fR \fB%m\fR
324 .RS 4
325 The kernel minor number for the device.
326 .RE
327 .PP
328 \fB$result\fR, \fB%c\fR
329 .RS 4
330 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:
331 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted:
332 \fB%c{N+}\fR
333 .RE
334 .PP
335 \fB$parent\fR, \fB%P\fR
336 .RS 4
337 The node name of the parent device.
338 .RE
339 .PP
340 \fB$root\fR, \fB%r\fR
341 .RS 4
342 The udev_root value.
343 .RE
344 .PP
345 \fB$tempnode\fR, \fB%N\fR
346 .RS 4
347 The name of a created temporary device node to provide access to the device from a external program before the real node is created.
348 .RE
349 .PP
350 \fB%%\fR
351 .RS 4
352 The '%' character itself.
353 .RE
354 .PP
355 \fB$$\fR
356 .RS 4
357 The '$' character itself.
358 .RE
359 .PP
360 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
361 .SH "AUTHOR"
362 .PP
363 Written by Greg Kroah\-Hartman
364 <greg@kroah.com>
365 and Kay Sievers
366 <kay.sievers@vrfy.org>. With much help from Dan Stekloff
367 <dsteklof@us.ibm.com>
368 and many others.
369 .SH "SEE ALSO"
370 .PP
371 \fBudevd\fR(8),
372 \fBudevinfo\fR(8),
373 \fBudevmonitor\fR(8)