chiark / gitweb /
man: fix unused, inaccurate metadata
[elogind.git] / udev / udev.xml
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>
6   <section>
7     <title>udev</title>
8     <refentry>
9       <refentryinfo>
10         <title>udev</title>
11         <productname>udev</productname>
12       </refentryinfo>
13
14       <refmeta>
15         <refentrytitle>udev</refentrytitle>
16         <manvolnum>7</manvolnum>
17       </refmeta>
18
19       <refnamediv>
20         <refname>udev</refname>
21         <refpurpose>dynamic device management</refpurpose>
22       </refnamediv>
23
24       <refsect1><title>DESCRIPTION</title>
25         <para>udev provides a dynamic device directory containing only the files for
26         actually present devices. It creates or removes device node files in the
27         <filename>/dev</filename> directory, or it renames network interfaces.</para>
28
29         <para>Usually udev runs as <citerefentry><refentrytitle>udevd</refentrytitle>
30         <manvolnum>8</manvolnum></citerefentry> and receives uevents directly from the
31         kernel if a device is added or removed from the system.</para>
32
33         <para>If udev receives a device event, it matches its configured rules
34         against the available device attributes provided in sysfs to identify the device.
35         Rules that match may provide additional device information or specify a device
36         node name and multiple symlink names and instruct udev to run additional programs
37         as part of the device event handling.</para>
38       </refsect1>
39
40       <refsect1><title>CONFIGURATION</title>
41         <para>udev configuration files are placed in <filename>/etc/udev/</filename>
42         and <filename>/lib/udev/</filename>. All empty lines, or lines beginning with
43         '#' will be ignored.</para>
44
45         <refsect2><title>Configuration file</title>
46           <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>.
47           It consists of a set of variables allowing the user to override default udev values.
48           The following variables can be set:</para>
49           <variablelist>
50             <varlistentry>
51               <term><option>udev_root</option></term>
52               <listitem>
53                 <para>Specifies where to place the device nodes in the filesystem.
54                 The default value is <filename>/dev</filename>.</para>
55               </listitem>
56             </varlistentry>
57
58             <varlistentry>
59               <term><option>udev_log</option></term>
60               <listitem>
61                 <para>The logging priority. Valid values are the numerical syslog priorities
62                 or their textual representations: <option>err</option>, <option>info</option>
63                 and <option>debug</option>.</para>
64               </listitem>
65             </varlistentry>
66           </variablelist>
67         </refsect2>
68
69         <refsect2><title>Rules files</title>
70           <para>The udev rules are read from the files located in the
71           default rules directory <filename>/lib/udev/rules.d/</filename>,
72           the custom rules directory <filename>/etc/udev/rules.d/</filename>
73           and the temporary rules directory <filename>/dev/.udev/rules.d/</filename>.
74           All rule files are sorted and processed in lexical order, regardless
75           in which of these directories they live.</para>
76
77           <para>Rule files are required to have a unique name, duplicate file names
78           are ignored. Files in <filename>/etc/udev/rules.d/</filename> have precedence
79           over files with the same name in <filename>/lib/udev/rules.d/</filename>. This
80           can be used to ignore a default rules file if needed.</para>
81
82           <para>Every line in the rules file contains at least one key value pair.
83           There are two kind of keys, match and assignment keys.
84           If all match keys are matching against its value, the rule gets applied and the
85           assign keys get the specified value assigned.</para>
86
87           <para>A matching rule may specify the name of the device node, add a symlink
88           pointing to the node, or run a specified program as part of the event handling.
89           If no matching rule is found, the default device node name is used.</para>
90
91           <para>A rule consists of a list of one or more key value pairs separated by
92           a comma. Each key has a distinct operation, depending on the used operator. Valid
93           operators are:</para>
94           <variablelist>
95             <varlistentry>
96               <term><option>==</option></term>
97               <listitem>
98                 <para>Compare for equality.</para>
99               </listitem>
100             </varlistentry>
101
102             <varlistentry>
103               <term><option>!=</option></term>
104               <listitem>
105                 <para>Compare for inequality.</para>
106               </listitem>
107             </varlistentry>
108
109             <varlistentry>
110               <term><option>=</option></term>
111               <listitem>
112                 <para>Assign a value to a key. Keys that represent a list, are reset
113                 and only this single value is assigned.</para>
114               </listitem>
115             </varlistentry>
116
117             <varlistentry>
118               <term><option>+=</option></term>
119               <listitem>
120                 <para>Add the value to a key that holds a list of entries.</para>
121               </listitem>
122             </varlistentry>
123
124             <varlistentry>
125               <term><option>:=</option></term>
126               <listitem>
127                 <para>Assign  a  value  to  a key finally; disallow any later changes,
128                 which may be used to prevent changes by any later rules.</para>
129               </listitem>
130             </varlistentry>
131           </variablelist>
132
133           <para>The following key names can be used to match against device properties.
134           Some of the keys also match against properties of the parent devices in sysfs,
135           not only the device that has generated the event. If multiple keys that match
136           a parent device are specified in a single rule, all these keys must match at
137           one and the same parent device.</para>
138           <variablelist>
139             <varlistentry>
140               <term><option>ACTION</option></term>
141               <listitem>
142                 <para>Match the name of the event action.</para>
143               </listitem>
144             </varlistentry>
145
146             <varlistentry>
147               <term><option>DEVPATH</option></term>
148               <listitem>
149                 <para>Match the devpath of the event device.</para>
150               </listitem>
151             </varlistentry>
152
153             <varlistentry>
154               <term><option>KERNEL</option></term>
155               <listitem>
156                 <para>Match the name of the event device.</para>
157               </listitem>
158             </varlistentry>
159
160             <varlistentry>
161               <term><option>NAME</option></term>
162               <listitem>
163                 <para>Match the name of the node or network interface. It can
164                 be used once the NAME key has been set in one of the preceding
165                 rules.</para>
166               </listitem>
167             </varlistentry>
168
169             <varlistentry>
170               <term><option>SUBSYSTEM</option></term>
171               <listitem>
172                 <para>Match the subsystem of the event device.</para>
173               </listitem>
174             </varlistentry>
175             <varlistentry>
176               <term><option>DRIVER</option></term>
177               <listitem>
178                 <para>Match the driver name of the event device. Only set for devices
179                 which are bound to a driver at the time the event is generated.</para>
180               </listitem>
181             </varlistentry>
182             <varlistentry>
183               <term><option>ATTR{<replaceable>filename</replaceable>}</option></term>
184               <listitem>
185                 <para>Match sysfs attribute values of the event device. Trailing
186                 whitespace in the attribute values is ignored, if the specified match
187                 value does not contain trailing whitespace itself.
188                 </para>
189               </listitem>
190             </varlistentry>
191
192             <varlistentry>
193               <term><option>KERNELS</option></term>
194               <listitem>
195                 <para>Search the devpath upwards for a matching device name.</para>
196               </listitem>
197             </varlistentry>
198
199             <varlistentry>
200               <term><option>SUBSYSTEMS</option></term>
201               <listitem>
202                 <para>Search the devpath upwards for a matching device subsystem name.</para>
203               </listitem>
204             </varlistentry>
205
206             <varlistentry>
207               <term><option>DRIVERS</option></term>
208               <listitem>
209                 <para>Search the devpath upwards for a matching device driver name.</para>
210               </listitem>
211             </varlistentry>
212
213             <varlistentry>
214               <term><option>ATTRS{<replaceable>filename</replaceable>}</option></term>
215               <listitem>
216                 <para>Search the devpath upwards for a device with matching sysfs attribute values.
217                 If multiple <option>ATTRS</option> matches are specified, all of them
218                 must match on the same device. Trailing whitespace in the attribute values is ignored,
219                 if the specified match value does not contain trailing whitespace itself.</para>
220               </listitem>
221             </varlistentry>
222
223             <varlistentry>
224               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
225               <listitem>
226                 <para>Match against a device property value.</para>
227               </listitem>
228             </varlistentry>
229
230             <varlistentry>
231               <term><option>TEST{<replaceable>octal mode mask</replaceable>}</option></term>
232               <listitem>
233                 <para>Test the existence of a file. An octal mode mask can be specified
234                 if needed.</para>
235               </listitem>
236             </varlistentry>
237
238             <varlistentry>
239               <term><option>PROGRAM</option></term>
240               <listitem>
241                 <para>Execute a program. The key is true, if the program returns
242                 successfully. The device properties are made available to the
243                 executed program in the environment. The program's output printed to
244                 stdout, is available in the RESULT key.</para>
245               </listitem>
246             </varlistentry>
247
248             <varlistentry>
249               <term><option>RESULT</option></term>
250               <listitem>
251                 <para>Match the returned string of the last PROGRAM call. This key can
252                 be used in the same or in any later rule after a PROGRAM call.</para>
253               </listitem>
254             </varlistentry>
255           </variablelist>
256
257           <para>Most of the fields support a shell style pattern matching. The following
258           pattern characters are supported:</para>
259           <variablelist>
260             <varlistentry>
261               <term><option>*</option></term>
262               <listitem>
263                 <para>Matches zero, or any number of characters.</para>
264               </listitem>
265             </varlistentry>
266             <varlistentry>
267               <term><option>?</option></term>
268               <listitem>
269                 <para>Matches any single character.</para>
270               </listitem>
271             </varlistentry>
272             <varlistentry>
273               <term><option>[]</option></term>
274               <listitem>
275                 <para>Matches any single character specified within the brackets. For
276                 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
277                 Ranges are also supported within this match with the '-' character.
278                 For example, to match on the range of all digits, the pattern [0-9] would
279                 be used. If the first character following the '[' is a '!', any characters
280                 not enclosed are matched.</para>
281               </listitem>
282             </varlistentry>
283           </variablelist>
284
285           <para>The following keys can get values assigned:</para>
286           <variablelist>
287             <varlistentry>
288               <term><option>NAME</option></term>
289               <listitem>
290                 <para>The name of the node to be created, or the name the network interface
291                 should be renamed to.</para>
292               </listitem>
293             </varlistentry>
294
295             <varlistentry>
296               <term><option>SYMLINK</option></term>
297               <listitem>
298                 <para>The name of a symlink targeting the node. Every matching rule can add
299                 this value to the list of symlinks to be created along with the device  node.
300                 Multiple symlinks may be specified by separating the names by the space
301                 character.</para>
302               </listitem>
303             </varlistentry>
304
305             <varlistentry>
306               <term><option>OWNER, GROUP, MODE</option></term>
307               <listitem>
308                 <para>The permissions for the device node. Every specified value overwrites
309                 the compiled-in default value.</para>
310               </listitem>
311             </varlistentry>
312
313             <varlistentry>
314               <term><option>ATTR{<replaceable>key</replaceable>}</option></term>
315               <listitem>
316                 <para>The value that should be written to a sysfs attribute of the
317                 event device.</para>
318               </listitem>
319             </varlistentry>
320
321             <varlistentry>
322               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
323               <listitem>
324                 <para>Set a device property value. Property names with a leading '.'
325                 are not stored in the database or exported to external tool or events.</para>
326               </listitem>
327             </varlistentry>
328
329             <varlistentry>
330               <term><option>RUN</option></term>
331               <listitem>
332                 <para>Add a program to the list of programs to be executed for a specific
333                 device. This can only be used for very short running tasks. Running an
334                 event process for a long period of time may block all further events for
335                 this or a dependent device. Long running tasks need to be immediately
336                 detached from the event process itself. If the option
337                 <option>RUN{<replaceable>fail_event_on_error</replaceable>}</option> is
338                 specified, and the executed program returns non-zero, the event will be
339                 marked as failed for a possible later handling.</para>
340                 <para>If the specified string starts with
341                 <option>socket:<replaceable>path</replaceable></option>, all current event
342                 values will be passed to the specified socket, as a message in the same
343                 format the kernel sends an uevent. If the first character of the specified path
344                 is an @ character, an abstract namespace socket is used, instead of an existing
345                 socket file.</para>
346               </listitem>
347             </varlistentry>
348
349             <varlistentry>
350               <term><option>LABEL</option></term>
351               <listitem>
352                 <para>Named label where a GOTO can jump to.</para>
353               </listitem>
354             </varlistentry>
355
356             <varlistentry>
357               <term><option>GOTO</option></term>
358               <listitem>
359                 <para>Jumps to the next LABEL with a matching name</para>
360               </listitem>
361             </varlistentry>
362
363             <varlistentry>
364               <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
365               <listitem>
366                 <para>Import a set of variables as device properties,
367                 depending on <replaceable>type</replaceable>:</para>
368                 <variablelist>
369                   <varlistentry>
370                     <term><option>program</option></term>
371                     <listitem>
372                       <para>Execute an external program specified as the assigned value and
373                       import its output, which must be in environment key format.</para>
374                     </listitem>
375                   </varlistentry>
376                   <varlistentry>
377                     <term><option>file</option></term>
378                     <listitem>
379                       <para>Import a text file specified as the assigned value, which must be in
380                       environment key format.</para>
381                     </listitem>
382                   </varlistentry>
383                   <varlistentry>
384                     <term><option>parent</option></term>
385                     <listitem>
386                       <para>Import the stored keys from the parent device by reading
387                       the database entry of the parent device. The value assigned to
388                       <option>IMPORT{parent}</option> is used as a filter of key names
389                       to import (with the same shell-style pattern matching used for
390                       comparisons).</para>
391                     </listitem>
392                   </varlistentry>
393                 </variablelist>
394                 <para>If no option is given, udev will choose between <option>program</option>
395                 and <option>file</option> based on the executable bit of the file
396                 permissions.</para>
397               </listitem>
398             </varlistentry>
399
400             <varlistentry>
401               <term><option>WAIT_FOR</option></term>
402               <listitem>
403                 <para>Wait for a file to become available.</para>
404               </listitem>
405             </varlistentry>
406
407             <varlistentry>
408               <term><option>OPTIONS</option></term>
409               <listitem>
410                 <para>Rule and device options:</para>
411                 <variablelist>
412                   <varlistentry>
413                     <term><option>last_rule</option></term>
414                     <listitem>
415                       <para>Stops further rules application. No later rules will have
416                       any effect.</para>
417                     </listitem>
418                   </varlistentry>
419                   <varlistentry>
420                     <term><option>ignore_device</option></term>
421                     <listitem>
422                       <para>Ignore this event completely.</para>
423                     </listitem>
424                   </varlistentry>
425                   <varlistentry>
426                     <term><option>ignore_remove</option></term>
427                     <listitem>
428                       <para>Do not remove the device node when the device goes away. This may be
429                       useful as a workaround for broken device drivers.</para>
430                     </listitem>
431                   </varlistentry>
432                   <varlistentry>
433                     <term><option>link_priority=<replaceable>value</replaceable></option></term>
434                     <listitem>
435                       <para>Specify the priority of the created symlinks. Devices with higher
436                       priorities overwrite existing symlinks of other devices. The default is 0.</para>
437                     </listitem>
438                   </varlistentry>
439                   <varlistentry>
440                     <term><option>all_partitions</option></term>
441                     <listitem>
442                       <para>Create the device nodes for all available partitions of a block device.
443                       This may be useful for removable media devices where media changes are not
444                       detected.</para>
445                     </listitem>
446                   </varlistentry>
447                   <varlistentry>
448                     <term><option>event_timeout=</option></term>
449                     <listitem>
450                       <para>Number of seconds an event will wait for operations to finish, before it
451                       will terminate itself.</para>
452                     </listitem>
453                   </varlistentry>
454                   <varlistentry>
455                     <term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
456                     <listitem>
457                       <para>Usually control and other possibly unsafe characters are replaced
458                       in strings used for device naming. The mode of replacement can be specified
459                       with this option.</para>
460                     </listitem>
461                   </varlistentry>
462                   <varlistentry>
463                     <term><option>watch</option></term>
464                     <listitem>
465                       <para>Watch the device node with inotify, when closed after being opened for
466                       writing, a change uevent will be synthesised.</para>
467                     </listitem>
468                   </varlistentry>
469                 </variablelist>
470               </listitem>
471             </varlistentry>
472           </variablelist>
473
474           <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
475           <option>OWNER</option>, <option>GROUP</option>, <option>MODE</option>  and  <option>RUN</option>
476           fields support simple printf-like string substitutions. The <option>RUN</option>
477           format chars gets applied after all rules have been processed, right before the program
478           is executed. It allows the use of device properties set by earlier matching
479           rules. For all other fields, substitutions are applied while the individual rule is
480           being processed. The available substitutions are:</para>
481           <variablelist>
482             <varlistentry>
483               <term><option>$kernel</option>, <option>%k</option></term>
484               <listitem>
485                 <para>The kernel name for this device.</para>
486               </listitem>
487             </varlistentry>
488
489             <varlistentry>
490               <term><option>$number</option>, <option>%n</option></term>
491               <listitem>
492                 <para>The kernel number for this device. For example, 'sda3' has
493                 kernel number of '3'</para>
494               </listitem>
495             </varlistentry>
496
497             <varlistentry>
498               <term><option>$devpath</option>, <option>%p</option></term>
499               <listitem>
500                 <para>The devpath of the device.</para>
501               </listitem>
502             </varlistentry>
503
504             <varlistentry>
505               <term><option>$id</option>, <option>%b</option></term>
506               <listitem>
507                 <para>The name of the device matched while searching the devpath upwards for
508                   <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
509                 </para>
510               </listitem>
511             </varlistentry>
512
513             <varlistentry>
514               <term><option>$driver</option></term>
515               <listitem>
516                 <para>The driver name of the device matched while searching the devpath upwards for
517                   <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
518                 </para>
519               </listitem>
520             </varlistentry>
521
522             <varlistentry>
523               <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
524               <listitem>
525                 <para>The value of a sysfs attribute found at the device, where
526                 all keys of the rule have matched. If the matching device does not have
527                 such an attribute, follow the chain of parent devices and use the value
528                 of the first attribute that matches.
529                 If the attribute is a symlink, the last element of the symlink target is
530                 returned as the value.</para>
531               </listitem>
532             </varlistentry>
533
534             <varlistentry>
535               <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
536               <listitem>
537                 <para>A device property value.</para>
538               </listitem>
539             </varlistentry>
540
541             <varlistentry>
542               <term><option>$major</option>, <option>%M</option></term>
543               <listitem>
544                 <para>The kernel major number for the device.</para>
545               </listitem>
546             </varlistentry>
547
548             <varlistentry>
549               <term><option>$minor</option>, <option>%m</option></term>
550               <listitem>
551                 <para>The kernel minor number for the device.</para>
552               </listitem>
553             </varlistentry>
554
555             <varlistentry>
556               <term><option>$result</option>, <option>%c</option></term>
557               <listitem>
558                 <para>The string returned by the external program requested with PROGRAM.
559                 A single part of the string, separated by a space character may be selected
560                 by specifying the part number as an attribute: <option>%c{N}</option>.
561                 If the number is followed by the '+' char this part plus all remaining parts
562                 of the result string are substituted: <option>%c{N+}</option></para>
563               </listitem>
564             </varlistentry>
565
566             <varlistentry>
567               <term><option>$parent</option>, <option>%P</option></term>
568               <listitem>
569                 <para>The node name of the parent device.</para>
570               </listitem>
571             </varlistentry>
572
573             <varlistentry>
574               <term><option>$name</option></term>
575               <listitem>
576                 <para>The current name of the device node. If not changed by a rule, it is the
577                 name of the kernel device.</para>
578               </listitem>
579             </varlistentry>
580
581             <varlistentry>
582               <term><option>$links</option></term>
583               <listitem>
584                 <para>The current list of symlinks, separated by a space character. The value is
585                 only set if an earlier rule assigned a value, or during a remove events.</para>
586               </listitem>
587             </varlistentry>
588
589             <varlistentry>
590               <term><option>$root</option>, <option>%r</option></term>
591               <listitem>
592                 <para>The udev_root value.</para>
593               </listitem>
594             </varlistentry>
595
596             <varlistentry>
597               <term><option>$sys</option>, <option>%S</option></term>
598               <listitem>
599                 <para>The sysfs mount point.</para>
600               </listitem>
601             </varlistentry>
602
603             <varlistentry>
604               <term><option>$tempnode</option>, <option>%N</option></term>
605               <listitem>
606                 <para>The name of a created temporary device node to provide access to
607                 the device from a external program before the real node is created.</para>
608               </listitem>
609             </varlistentry>
610
611             <varlistentry>
612               <term><option>%%</option></term>
613               <listitem>
614               <para>The '%' character itself.</para>
615               </listitem>
616             </varlistentry>
617
618             <varlistentry>
619               <term><option>$$</option></term>
620               <listitem>
621               <para>The '$' character itself.</para>
622               </listitem>
623             </varlistentry>
624           </variablelist>
625         </refsect2>
626       </refsect1>
627
628       <refsect1><title>AUTHOR</title>
629         <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
630         Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
631         Dan Stekloff and many others.</para>
632       </refsect1>
633
634       <refsect1>
635         <title>SEE ALSO</title>
636         <para><citerefentry>
637             <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
638           </citerefentry>, 
639           <citerefentry>
640             <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
641         </citerefentry></para>
642       </refsect1>
643     </refentry>
644   </section>
645 </article>