chiark / gitweb /
create_floppy_devices: add option for owner/group
[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. 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.
61 .PP
62 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:
63 .PP
64 \fB==\fR
65 .RS 4
66 Compare for equality.
67 .RE
68 .PP
69 \fB!=\fR
70 .RS 4
71 Compare for non\-equality.
72 .RE
73 .PP
74 \fB=\fR
75 .RS 4
76 Assign a value to a key. Keys that represent a list, are reset and only this single value is assigned.
77 .RE
78 .PP
79 \fB+=\fR
80 .RS 4
81 Add the value to a key that holds a list of entries.
82 .RE
83 .PP
84 \fB:=\fR
85 .RS 4
86 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules.
87 .RE
88 .PP
89 The following key names can be used to match against device properties:
90 .PP
91 \fBACTION\fR
92 .RS 4
93 Match the name of the event action.
94 .RE
95 .PP
96 \fBDEVPATH\fR
97 .RS 4
98 Match the devpath of the event device.
99 .RE
100 .PP
101 \fBKERNEL\fR
102 .RS 4
103 Match the name of the event device.
104 .RE
105 .PP
106 \fBSUBSYSTEM\fR
107 .RS 4
108 Match the subsystem of the event device.
109 .RE
110 .PP
111 \fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
112 .RS 4
113 Match sysfs attribute values of the event device. Up to five
114 \fBATTR\fR
115 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.
116 .RE
117 .PP
118 \fBKERNELS\fR
119 .RS 4
120 Search the devpath upwards for a matching device name.
121 .RE
122 .PP
123 \fBSUBSYSTEMS\fR
124 .RS 4
125 Search the devpath upwards for a matching device subsystem name.
126 .RE
127 .PP
128 \fBDRIVERS\fR
129 .RS 4
130 Search the devpath upwards for a matching device driver name.
131 .RE
132 .PP
133 \fBATTRS{\fR\fB\fIfilename\fR\fR\fB}\fR
134 .RS 4
135 Search the devpath upwards for a device with matching sysfs attribute values. Up to five
136 \fBATTRS\fR
137 keys can be specified per rule. All attributes 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.
138 .RE
139 .PP
140 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
141 .RS 4
142 Match against the value of an environment variable. Up to five
143 \fBENV\fR
144 keys can be specified per rule. Depending on the type of operator, this key is also used to export a variable to the environment.
145 .RE
146 .PP
147 \fBPROGRAM\fR
148 .RS 4
149 Execute external program. The key is true, if the program returns without exit code zero. The whole event environment is available to the executed program. The program's output printed to stdout is available for the RESULT key.
150 .RE
151 .PP
152 \fBRESULT\fR
153 .RS 4
154 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.
155 .RE
156 .PP
157 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
158 .PP
159 \fB*\fR
160 .RS 4
161 Matches zero, or any number of characters.
162 .RE
163 .PP
164 \fB?\fR
165 .RS 4
166 Matches any single character.
167 .RE
168 .PP
169 \fB[]\fR
170 .RS 4
171 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.
172 .RE
173 .PP
174 The following keys can get values assigned:
175 .PP
176 \fBNAME\fR
177 .RS 4
178 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.
179 .RE
180 .PP
181 \fBSYMLINK\fR
182 .RS 4
183 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.
184 .RE
185 .PP
186 \fBOWNER, GROUP, MODE\fR
187 .RS 4
188 The permissions for the device node. Every specified value overwrites the compiled\-in default value.
189 .RE
190 .PP
191 \fBATTR{\fR\fB\fIkey\fR\fR\fB}\fR
192 .RS 4
193 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.
194 .RE
195 .PP
196 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
197 .RS 4
198 Export a variable to the environment. Depending on the type of operator, this key is also to match against an environment variable.
199 .RE
200 .PP
201 \fBRUN\fR
202 .RS 4
203 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.
204 .RE
205 .PP
206 \fBLABEL\fR
207 .RS 4
208 Named label where a GOTO can jump to.
209 .RE
210 .PP
211 \fBGOTO\fR
212 .RS 4
213 Jumps to the next LABEL with a matching name
214 .RE
215 .PP
216 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
217 .RS 4
218 Import a set of variables into the event environment, depending on
219 \fItype\fR:
220 .RS 4
221 .PP
222 \fBprogram\fR
223 .RS 4
224 Execute an external program specified as the assigned value and import its output, which must be in environment key format.
225 .RE
226 .PP
227 \fBfile\fR
228 .RS 4
229 Import a text file specified as the assigned value, which must be in environment key format.
230 .RE
231 .PP
232 \fBparent\fR
233 .RS 4
234 Import the stored keys from the parent device by reading the database entry of the parent device. The value assigned to
235 \fBIMPORT{parent}\fR
236 is used as a filter of key names to import (with the same shell\-style pattern matching used for comparisons).
237 .RE
238 .RE
239 .IP "" 4
240 If no option is given, udev will choose between
241 \fBprogram\fR
242 and
243 \fBfile\fR
244 based on the executable bit of of the file permissions.
245 .RE
246 .PP
247 \fBWAIT_FOR_SYSFS\fR
248 .RS 4
249 Wait for the specified sysfs file of the device to be created. Can be used to fight against kernel sysfs timing issues.
250 .RE
251 .PP
252 \fBOPTIONS\fR
253 .RS 4
254 \fBlast_rule\fR
255 stops further rules application. No later rules will have any effect.
256 \fBignore_device\fR
257 will ignore this event completely.
258 \fBignore_remove\fR
259 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers.
260 \fBall_partitions\fR
261 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.
262 .RE
263 .PP
264 The
265 \fBNAME\fR,
266 \fBSYMLINK\fR,
267 \fBPROGRAM\fR,
268 \fBOWNER\fR,
269 \fBGROUP\fR
270 and
271 \fBRUN\fR
272 fields support simple printf\-like string substitutions. The
273 \fBRUN\fR
274 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:
275 .PP
276 \fB$kernel\fR, \fB%k\fR
277 .RS 4
278 The kernel name for this device.
279 .RE
280 .PP
281 \fB$number\fR, \fB%n\fR
282 .RS 4
283 The kernel number for this device. For example, 'sda3' has kernel number of '3'
284 .RE
285 .PP
286 \fB$devpath\fR, \fB%p\fR
287 .RS 4
288 The devpath of the device.
289 .RE
290 .PP
291 \fB$id\fR, \fB%b\fR
292 .RS 4
293 The name of the device matched while searching the devpath upwards for
294 \fBSUBSYSTEMS\fR,
295 \fBKERNELS\fR,
296 \fBDRIVERS\fR
297 and
298 \fBATTRS\fR.
299 .RE
300 .PP
301 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
302 .RS 4
303 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.
304 .RE
305 .PP
306 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
307 .RS 4
308 The value of an environment variable.
309 .RE
310 .PP
311 \fB$major\fR, \fB%M\fR
312 .RS 4
313 The kernel major number for the device.
314 .RE
315 .PP
316 \fB$minor\fR \fB%m\fR
317 .RS 4
318 The kernel minor number for the device.
319 .RE
320 .PP
321 \fB$result\fR, \fB%c\fR
322 .RS 4
323 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:
324 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted:
325 \fB%c{N+}\fR
326 .RE
327 .PP
328 \fB$parent\fR, \fB%P\fR
329 .RS 4
330 The node name of the parent device.
331 .RE
332 .PP
333 \fB$root\fR, \fB%r\fR
334 .RS 4
335 The udev_root value.
336 .RE
337 .PP
338 \fB$tempnode\fR, \fB%N\fR
339 .RS 4
340 The name of a created temporary device node to provide access to the device from a external program before the real node is created.
341 .RE
342 .PP
343 \fB%%\fR
344 .RS 4
345 The '%' character itself.
346 .RE
347 .PP
348 \fB$$\fR
349 .RS 4
350 The '$' character itself.
351 .RE
352 .PP
353 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
354 .SH "AUTHOR"
355 .PP
356 Written by Greg Kroah\-Hartman
357 <greg@kroah.com>
358 and Kay Sievers
359 <kay.sievers@vrfy.org>. With much help from Dan Stekloff
360 <dsteklof@us.ibm.com>
361 and many others.
362 .SH "SEE ALSO"
363 .PP
364 \fBudevd\fR(8),
365 \fBudevinfo\fR(8),
366 \fBudevmonitor\fR(8)