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