chiark / gitweb /
udevtrigger: add --retry-failed
[elogind.git] / 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         <date>August 2005</date>
12         <productname>udev</productname>
13       </refentryinfo>
14
15       <refmeta>
16         <refentrytitle>udev</refentrytitle>
17         <manvolnum>7</manvolnum>
18         <refmiscinfo class="version"></refmiscinfo>
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
33         kernel if a device is added or removed form the system.</para>
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>.
44         Every file consists of a set of lines of text. All empty lines or lines beginning
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
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 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.
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>
113                 <para>Assign a value to a key. Keys that represent a list, are reset
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>
139                 <para>Match the name of the event action.</para>
140               </listitem>
141             </varlistentry>
142
143             <varlistentry>
144               <term><option>DEVPATH</option></term>
145               <listitem>
146                 <para>Match the devpath of the event device.</para>
147               </listitem>
148             </varlistentry>
149
150             <varlistentry>
151               <term><option>KERNEL</option></term>
152               <listitem>
153                 <para>Match the name of the event device.</para>
154               </listitem>
155             </varlistentry>
156
157             <varlistentry>
158               <term><option>SUBSYSTEM</option></term>
159               <listitem>
160                 <para>Match the subsystem of the event device.</para>
161               </listitem>
162             </varlistentry>
163 <!--
164             <varlistentry>
165               <term><option>DRIVER</option></term>
166               <listitem>
167                 <para>Match the driver name of the event device. Only set for devices created by a bus driver.</para>
168               </listitem>
169             </varlistentry>
170 -->
171             <varlistentry>
172               <term><option>ATTR{<replaceable>filename</replaceable>}</option></term>
173               <listitem>
174                 <para>Match sysfs attribute values of the event device. Up to five
175                 <option>ATTR</option> keys can be specified per rule. Trailing
176                 whitespace in the attribute values is ignored, if the specified match
177                 value does not contain trailing whitespace itself.</para>
178               </listitem>
179             </varlistentry>
180
181             <varlistentry>
182               <term><option>KERNELS</option></term>
183               <listitem>
184                 <para>Search the devpath upwards for a matching device name.</para>
185               </listitem>
186             </varlistentry>
187
188             <varlistentry>
189               <term><option>SUBSYSTEMS</option></term>
190               <listitem>
191                 <para>Search the devpath upwards for a matching device subsystem name.</para>
192               </listitem>
193             </varlistentry>
194
195             <varlistentry>
196               <term><option>DRIVERS</option></term>
197               <listitem>
198                 <para>Search the devpath upwards for a matching device driver name.</para>
199               </listitem>
200             </varlistentry>
201
202             <varlistentry>
203               <term><option>ATTRS{<replaceable>filename</replaceable>}</option></term>
204               <listitem>
205                 <para>Search the devpath upwards for a device with matching sysfs attribute values.
206                 Up to five <option>ATTRS</option> keys can be specified per rule. All attributes
207                 must match on the same device. Trailing whitespace in the attribute values is ignored,
208                 if the specified match value does not contain trailing whitespace itself.</para>
209               </listitem>
210             </varlistentry>
211
212             <varlistentry>
213               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
214               <listitem>
215                 <para>Match against the value of an environment variable. Up to five <option>ENV</option>
216                 keys can be specified per rule. This key can also be used to export a variable to
217                 the environment.</para>
218               </listitem>
219             </varlistentry>
220
221             <varlistentry>
222               <term><option>PROGRAM</option></term>
223               <listitem>
224                 <para>Execute external program. The key is true, if the program returns
225                 without exit code zero. The whole event environment is available to the
226                 executed program. The program's output printed to stdout is available for
227                 the RESULT key.</para>
228               </listitem>
229             </varlistentry>
230
231             <varlistentry>
232               <term><option>RESULT</option></term>
233               <listitem>
234                 <para>Match the returned string of the last PROGRAM call. This key can
235                 be used in the same or in any later rule after a PROGRAM call.</para>
236               </listitem>
237             </varlistentry>
238           </variablelist>
239
240           <para>Most of the fields support a shell style pattern matching. The following
241           pattern characters are supported:</para>
242           <variablelist>
243             <varlistentry>
244               <term><option>*</option></term>
245               <listitem>
246                 <para>Matches zero, or any number of characters.</para>
247               </listitem>
248             </varlistentry>
249             <varlistentry>
250               <term><option>?</option></term>
251               <listitem>
252                 <para>Matches any single character.</para>
253               </listitem>
254             </varlistentry>
255             <varlistentry>
256               <term><option>[]</option></term>
257               <listitem>
258                 <para>Matches any single character specified within the brackets. For
259                 example, the pattern string 'tty[SR]' would match either 'ttyS' or 'ttyR'.
260                 Ranges are also supported within this match with the '-' character.
261                 For example, to match on the range of all digits, the pattern [0-9] would
262                 be used. If the first character following the '[' is a '!', any characters
263                 not enclosed are matched.</para>
264               </listitem>
265             </varlistentry>
266           </variablelist>
267
268           <para>The following keys can get values assigned:</para>
269           <variablelist>
270             <varlistentry>
271               <term><option>NAME</option></term>
272               <listitem>
273                 <para>The name of the node to be created, or the name the network interface
274                 should be renamed to. Only one rule can set the node name, all later rules with
275                 a NAME key will be ignored.</para>
276               </listitem>
277             </varlistentry>
278
279             <varlistentry>
280               <term><option>SYMLINK</option></term>
281               <listitem>
282                 <para>The name of a symlink targeting the node. Every matching rule can add
283                 this value to the list of symlinks to be created along with the device  node.
284                 Multiple symlinks may be specified by separating the names by the space
285                 character.</para>
286               </listitem>
287             </varlistentry>
288
289             <varlistentry>
290               <term><option>OWNER, GROUP, MODE</option></term>
291               <listitem>
292                 <para>The permissions for the device node. Every specified value overwrites
293                 the compiled-in default value.</para>
294               </listitem>
295             </varlistentry>
296
297             <varlistentry>
298               <term><option>ENV{<replaceable>key</replaceable>}</option></term>
299               <listitem>
300                 <para>Export a variable to the environment. This key can also be used to match
301                 against an environment variable.</para>
302               </listitem>
303             </varlistentry>
304
305             <varlistentry>
306               <term><option>RUN</option></term>
307               <listitem>
308                 <para>Add a program to the list of programs to be executed for a specific
309                 device. This can only be used for very short running tasks. Running an
310                 event process for a long period of time may block all further events for
311                 this or a dependent device. Long running tasks need to be immediately
312                 detached from the event process itself.</para>
313               </listitem>
314             </varlistentry>
315
316             <varlistentry>
317               <term><option>LABEL</option></term>
318               <listitem>
319                 <para>Named label where a GOTO can jump to.</para>
320               </listitem>
321             </varlistentry>
322
323             <varlistentry>
324               <term><option>GOTO</option></term>
325               <listitem>
326                 <para>Jumps to the next LABEL with a matching name</para>
327               </listitem>
328             </varlistentry>
329
330             <varlistentry>
331               <term><option>IMPORT{<replaceable>type</replaceable>}</option></term>
332               <listitem>
333                 <para>Import the printed result or the value of a file in environment key
334                 format into the event environment. <option>program</option> will execute an
335                 external program and read its output. <option>file</option> will import a
336                 text file. If no option is given, udev will determine it from the  executable
337                 bit of of the file permissions.</para>
338               </listitem>
339             </varlistentry>
340
341             <varlistentry>
342               <term><option>WAIT_FOR_SYSFS</option></term>
343               <listitem>
344                 <para>Wait for the specified sysfs file of the device to be created. Can be used
345                 to fight against kernel sysfs timing issues.</para>
346               </listitem>
347             </varlistentry>
348
349             <varlistentry>
350               <term><option>OPTIONS</option></term>
351               <listitem>
352                 <para><option>last_rule</option> stops further rules application. No later rules
353                 will have any effect.
354                 <option>ignore_device</option> will ignore this event completely.
355                 <option>ignore_remove</option> will ignore  any  later  remove  event  for  this
356                 device. This may be useful as a workaround for broken device drivers.
357                 <option>all_partitions</option> will create the device nodes for all available
358                 partitions of a block device. This may be useful for removable media devices where
359                 media changes are not detected.</para>
360               </listitem>
361             </varlistentry>
362           </variablelist>
363
364           <para>The <option>NAME</option>, <option>SYMLINK</option>, <option>PROGRAM</option>,
365           <option>OWNER</option>, <option>GROUP</option>  and  <option>RUN</option>
366           fields support simple printf-like string substitutions. The <option>RUN</option>
367           format chars gets applied after all rules have been processed, right before the program
368           is executed. It allows the use of the complete environment set by earlier matching
369           rules. For all other fields, substitutions are applied while the individual rule is
370           being processed. The available substitutions are:</para>
371           <variablelist>
372             <varlistentry>
373               <term><option>$kernel</option>, <option>%k</option></term>
374               <listitem>
375                 <para>The kernel name for this device.</para>
376               </listitem>
377             </varlistentry>
378
379             <varlistentry>
380               <term><option>$number</option>, <option>%n</option></term>
381               <listitem>
382                 <para>The kernel number for this device. For example, 'sda3' has
383                 kernel number of '3'</para>
384               </listitem>
385             </varlistentry>
386
387             <varlistentry>
388               <term><option>$devpath</option>, <option>%p</option></term>
389               <listitem>
390                 <para>The devpath of the device.</para>
391               </listitem>
392             </varlistentry>
393
394             <varlistentry>
395               <term><option>$id</option>, <option>%b</option></term>
396               <listitem>
397                 <para>The name of the device matched while searching the devpath upwards for
398                   <option>SUBSYSTEMS</option>, <option>KERNELS</option> <option>DRIVERS</option> and <option>ATTRS</option>.
399                 </para>
400               </listitem>
401             </varlistentry>
402
403             <varlistentry>
404               <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
405               <listitem>
406                 <para>The value of a sysfs attribute found at the current or a parent device.</para>
407               </listitem>
408             </varlistentry>
409
410             <varlistentry>
411               <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
412               <listitem>
413                 <para>The value of an environment variable.</para>
414               </listitem>
415             </varlistentry>
416
417             <varlistentry>
418               <term><option>$major</option>, <option>%M</option></term>
419               <listitem>
420                 <para>The kernel major number for the device.</para>
421               </listitem>
422             </varlistentry>
423
424             <varlistentry>
425               <term><option>$minor</option> <option>%m</option></term>
426               <listitem>
427                 <para>The kernel minor number for the device.</para>
428               </listitem>
429             </varlistentry>
430
431             <varlistentry>
432               <term><option>$result</option>, <option>%c</option></term>
433               <listitem>
434                 <para>The string returned by the external program requested with PROGRAM.
435                 A single part of the string, separated by a space character may be selected
436                 by specifying the part number as an attribute: <option>%c{N}</option>.
437                 If the number is followed by the '+' char this part plus all remaining parts
438                 of the result string are substituted: <option>%c{N+}</option></para>
439               </listitem>
440             </varlistentry>
441
442             <varlistentry>
443               <term><option>$parent</option>, <option>%P</option></term>
444               <listitem>
445                 <para>The node name of the parent device.</para>
446               </listitem>
447             </varlistentry>
448
449             <varlistentry>
450               <term><option>$root</option>, <option>%r</option></term>
451               <listitem>
452                 <para>The udev_root value.</para>
453               </listitem>
454             </varlistentry>
455
456             <varlistentry>
457               <term><option>$tempnode</option>, <option>%N</option></term>
458               <listitem>
459                 <para>The name of a created temporary device node to provide access to
460                 the device from a external program before the real node is created.</para>
461               </listitem>
462             </varlistentry>
463
464             <varlistentry>
465               <term><option>%%</option></term>
466               <listitem>
467               <para>The '%' character itself.</para>
468               </listitem>
469             </varlistentry>
470
471             <varlistentry>
472               <term><option>$$</option></term>
473               <listitem>
474               <para>The '$' character itself.</para>
475               </listitem>
476             </varlistentry>
477           </variablelist>
478           <para>The count of characters to be substituted may be limited by specifying
479           the format length value. For example, '%3s{file}' will only
480           insert the first three characters of the sysfs attribute</para>
481         </refsect2>
482       </refsect1>
483
484       <refsect1><title>AUTHOR</title>
485         <para>Written by Greg Kroah-Hartman <email>greg@kroah.com</email> and
486         Kay Sievers <email>kay.sievers@vrfy.org</email>. With much help from
487         Dan  Stekloff <email>dsteklof@us.ibm.com</email> and many others.</para>
488       </refsect1>
489
490       <refsect1>
491         <title>SEE ALSO</title>
492         <para><citerefentry>
493             <refentrytitle>udevd</refentrytitle><manvolnum>8</manvolnum>
494           </citerefentry>, 
495           <citerefentry>
496             <refentrytitle>udevinfo</refentrytitle><manvolnum>8</manvolnum>
497           </citerefentry>, 
498           <citerefentry>
499             <refentrytitle>udevmonitor</refentrytitle><manvolnum>8</manvolnum>
500         </citerefentry></para>
501       </refsect1>
502     </refentry>
503   </section>
504 </article>