]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev.xml
Makefile: check for missing ChangeLog or RELEASE-NOTES at release
[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
7f723806 33 kernel if a device is added or removed from 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.
7f723806 37 Rules that match may provide additional device information or specify a device
7b86ada7
KS
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
33a570f3
MB
84 value in the configuration file. Every line in the rules file contains at least
85 one key value pair. There are two kind of keys, match and assignment keys.
7b86ada7 86 If all match keys are matching against its value, the rule gets applied and the
e7c39acb
KS
87 assign keys get the specified value assigned.</para>
88
89 <para>A matching rule may specify the name of the device node, add a symlink
90 pointing to the node, or run a specified program as part of the event handling.
91 If no matching rule is found, the default device node name is used.</para>
7b86ada7 92
7f723806 93 <para>A rule may consist of a list of one or more key value pairs separated by
7b86ada7
KS
94 a comma. Each key has a distinct operation, depending on the used operator. Valid
95 operators are:</para>
96 <variablelist>
97 <varlistentry>
98 <term><option>==</option></term>
99 <listitem>
100 <para>Compare for equality.</para>
101 </listitem>
102 </varlistentry>
103
104 <varlistentry>
105 <term><option>!=</option></term>
106 <listitem>
107 <para>Compare for non-equality.</para>
108 </listitem>
109 </varlistentry>
110
111 <varlistentry>
112 <term><option>=</option></term>
113 <listitem>
226b9692 114 <para>Assign a value to a key. Keys that represent a list, are reset
7b86ada7
KS
115 and only this single value is assigned.</para>
116 </listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><option>+=</option></term>
121 <listitem>
122 <para>Add the value to a key that holds a list of entries.</para>
123 </listitem>
124 </varlistentry>
125
126 <varlistentry>
127 <term><option>:=</option></term>
128 <listitem>
129 <para>Assign a value to a key finally; disallow any later changes,
130 which may be used to prevent changes by any later rules.</para>
131 </listitem>
132 </varlistentry>
133 </variablelist>
134
e7c39acb
KS
135 <para>The following key names can be used to match against device properties.
136 Some of the keys also match against properties of the parent devices in sysfs,
137 not only the device that has generated the event. If multiple keys that match
138 a parent device are specified in a single rule, all these keys must match at
139 one and the same parent device.</para>
7b86ada7
KS
140 <variablelist>
141 <varlistentry>
142 <term><option>ACTION</option></term>
143 <listitem>
03b24b71 144 <para>Match the name of the event action.</para>
7b86ada7
KS
145 </listitem>
146 </varlistentry>
147
148 <varlistentry>
95776dc6 149 <term><option>DEVPATH</option></term>
7b86ada7 150 <listitem>
95776dc6 151 <para>Match the devpath of the event device.</para>
7b86ada7
KS
152 </listitem>
153 </varlistentry>
154
155 <varlistentry>
95776dc6 156 <term><option>KERNEL</option></term>
7b86ada7 157 <listitem>
95776dc6 158 <para>Match the name of the event device.</para>
7b86ada7
KS
159 </listitem>
160 </varlistentry>
161
162 <varlistentry>
163 <term><option>SUBSYSTEM</option></term>
164 <listitem>
95776dc6
KS
165 <para>Match the subsystem of the event device.</para>
166 </listitem>
167 </varlistentry>
95776dc6
KS
168 <varlistentry>
169 <term><option>DRIVER</option></term>
170 <listitem>
e7c39acb
KS
171 <para>Match the driver name of the event device. Only set for devices
172 which are bound to a driver at the time the event is generated.</para>
95776dc6
KS
173 </listitem>
174 </varlistentry>
95776dc6
KS
175 <varlistentry>
176 <term><option>ATTR{<replaceable>filename</replaceable>}</option></term>
177 <listitem>
178 <para>Match sysfs attribute values of the event device. Up to five
179 <option>ATTR</option> keys can be specified per rule. Trailing
180 whitespace in the attribute values is ignored, if the specified match
02adc0cb
KS
181 value does not contain trailing whitespace itself. Depending on the type
182 of operator, this key is also used to set the value of a sysfs attribute.
183 </para>
7b86ada7
KS
184 </listitem>
185 </varlistentry>
186
187 <varlistentry>
95776dc6 188 <term><option>KERNELS</option></term>
7b86ada7 189 <listitem>
95776dc6 190 <para>Search the devpath upwards for a matching device name.</para>
7b86ada7
KS
191 </listitem>
192 </varlistentry>
193
194 <varlistentry>
95776dc6 195 <term><option>SUBSYSTEMS</option></term>
7b86ada7 196 <listitem>
95776dc6 197 <para>Search the devpath upwards for a matching device subsystem name.</para>
7b86ada7
KS
198 </listitem>
199 </varlistentry>
200
201 <varlistentry>
95776dc6 202 <term><option>DRIVERS</option></term>
7b86ada7 203 <listitem>
95776dc6 204 <para>Search the devpath upwards for a matching device driver name.</para>
7b86ada7
KS
205 </listitem>
206 </varlistentry>
207
208 <varlistentry>
95776dc6 209 <term><option>ATTRS{<replaceable>filename</replaceable>}</option></term>
7b86ada7 210 <listitem>
03b24b71 211 <para>Search the devpath upwards for a device with matching sysfs attribute values.
e7c39acb 212 Up to five <option>ATTRS</option> keys can be specified per rule, but all of them
03b24b71
KS
213 must match on the same device. Trailing whitespace in the attribute values is ignored,
214 if the specified match value does not contain trailing whitespace itself.</para>
7b86ada7
KS
215 </listitem>
216 </varlistentry>
217
218 <varlistentry>
03b24b71 219 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
7b86ada7 220 <listitem>
03b24b71 221 <para>Match against the value of an environment variable. Up to five <option>ENV</option>
02adc0cb
KS
222 keys can be specified per rule. Depending on the type of operator, this key is also used
223 to export a variable to the environment.</para>
7b86ada7
KS
224 </listitem>
225 </varlistentry>
226
953249a3
KS
227 <varlistentry>
228 <term><option>TEST{<replaceable>octal mode mask</replaceable>}</option></term>
229 <listitem>
230 <para>Test the existence of a file. An octal mode mask can be specified
231 if needed.</para>
232 </listitem>
233 </varlistentry>
234
7b86ada7
KS
235 <varlistentry>
236 <term><option>PROGRAM</option></term>
237 <listitem>
238 <para>Execute external program. The key is true, if the program returns
684e935f
KS
239 with exit code zero. The whole event environment is available to the
240 executed program. The program's output printed to stdout, is available in
7b86ada7
KS
241 the RESULT key.</para>
242 </listitem>
243 </varlistentry>
244
245 <varlistentry>
246 <term><option>RESULT</option></term>
247 <listitem>
248 <para>Match the returned string of the last PROGRAM call. This key can
249 be used in the same or in any later rule after a PROGRAM call.</para>
250 </listitem>
251 </varlistentry>
252 </variablelist>
253
254 <para>Most of the fields support a shell style pattern matching. The following
255 pattern characters are supported:</para>
256 <variablelist>
257 <varlistentry>
258 <term><option>*</option></term>
259 <listitem>
260 <para>Matches zero, or any number of characters.</para>
261 </listitem>
262 </varlistentry>
263 <varlistentry>
264 <term><option>?</option></term>
265 <listitem>
266 <para>Matches any single character.</para>
267 </listitem>
268 </varlistentry>
269 <varlistentry>
270 <term><option>[]</option></term>
271 <listitem>
33a570f3 272 <para>Matches any single character specified within the brackets. For
7b86ada7
KS
273 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
274 Ranges are also supported within this match with the '-' character.
275 For example, to match on the range of all digits, the pattern [0-9] would
276 be used. If the first character following the '[' is a '!', any characters
277 not enclosed are matched.</para>
278 </listitem>
279 </varlistentry>
280 </variablelist>
281
282 <para>The following keys can get values assigned:</para>
283 <variablelist>
284 <varlistentry>
285 <term><option>NAME</option></term>
286 <listitem>
fabd8709
KS
287 <para>The name of the node to be created, or the name the network interface
288 should be renamed to. Only one rule can set the node name, all later rules with
7b86ada7
KS
289 a NAME key will be ignored.</para>
290 </listitem>
291 </varlistentry>
292
293 <varlistentry>
294 <term><option>SYMLINK</option></term>
295 <listitem>
296 <para>The name of a symlink targeting the node. Every matching rule can add
297 this value to the list of symlinks to be created along with the device node.
298 Multiple symlinks may be specified by separating the names by the space
299 character.</para>
300 </listitem>
301 </varlistentry>
302
303 <varlistentry>
304 <term><option>OWNER, GROUP, MODE</option></term>
305 <listitem>
fabd8709 306 <para>The permissions for the device node. Every specified value overwrites
7b86ada7
KS
307 the compiled-in default value.</para>
308 </listitem>
309 </varlistentry>
310
02adc0cb
KS
311 <varlistentry>
312 <term><option>ATTR{<replaceable>key</replaceable>}</option></term>
313 <listitem>
314 <para>The value that should be written to a sysfs attribute of the
315 event device. Depending on the type of operator, this key is also
316 used to match against the value of a sysfs attribute.</para>
317 </listitem>
318 </varlistentry>
319
7b86ada7
KS
320 <varlistentry>
321 <term><option>ENV{<replaceable>key</replaceable>}</option></term>
322 <listitem>
02adc0cb
KS
323 <para>Export a variable to the environment. Depending on the type of operator,
324 this key is also to match against an environment variable.</para>
7b86ada7
KS
325 </listitem>
326 </varlistentry>
327
328 <varlistentry>
329 <term><option>RUN</option></term>
330 <listitem>
331 <para>Add a program to the list of programs to be executed for a specific
727f3fb0
KS
332 device. This can only be used for very short running tasks. Running an
333 event process for a long period of time may block all further events for
334 this or a dependent device. Long running tasks need to be immediately
335 detached from the event process itself.</para>
7b86ada7
KS
336 </listitem>
337 </varlistentry>
338
339 <varlistentry>
340 <term><option>LABEL</option></term>
341 <listitem>
342 <para>Named label where a GOTO can jump to.</para>
343 </listitem>
344 </varlistentry>
345
346 <varlistentry>
347 <term><option>GOTO</option></term>
348 <listitem>
a2a7f7d7 349 <para>Jumps to the next LABEL with a matching name</para>
7b86ada7
KS
350 </listitem>
351 </varlistentry>
352
353 <varlistentry>
354 <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
355 <listitem>
53fc01d5
BK
356 <para>Import a set of variables into the event environment,
357 depending on <replaceable>type</replaceable>:</para>
358 <variablelist>
359 <varlistentry>
360 <term><option>program</option></term>
361 <listitem>
362 <para>Execute an external program specified as the assigned value and
363 import its output, which must be in environment key format.</para>
364 </listitem>
365 </varlistentry>
366 <varlistentry>
367 <term><option>file</option></term>
368 <listitem>
369 <para>Import a text file specified as the assigned value, which must be in
370 environment key format.</para>
371 </listitem>
372 </varlistentry>
373 <varlistentry>
374 <term><option>parent</option></term>
375 <listitem>
376 <para>Import the stored keys from the parent device by reading
377 the database entry of the parent device. The value assigned to
378 <option>IMPORT{parent}</option> is used as a filter of key names
379 to import (with the same shell-style pattern matching used for
380 comparisons).</para>
381 </listitem>
382 </varlistentry>
383 </variablelist>
384 <para>If no option is given, udev will choose between <option>program</option>
7f723806 385 and <option>file</option> based on the executable bit of the file
53fc01d5 386 permissions.</para>
7b86ada7
KS
387 </listitem>
388 </varlistentry>
389
390 <varlistentry>
391 <term><option>WAIT_FOR_SYSFS</option></term>
392 <listitem>
03b24b71
KS
393 <para>Wait for the specified sysfs file of the device to be created. Can be used
394 to fight against kernel sysfs timing issues.</para>
7b86ada7
KS
395 </listitem>
396 </varlistentry>
397
398 <varlistentry>
399 <term><option>OPTIONS</option></term>
400 <listitem>
7a17ca7e
KS
401 <para>Rule and device options:</para>
402 <variablelist>
403 <varlistentry>
404 <term><option>last_rule</option></term>
405 <listitem>
406 <para>Stops further rules application. No later rules will have
407 any effect.</para>
408 </listitem>
409 </varlistentry>
410 <varlistentry>
411 <term><option>ignore_device</option></term>
412 <listitem>
413 <para>Ignore this event completely.</para>
414 </listitem>
415 </varlistentry>
416 <varlistentry>
417 <term><option>ignore_remove</option></term>
418 <listitem>
419 <para>Ignore any later remove event for this device. This may be useful
420 as a workaround for broken device drivers.</para>
421 </listitem>
422 </varlistentry>
423 <varlistentry>
424 <term><option>link_priority=<replaceable>value</replaceable></option></term>
425 <listitem>
426 <para>Specify the priority of the created symlinks. Devices with higher
427 priorities overwrite existing symlinks of other devices.</para>
428 </listitem>
429 </varlistentry>
430 <varlistentry>
431 <term><option>all_partitions</option></term>
432 <listitem>
433 <para>Create the device nodes for all available partitions of a block device.
434 This may be useful for removable media devices where media changes are not
435 detected.</para>
436 </listitem>
437 </varlistentry>
438 </variablelist>
7b86ada7
KS
439 </listitem>
440 </varlistentry>
441 </variablelist>
442
443 <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
864412e0
AB
444 <option>OWNER</option>, <option>GROUP</option> and <option>RUN</option>
445 fields support simple printf-like string substitutions. The <option>RUN</option>
446 format chars gets applied after all rules have been processed, right before the program
447 is executed. It allows the use of the complete environment set by earlier matching
448 rules. For all other fields, substitutions are applied while the individual rule is
449 being processed. The available substitutions are:</para>
7b86ada7
KS
450 <variablelist>
451 <varlistentry>
03b24b71 452 <term><option>$kernel</option>, <option>%k</option></term>
7b86ada7
KS
453 <listitem>
454 <para>The kernel name for this device.</para>
455 </listitem>
456 </varlistentry>
457
7b86ada7 458 <varlistentry>
03b24b71 459 <term><option>$number</option>, <option>%n</option></term>
7b86ada7
KS
460 <listitem>
461 <para>The kernel number for this device. For example, 'sda3' has
462 kernel number of '3'</para>
463 </listitem>
464 </varlistentry>
465
466 <varlistentry>
03b24b71 467 <term><option>$devpath</option>, <option>%p</option></term>
7b86ada7
KS
468 <listitem>
469 <para>The devpath of the device.</para>
470 </listitem>
471 </varlistentry>
472
473 <varlistentry>
03b24b71
KS
474 <term><option>$id</option>, <option>%b</option></term>
475 <listitem>
476 <para>The name of the device matched while searching the devpath upwards for
4febf7f0 477 <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
03b24b71
KS
478 </para>
479 </listitem>
480 </varlistentry>
481
482 <varlistentry>
95776dc6 483 <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
7b86ada7 484 <listitem>
4febf7f0
KS
485 <para>The value of a sysfs attribute found at the device, where
486 all keys of the rule have matched. If the matching device does not have
487 such an attribute, all devices along the chain of parents are searched
488 for a matching attribute.
489 If the attribute is a symlink, the last element of the symlink target is
490 returned as the value.</para>
7b86ada7
KS
491 </listitem>
492 </varlistentry>
493
494 <varlistentry>
03b24b71 495 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
7b86ada7
KS
496 <listitem>
497 <para>The value of an environment variable.</para>
498 </listitem>
499 </varlistentry>
500
501 <varlistentry>
03b24b71 502 <term><option>$major</option>, <option>%M</option></term>
7b86ada7
KS
503 <listitem>
504 <para>The kernel major number for the device.</para>
505 </listitem>
506 </varlistentry>
507
508 <varlistentry>
7f723806 509 <term><option>$minor</option>, <option>%m</option></term>
7b86ada7
KS
510 <listitem>
511 <para>The kernel minor number for the device.</para>
512 </listitem>
513 </varlistentry>
514
515 <varlistentry>
03b24b71 516 <term><option>$result</option>, <option>%c</option></term>
7b86ada7
KS
517 <listitem>
518 <para>The string returned by the external program requested with PROGRAM.
519 A single part of the string, separated by a space character may be selected
520 by specifying the part number as an attribute: <option>%c{N}</option>.
521 If the number is followed by the '+' char this part plus all remaining parts
522 of the result string are substituted: <option>%c{N+}</option></para>
523 </listitem>
524 </varlistentry>
525
7b86ada7 526 <varlistentry>
03b24b71 527 <term><option>$parent</option>, <option>%P</option></term>
7b86ada7
KS
528 <listitem>
529 <para>The node name of the parent device.</para>
530 </listitem>
531 </varlistentry>
532
533 <varlistentry>
03b24b71 534 <term><option>$root</option>, <option>%r</option></term>
7b86ada7
KS
535 <listitem>
536 <para>The udev_root value.</para>
537 </listitem>
538 </varlistentry>
539
5e9eb88f
KS
540 <varlistentry>
541 <term><option>$sys</option>, <option>%S</option></term>
542 <listitem>
543 <para>The sysfs mount point.</para>
544 </listitem>
545 </varlistentry>
546
7b86ada7 547 <varlistentry>
03b24b71 548 <term><option>$tempnode</option>, <option>%N</option></term>
7b86ada7
KS
549 <listitem>
550 <para>The name of a created temporary device node to provide access to
551 the device from a external program before the real node is created.</para>
552 </listitem>
553 </varlistentry>
554
555 <varlistentry>
556 <term><option>%%</option></term>
557 <listitem>
558 <para>The '%' character itself.</para>
559 </listitem>
560 </varlistentry>
561
562 <varlistentry>
563 <term><option>$$</option></term>
564 <listitem>
565 <para>The '$' character itself.</para>
566 </listitem>
567 </varlistentry>
568 </variablelist>
569 <para>The count of characters to be substituted may be limited by specifying
570 the format length value. For example, '%3s{file}' will only
571 insert the first three characters of the sysfs attribute</para>
572 </refsect2>
573 </refsect1>
574
7b86ada7
KS
575 <refsect1><title>AUTHOR</title>
576 <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
577 Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
578 Dan Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
579 </refsect1>
580
581 <refsect1>
582 <title>SEE ALSO</title>
583 <para><citerefentry>
2c769419 584 <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
7b86ada7
KS
585 </citerefentry>,
586 <citerefentry>
587 <refentrytitle>udevinfo</refentrytitle><manvolnum>8</manvolnum>
588 </citerefentry>,
7b86ada7
KS
589 <citerefentry>
590 <refentrytitle>udevmonitor</refentrytitle><manvolnum>8</manvolnum>
591 </citerefentry></para>
592 </refsect1>
593 </refentry>
594 </section>
595</article>