]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev.xml
rename udev_libc_wrapper -> udev_sysdeps
[thirdparty/systemd.git] / udev.xml
CommitLineData
7b86ada7
KS
1<?xml version='1.0'?>
2<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<article>
7b86ada7
KS
6 <section>
7 <title>udev</title>
8 <refentry>
9 <refentryinfo>
10 <title>udev</title>
11 <date>August 2005</date>
12 <productname>udev</productname>
13 </refentryinfo>
14
15 <refmeta>
16 <refentrytitle>udev</refentrytitle>
2c769419 17 <manvolnum>7</manvolnum>
660508cd 18 <refmiscinfo class="version"></refmiscinfo>
7b86ada7
KS
19 </refmeta>
20
21 <refnamediv>
22 <refname>udev</refname>
23 <refpurpose>dynamic device management</refpurpose>
24 </refnamediv>
25
26 <refsect1><title>DESCRIPTION</title>
27 <para>udev provides a dynamic device directory containing only the files for
28 actually present devices. It creates or removes device node files in the
29 <filename>/dev</filename> directory, or it renames network interfaces.</para>
30
31 <para>Usually udev runs as <citerefentry><refentrytitle>udevd</refentrytitle>
32 <manvolnum>8</manvolnum></citerefentry> and receives uevents directly from the
c082b99a 33 kernel if a device is added or removed form the system.</para>
7b86ada7
KS
34
35 <para>If udev receives a device event, it matches its configured rules
36 against the available device attributes provided in sysfs to identify the device.
37 Rules that match, may provide additional device information or specify a device
38 node name and multiple symlink names and instruct udev to run additional programs
39 as part of the device event handling.</para>
40 </refsect1>
41
42 <refsect1><title>CONFIGURATION</title>
43 <para>All udev configuration files are placed in <filename>/etc/udev/*</filename>.
309d6fd3 44 Every file consists of a set of lines of text. All empty lines or lines beginning
7b86ada7
KS
45 with '#' will be ignored.</para>
46
47 <refsect2><title>Configuration file</title>
48 <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>.
49 It consists of a set of variables allowing the user to override default udev values.
50 The following variables can be set:</para>
51 <variablelist>
52 <varlistentry>
53 <term><option>udev_root</option></term>
54 <listitem>
55 <para>Specifies where to place the device nodes in the filesystem.
56 The default value is <filename>/dev</filename>.</para>
57 </listitem>
58 </varlistentry>
59
7b86ada7
KS
60 <varlistentry>
61 <term><option>udev_rules</option></term>
62 <listitem>
63 <para>The name of the udev rules file or directory to look for files
64 with the suffix <filename>.rules</filename>. Multiple rule files are
65 read in lexical order. The default value is
66 <filename>/etc/udev/rules.d</filename>.</para>
67 </listitem>
68 </varlistentry>
69
70 <varlistentry>
71 <term><option>udev_log</option></term>
72 <listitem>
73 <para>The logging priority. Valid values are the numerical syslog priorities
74 or their textual representations: <option>err</option>, <option>info</option>
75 and <option>debug</option>.</para>
76 </listitem>
77 </varlistentry>
78 </variablelist>
79 </refsect2>
80
81 <refsect2><title>Rules files</title>
82 <para>The udev rules are read from the files located in the
83 <filename>/etc/udev/rules.d</filename> directory or at the location specified
84 value in the configuraton file. Every line in the rules file contains at least
85 one key value pair. There are two kind of keys, match and assignement keys.
86 If all match keys are matching against its value, the rule gets applied and the
87 assign keys get the specified value assigned. A matching rule may specify the
88 name of the device node, add a symlink pointing to the node, or run a specified
89 program as part of the event handling. If no matching rule is found, the default
90 device node name is used.</para>
91
92 <para>A rule may consists of a list of one or more key value pairs separated by
93 a comma. Each key has a distinct operation, depending on the used operator. Valid
94 operators are:</para>
95 <variablelist>
96 <varlistentry>
97 <term><option>==</option></term>
98 <listitem>
99 <para>Compare for equality.</para>
100 </listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><option>!=</option></term>
105 <listitem>
106 <para>Compare for non-equality.</para>
107 </listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><option>=</option></term>
112 <listitem>
226b9692 113 <para>Assign a value to a key. Keys that represent a list, are reset
7b86ada7
KS
114 and only this single value is assigned.</para>
115 </listitem>
116 </varlistentry>
117
118 <varlistentry>
119 <term><option>+=</option></term>
120 <listitem>
121 <para>Add the value to a key that holds a list of entries.</para>
122 </listitem>
123 </varlistentry>
124
125 <varlistentry>
126 <term><option>:=</option></term>
127 <listitem>
128 <para>Assign a value to a key finally; disallow any later changes,
129 which may be used to prevent changes by any later rules.</para>
130 </listitem>
131 </varlistentry>
132 </variablelist>
133
134 <para>The following key names can be used to match against device properties:</para>
135 <variablelist>
136 <varlistentry>
137 <term><option>ACTION</option></term>
138 <listitem>
03b24b71 139 <para>Match the name of the event action.</para>
7b86ada7
KS
140 </listitem>
141 </varlistentry>
142
143 <varlistentry>
144 <term><option>KERNEL</option></term>
145 <listitem>
03b24b71 146 <para>Match the name of the device.</para>
7b86ada7
KS
147 </listitem>
148 </varlistentry>
149
150 <varlistentry>
151 <term><option>DEVPATH</option></term>
152 <listitem>
03b24b71 153 <para>Match the devpath of the device.</para>
7b86ada7
KS
154 </listitem>
155 </varlistentry>
156
157 <varlistentry>
158 <term><option>SUBSYSTEM</option></term>
159 <listitem>
03b24b71 160 <para>Match the subsystem of the device.</para>
7b86ada7
KS
161 </listitem>
162 </varlistentry>
163
164 <varlistentry>
165 <term><option>BUS</option></term>
166 <listitem>
03b24b71 167 <para>Search the devpath upwards for a matching device subsystem name.</para>
7b86ada7
KS
168 </listitem>
169 </varlistentry>
170
171 <varlistentry>
172 <term><option>DRIVER</option></term>
173 <listitem>
03b24b71 174 <para>Search the devpath upwards for a matching device driver name.</para>
7b86ada7
KS
175 </listitem>
176 </varlistentry>
177
178 <varlistentry>
179 <term><option>ID</option></term>
180 <listitem>
03b24b71 181 <para>Search the devpath upwards for a matching device name.</para>
7b86ada7
KS
182 </listitem>
183 </varlistentry>
184
185 <varlistentry>
03b24b71 186 <term><option>SYSFS{<replaceable>filename</replaceable>}</option></term>
7b86ada7 187 <listitem>
03b24b71
KS
188 <para>Search the devpath upwards for a device with matching sysfs attribute values.
189 Up to five <option>SYSFS</option> keys can be specified per rule. All attributes
190 must match on the same device. Trailing whitespace in the attribute values is ignored,
191 if the specified match value does not contain trailing whitespace itself.</para>
7b86ada7
KS
192 </listitem>
193 </varlistentry>
194
195 <varlistentry>
03b24b71 196 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
7b86ada7 197 <listitem>
03b24b71
KS
198 <para>Match against the value of an environment variable. Up to five <option>ENV</option>
199 keys can be specified per rule. This key can also be used to export a variable to
200 the environment.</para>
7b86ada7
KS
201 </listitem>
202 </varlistentry>
203
204 <varlistentry>
205 <term><option>PROGRAM</option></term>
206 <listitem>
207 <para>Execute external program. The key is true, if the program returns
208 without exit code zero. The whole event environment is available to the
209 executed program. The program's output printed to stdout is available for
210 the RESULT key.</para>
211 </listitem>
212 </varlistentry>
213
214 <varlistentry>
215 <term><option>RESULT</option></term>
216 <listitem>
217 <para>Match the returned string of the last PROGRAM call. This key can
218 be used in the same or in any later rule after a PROGRAM call.</para>
219 </listitem>
220 </varlistentry>
221 </variablelist>
222
223 <para>Most of the fields support a shell style pattern matching. The following
224 pattern characters are supported:</para>
225 <variablelist>
226 <varlistentry>
227 <term><option>*</option></term>
228 <listitem>
229 <para>Matches zero, or any number of characters.</para>
230 </listitem>
231 </varlistentry>
232 <varlistentry>
233 <term><option>?</option></term>
234 <listitem>
235 <para>Matches any single character.</para>
236 </listitem>
237 </varlistentry>
238 <varlistentry>
239 <term><option>[]</option></term>
240 <listitem>
241 <para>Matches any single character specified within the brackets.
242 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
243 Ranges are also supported within this match with the '-' character.
244 For example, to match on the range of all digits, the pattern [0-9] would
245 be used. If the first character following the '[' is a '!', any characters
246 not enclosed are matched.</para>
247 </listitem>
248 </varlistentry>
249 </variablelist>
250
251 <para>The following keys can get values assigned:</para>
252 <variablelist>
253 <varlistentry>
254 <term><option>NAME</option></term>
255 <listitem>
fabd8709
KS
256 <para>The name of the node to be created, or the name the network interface
257 should be renamed to. Only one rule can set the node name, all later rules with
7b86ada7
KS
258 a NAME key will be ignored.</para>
259 </listitem>
260 </varlistentry>
261
262 <varlistentry>
263 <term><option>SYMLINK</option></term>
264 <listitem>
265 <para>The name of a symlink targeting the node. Every matching rule can add
266 this value to the list of symlinks to be created along with the device node.
267 Multiple symlinks may be specified by separating the names by the space
268 character.</para>
269 </listitem>
270 </varlistentry>
271
272 <varlistentry>
273 <term><option>OWNER, GROUP, MODE</option></term>
274 <listitem>
fabd8709 275 <para>The permissions for the device node. Every specified value overwrites
7b86ada7
KS
276 the compiled-in default value.</para>
277 </listitem>
278 </varlistentry>
279
280 <varlistentry>
281 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
282 <listitem>
03b24b71
KS
283 <para>Export a variable to the environment. This key can also be used to match
284 against an environment variable.</para>
7b86ada7
KS
285 </listitem>
286 </varlistentry>
287
288 <varlistentry>
289 <term><option>RUN</option></term>
290 <listitem>
291 <para>Add a program to the list of programs to be executed for a specific
727f3fb0
KS
292 device. This can only be used for very short running tasks. Running an
293 event process for a long period of time may block all further events for
294 this or a dependent device. Long running tasks need to be immediately
295 detached from the event process itself.</para>
7b86ada7
KS
296 </listitem>
297 </varlistentry>
298
299 <varlistentry>
300 <term><option>LABEL</option></term>
301 <listitem>
302 <para>Named label where a GOTO can jump to.</para>
303 </listitem>
304 </varlistentry>
305
306 <varlistentry>
307 <term><option>GOTO</option></term>
308 <listitem>
a2a7f7d7 309 <para>Jumps to the next LABEL with a matching name</para>
7b86ada7
KS
310 </listitem>
311 </varlistentry>
312
313 <varlistentry>
314 <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
315 <listitem>
03b24b71 316 <para>Import the printed result or the value of a file in environment key
7b86ada7
KS
317 format into the event environment. <option>program</option> will execute an
318 external program and read its output. <option>file</option> will inport a
319 text file. If no option is given, udev will determine it from the executable
320 bit of of the file permissions.</para>
321 </listitem>
322 </varlistentry>
323
324 <varlistentry>
325 <term><option>WAIT_FOR_SYSFS</option></term>
326 <listitem>
03b24b71
KS
327 <para>Wait for the specified sysfs file of the device to be created. Can be used
328 to fight against kernel sysfs timing issues.</para>
7b86ada7
KS
329 </listitem>
330 </varlistentry>
331
332 <varlistentry>
333 <term><option>OPTIONS</option></term>
334 <listitem>
335 <para><option>last_rule</option> stops further rules application. No later rules
336 will have any effect.
337 <option>ignore_device</option> will ignore this event completely.
338 <option>ignore_remove</option> will ignore any later remove event for this
339 device. This may be useful as a workaround for broken device drivers.
226b9692
KS
340 <option>all_partitions</option> will create the device nodes for all available
341 partitions of a block device. This may be useful for removable media devices where
342 media changes are not detected.</para>
7b86ada7
KS
343 </listitem>
344 </varlistentry>
345 </variablelist>
346
347 <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
864412e0
AB
348 <option>OWNER</option>, <option>GROUP</option> and <option>RUN</option>
349 fields support simple printf-like string substitutions. The <option>RUN</option>
350 format chars gets applied after all rules have been processed, right before the program
351 is executed. It allows the use of the complete environment set by earlier matching
352 rules. For all other fields, substitutions are applied while the individual rule is
353 being processed. The available substitutions are:</para>
7b86ada7
KS
354 <variablelist>
355 <varlistentry>
03b24b71 356 <term><option>$kernel</option>, <option>%k</option></term>
7b86ada7
KS
357 <listitem>
358 <para>The kernel name for this device.</para>
359 </listitem>
360 </varlistentry>
361
7b86ada7 362 <varlistentry>
03b24b71 363 <term><option>$number</option>, <option>%n</option></term>
7b86ada7
KS
364 <listitem>
365 <para>The kernel number for this device. For example, 'sda3' has
366 kernel number of '3'</para>
367 </listitem>
368 </varlistentry>
369
370 <varlistentry>
03b24b71 371 <term><option>$devpath</option>, <option>%p</option></term>
7b86ada7
KS
372 <listitem>
373 <para>The devpath of the device.</para>
374 </listitem>
375 </varlistentry>
376
377 <varlistentry>
03b24b71
KS
378 <term><option>$id</option>, <option>%b</option></term>
379 <listitem>
380 <para>The name of the device matched while searching the devpath upwards for
381 <option>BUS</option>, <option>ID</option> <option>DRIVER</option> and <option>SYSFS</option>.
382 </para>
383 </listitem>
384 </varlistentry>
385
386 <varlistentry>
387 <term><option>$sysfs{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
7b86ada7 388 <listitem>
03b24b71 389 <para>The value of a sysfs attribute found at the current or a parent device.</para>
7b86ada7
KS
390 </listitem>
391 </varlistentry>
392
393 <varlistentry>
03b24b71 394 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
7b86ada7
KS
395 <listitem>
396 <para>The value of an environment variable.</para>
397 </listitem>
398 </varlistentry>
399
400 <varlistentry>
03b24b71 401 <term><option>$major</option>, <option>%M</option></term>
7b86ada7
KS
402 <listitem>
403 <para>The kernel major number for the device.</para>
404 </listitem>
405 </varlistentry>
406
407 <varlistentry>
03b24b71 408 <term><option>$minor</option> <option>%m</option></term>
7b86ada7
KS
409 <listitem>
410 <para>The kernel minor number for the device.</para>
411 </listitem>
412 </varlistentry>
413
414 <varlistentry>
03b24b71 415 <term><option>$result</option>, <option>%c</option></term>
7b86ada7
KS
416 <listitem>
417 <para>The string returned by the external program requested with PROGRAM.
418 A single part of the string, separated by a space character may be selected
419 by specifying the part number as an attribute: <option>%c{N}</option>.
420 If the number is followed by the '+' char this part plus all remaining parts
421 of the result string are substituted: <option>%c{N+}</option></para>
422 </listitem>
423 </varlistentry>
424
7b86ada7 425 <varlistentry>
03b24b71 426 <term><option>$parent</option>, <option>%P</option></term>
7b86ada7
KS
427 <listitem>
428 <para>The node name of the parent device.</para>
429 </listitem>
430 </varlistentry>
431
432 <varlistentry>
03b24b71 433 <term><option>$root</option>, <option>%r</option></term>
7b86ada7
KS
434 <listitem>
435 <para>The udev_root value.</para>
436 </listitem>
437 </varlistentry>
438
439 <varlistentry>
03b24b71 440 <term><option>$tempnode</option>, <option>%N</option></term>
7b86ada7
KS
441 <listitem>
442 <para>The name of a created temporary device node to provide access to
443 the device from a external program before the real node is created.</para>
444 </listitem>
445 </varlistentry>
446
447 <varlistentry>
448 <term><option>%%</option></term>
449 <listitem>
450 <para>The '%' character itself.</para>
451 </listitem>
452 </varlistentry>
453
454 <varlistentry>
455 <term><option>$$</option></term>
456 <listitem>
457 <para>The '$' character itself.</para>
458 </listitem>
459 </varlistentry>
460 </variablelist>
461 <para>The count of characters to be substituted may be limited by specifying
462 the format length value. For example, '%3s{file}' will only
463 insert the first three characters of the sysfs attribute</para>
464 </refsect2>
465 </refsect1>
466
7b86ada7
KS
467 <refsect1><title>AUTHOR</title>
468 <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
469 Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
470 Dan Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
471 </refsect1>
472
473 <refsect1>
474 <title>SEE ALSO</title>
475 <para><citerefentry>
2c769419 476 <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
7b86ada7
KS
477 </citerefentry>,
478 <citerefentry>
479 <refentrytitle>udevinfo</refentrytitle><manvolnum>8</manvolnum>
480 </citerefentry>,
7b86ada7
KS
481 <citerefentry>
482 <refentrytitle>udevmonitor</refentrytitle><manvolnum>8</manvolnum>
483 </citerefentry></para>
484 </refsect1>
485 </refentry>
486 </section>
487</article>