]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/udev.xml
Document "...|..." udev match syntax
[thirdparty/systemd.git] / man / udev.xml
1 <?xml version='1.0'?>
2 <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
6 <refentry id="udev">
7 <refentryinfo>
8 <title>udev</title>
9 <productname>systemd</productname>
10 <authorgroup>
11 <author>
12 <contrib>Developer</contrib>
13 <firstname>Greg</firstname>
14 <surname>Kroah-Hartmann</surname>
15 <email>greg@kroah.com</email>
16 </author>
17 <author>
18 <contrib>Developer</contrib>
19 <firstname>Kay</firstname>
20 <surname>Sievers</surname>
21 <email>kay@vrfy.org</email>
22 </author>
23 </authorgroup>
24 </refentryinfo>
25
26 <refmeta>
27 <refentrytitle>udev</refentrytitle>
28 <manvolnum>7</manvolnum>
29 </refmeta>
30
31 <refnamediv>
32 <refname>udev</refname>
33 <refpurpose>Dynamic device management</refpurpose>
34 </refnamediv>
35
36 <refsect1><title>Description</title>
37 <para>udev supplies the system software with device events, manages permissions
38 of device nodes and may create additional symlinks in the <filename>/dev</filename>
39 directory, or renames network interfaces. The kernel usually just assigns unpredictable
40 device names based on the order of discovery. Meaningful symlinks or network device
41 names provide a way to reliably identify devices based on their properties or
42 current configuration.</para>
43
44 <para>The udev daemon, <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle>
45 <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from
46 the kernel whenever a device is added or removed from the system, or it changes its
47 state. When udev receives a device event, it matches its configured set of rules
48 against various device attributes to identify the device. Rules that match may
49 provide additional device information to be stored in the udev database or
50 to be used to create meaningful symlink names.</para>
51
52 <para>All device information udev processes is stored in the udev database and
53 sent out to possible event subscribers. Access to all stored data and the event
54 sources is provided by the library libudev.</para>
55 </refsect1>
56
57 <refsect1><title>Rules Files</title>
58 <para>The udev rules are read from the files located in the
59 system rules directory <filename>/usr/lib/udev/rules.d</filename>,
60 the volatile runtime directory <filename>/run/udev/rules.d</filename>
61 and the local administration directory <filename>/etc/udev/rules.d</filename>.
62 All rules files are collectively sorted and processed in lexical order,
63 regardless of the directories in which they live. However, files with
64 identical filenames replace each other. Files in <filename>/etc</filename>
65 have the highest priority, files in <filename>/run</filename> take precedence
66 over files with the same name in <filename>/usr/lib</filename>. This can be
67 used to override a system-supplied rules file with a local file if needed;
68 a symlink in <filename>/etc</filename> with the same name as a rules file in
69 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
70 disables the rules file entirely. Rule files must have the extension
71 <filename>.rules</filename>; other extensions are ignored.</para>
72
73 <para>Every line in the rules file contains at least one key-value pair.
74 Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
75 There are two kinds of keys: match and assignment.
76 If all match keys match against their values, the rule gets applied and the
77 assignment keys get the specified values assigned.</para>
78
79 <para>A matching rule may rename a network interface, add symlinks
80 pointing to the device node, or run a specified program as part of
81 the event handling.</para>
82
83 <para>A rule consists of a comma-separated list of one or more key-value pairs.
84 Each key has a distinct operation, depending on the used operator. Valid
85 operators are:</para>
86 <variablelist>
87 <varlistentry>
88 <term><literal>==</literal></term>
89 <listitem>
90 <para>Compare for equality.</para>
91 </listitem>
92 </varlistentry>
93
94 <varlistentry>
95 <term><literal>!=</literal></term>
96 <listitem>
97 <para>Compare for inequality.</para>
98 </listitem>
99 </varlistentry>
100
101 <varlistentry>
102 <term><literal>=</literal></term>
103 <listitem>
104 <para>Assign a value to a key. Keys that represent a list are reset
105 and only this single value is assigned.</para>
106 </listitem>
107 </varlistentry>
108
109 <varlistentry>
110 <term><literal>+=</literal></term>
111 <listitem>
112 <para>Add the value to a key that holds a list of entries.</para>
113 </listitem>
114 </varlistentry>
115
116 <varlistentry>
117 <term><literal>:=</literal></term>
118 <listitem>
119 <para>Assign a value to a key finally; disallow any later changes.</para>
120 </listitem>
121 </varlistentry>
122 </variablelist>
123
124 <para>The following key names can be used to match against device properties.
125 Some of the keys also match against properties of the parent devices in sysfs,
126 not only the device that has generated the event. If multiple keys that match
127 a parent device are specified in a single rule, all these keys must match at
128 one and the same parent device.</para>
129 <variablelist class='udev-directives'>
130 <varlistentry>
131 <term><varname>ACTION</varname></term>
132 <listitem>
133 <para>Match the name of the event action.</para>
134 </listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><varname>DEVPATH</varname></term>
139 <listitem>
140 <para>Match the devpath of the event device.</para>
141 </listitem>
142 </varlistentry>
143
144 <varlistentry>
145 <term><varname>KERNEL</varname></term>
146 <listitem>
147 <para>Match the name of the event device.</para>
148 </listitem>
149 </varlistentry>
150
151 <varlistentry>
152 <term><varname>NAME</varname></term>
153 <listitem>
154 <para>Match the name of a network interface. It can be used once the
155 NAME key has been set in one of the preceding rules.</para>
156 </listitem>
157 </varlistentry>
158
159 <varlistentry>
160 <term><varname>SYMLINK</varname></term>
161 <listitem>
162 <para>Match the name of a symlink targeting the node. It can
163 be used once a SYMLINK key has been set in one of the preceding
164 rules. There may be multiple symlinks; only one needs to match.
165 </para>
166 </listitem>
167 </varlistentry>
168
169 <varlistentry>
170 <term><varname>SUBSYSTEM</varname></term>
171 <listitem>
172 <para>Match the subsystem of the event device.</para>
173 </listitem>
174 </varlistentry>
175 <varlistentry>
176 <term><varname>DRIVER</varname></term>
177 <listitem>
178 <para>Match the driver name of the event device. Only set this key 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><varname>ATTR{<replaceable>filename</replaceable>}</varname></term>
184 <listitem>
185 <para>Match sysfs attribute values of the event device. Trailing
186 whitespace in the attribute values is ignored unless the specified match
187 value itself contains trailing whitespace.
188 </para>
189 </listitem>
190 </varlistentry>
191
192 <varlistentry>
193 <term><varname>KERNELS</varname></term>
194 <listitem>
195 <para>Search the devpath upwards for a matching device name.</para>
196 </listitem>
197 </varlistentry>
198
199 <varlistentry>
200 <term><varname>SUBSYSTEMS</varname></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><varname>DRIVERS</varname></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><varname>ATTRS{<replaceable>filename</replaceable>}</varname></term>
215 <listitem>
216 <para>Search the devpath upwards for a device with matching sysfs attribute values.
217 If multiple <varname>ATTRS</varname> matches are specified, all of them
218 must match on the same device. Trailing whitespace in the attribute values is ignored
219 unless the specified match value itself contains trailing whitespace.</para>
220 </listitem>
221 </varlistentry>
222
223 <varlistentry>
224 <term><varname>TAGS</varname></term>
225 <listitem>
226 <para>Search the devpath upwards for a device with matching tag.</para>
227 </listitem>
228 </varlistentry>
229
230 <varlistentry>
231 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
232 <listitem>
233 <para>Match against a device property value.</para>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry>
238 <term><varname>TAG</varname></term>
239 <listitem>
240 <para>Match against a device tag.</para>
241 </listitem>
242 </varlistentry>
243
244 <varlistentry>
245 <term><varname>TEST{<replaceable>octal mode mask</replaceable>}</varname></term>
246 <listitem>
247 <para>Test the existence of a file. An octal mode mask can be specified
248 if needed.</para>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry>
253 <term><varname>PROGRAM</varname></term>
254 <listitem>
255 <para>Execute a program to determine whether there
256 is a match; the key is true if the program returns
257 successfully. The device properties are made available to the
258 executed program in the environment. The program's standard ouput
259 is available in the <varname>RESULT</varname> key.</para>
260 <para>This can only be used for very short-running foreground tasks. For details,
261 see <varname>RUN</varname>.</para>
262 </listitem>
263 </varlistentry>
264
265 <varlistentry>
266 <term><varname>RESULT</varname></term>
267 <listitem>
268 <para>Match the returned string of the last <varname>PROGRAM</varname> call.
269 This key can be used in the same or in any later rule after a
270 <varname>PROGRAM</varname> call.</para>
271 </listitem>
272 </varlistentry>
273 </variablelist>
274
275 <para>Most of the fields support shell glob pattern matching and
276 alternate patterns. The following special characters are supported:</para>
277 <variablelist>
278 <varlistentry>
279 <term><literal>*</literal></term>
280 <listitem>
281 <para>Matches zero or more characters.</para>
282 </listitem>
283 </varlistentry>
284 <varlistentry>
285 <term><literal>?</literal></term>
286 <listitem>
287 <para>Matches any single character.</para>
288 </listitem>
289 </varlistentry>
290 <varlistentry>
291 <term><literal>[]</literal></term>
292 <listitem>
293 <para>Matches any single character specified within the brackets. For
294 example, the pattern string <literal>tty[SR]</literal>
295 would match either <literal>ttyS</literal> or <literal>ttyR</literal>.
296 Ranges are also supported via the <literal>-</literal> character.
297 For example, to match on the range of all digits, the pattern
298 <literal>[0-9]</literal> could be used. If the first character
299 following the <literal>[</literal> is a <literal>!</literal>,
300 any characters not enclosed are matched.</para>
301 </listitem>
302 </varlistentry>
303 <varlistentry>
304 <term><literal>|</literal></term>
305 <listitem>
306 <para>Separates alternative patterns. For example, the pattern string
307 <literal>abc|x*</literal> would match either <literal>abc</literal>
308 or <literal>x*</literal>.</para>
309 </listitem>
310 </varlistentry>
311 </variablelist>
312
313 <para>The following keys can get values assigned:</para>
314 <variablelist class='udev-directives'>
315 <varlistentry>
316 <term><varname>NAME</varname></term>
317 <listitem>
318 <para>The name to use for a network interface. See
319 <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
320 for a higher-level mechanism for setting the interface name.
321 The name of a device node cannot be changed by udev, only additional
322 symlinks can be created.</para>
323 </listitem>
324 </varlistentry>
325
326 <varlistentry>
327 <term><varname>SYMLINK</varname></term>
328 <listitem>
329 <para>The name of a symlink targeting the node. Every matching rule adds
330 this value to the list of symlinks to be created.</para>
331 <para>The set of characters to name a symlink is limited. Allowed
332 characters are <literal>0-9A-Za-z#+-.:=@_/</literal>, valid UTF-8 character
333 sequences, and <literal>\x00</literal> hex encoding. All other
334 characters are replaced by a <literal>_</literal> character.</para>
335 <para>Multiple symlinks may be specified by separating the names by the
336 space character. In case multiple devices claim the same name, the link
337 always points to the device with the highest link_priority. If the current
338 device goes away, the links are re-evaluated and the device with the
339 next highest link_priority becomes the owner of the link. If no
340 link_priority is specified, the order of the devices (and which one of
341 them owns the link) is undefined.</para>
342 <para>Symlink names must never conflict with the kernel's default device
343 node names, as that would result in unpredictable behavior.
344 </para>
345 </listitem>
346 </varlistentry>
347
348 <varlistentry>
349 <term><varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname></term>
350 <listitem>
351 <para>The permissions for the device node. Every specified value overrides
352 the compiled-in default value.</para>
353 </listitem>
354 </varlistentry>
355
356 <varlistentry>
357 <term><varname>SECLABEL{<replaceable>module</replaceable>}</varname></term>
358 <listitem>
359 <para>Applies the specified Linux Security Module label to the device node.</para>
360 </listitem>
361 </varlistentry>
362
363 <varlistentry>
364 <term><varname>ATTR{<replaceable>key</replaceable>}</varname></term>
365 <listitem>
366 <para>The value that should be written to a sysfs attribute of the
367 event device.</para>
368 </listitem>
369 </varlistentry>
370
371 <varlistentry>
372 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
373 <listitem>
374 <para>Set a device property value. Property names with a leading <literal>.</literal>
375 are neither stored in the database nor exported to events or
376 external tools (run by, for example, the <varname>PROGRAM</varname>
377 match key).</para>
378 </listitem>
379 </varlistentry>
380
381 <varlistentry>
382 <term><varname>TAG</varname></term>
383 <listitem>
384 <para>Attach a tag to a device. This is used to filter events for users
385 of libudev's monitor functionality, or to enumerate a group of tagged
386 devices. The implementation can only work efficiently if only a few
387 tags are attached to a device. It is only meant to be used in
388 contexts with specific device filter requirements, and not as a
389 general-purpose flag. Excessive use might result in inefficient event
390 handling.</para>
391 </listitem>
392 </varlistentry>
393
394 <varlistentry>
395 <term><varname>RUN{<replaceable>type</replaceable>}</varname></term>
396 <listitem>
397 <para>Add a program to the list of programs to be executed after
398 processing all the rules for a specific event, depending on
399 <literal>type</literal>:</para>
400 <variablelist>
401 <varlistentry>
402 <term><literal>program</literal></term>
403 <listitem>
404 <para>Execute an external program specified as the assigned
405 value. If no absolute path is given, the program is expected
406 to live in <filename>/usr/lib/udev</filename>; otherwise, the
407 absolute path must be specified.</para>
408 <para>This is the default if no <replaceable>type</replaceable>
409 is specified.</para>
410 </listitem>
411 </varlistentry>
412 <varlistentry>
413 <term><literal>builtin</literal></term>
414 <listitem>
415 <para>As <varname>program</varname>, but use one of the
416 built-in programs rather than an external one.</para>
417 </listitem>
418 </varlistentry>
419 </variablelist>
420 <para>The program name and following arguments are separated by spaces.
421 Single quotes can be used to specify arguments with spaces.</para>
422 <para>This can only be used for very short-running foreground tasks. Running an
423 event process for a long period of time may block all further events for
424 this or a dependent device.</para>
425 <para>Starting daemons or other long-running processes is not appropriate
426 for udev; the forked processes, detached or not, will be unconditionally
427 killed after the event handling has finished.</para>
428 </listitem>
429 </varlistentry>
430
431 <varlistentry>
432 <term><varname>LABEL</varname></term>
433 <listitem>
434 <para>A named label to which a <varname>GOTO</varname> may jump.</para>
435 </listitem>
436 </varlistentry>
437
438 <varlistentry>
439 <term><varname>GOTO</varname></term>
440 <listitem>
441 <para>Jumps to the next <varname>LABEL</varname> with a matching name.</para>
442 </listitem>
443 </varlistentry>
444
445 <varlistentry>
446 <term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term>
447 <listitem>
448 <para>Import a set of variables as device properties,
449 depending on <literal>type</literal>:</para>
450 <variablelist>
451 <varlistentry>
452 <term><literal>program</literal></term>
453 <listitem>
454 <para>Execute an external program specified as the assigned value and
455 import its output, which must be in environment key
456 format. Path specification, command/argument separation,
457 and quoting work like in <varname>RUN</varname>.</para>
458 </listitem>
459 </varlistentry>
460 <varlistentry>
461 <term><literal>builtin</literal></term>
462 <listitem>
463 <para>Similar to <literal>program</literal>, but use one of the
464 built-in programs rather than an external one.</para>
465 </listitem>
466 </varlistentry>
467 <varlistentry>
468 <term><literal>file</literal></term>
469 <listitem>
470 <para>Import a text file specified as the assigned value, the content
471 of which must be in environment key format.</para>
472 </listitem>
473 </varlistentry>
474 <varlistentry>
475 <term><literal>db</literal></term>
476 <listitem>
477 <para>Import a single property specified as the assigned value from the
478 current device database. This works only if the database is already populated
479 by an earlier event.</para>
480 </listitem>
481 </varlistentry>
482 <varlistentry>
483 <term><literal>cmdline</literal></term>
484 <listitem>
485 <para>Import a single property from the kernel command line. For simple flags
486 the value of the property is set to <literal>1</literal>.</para>
487 </listitem>
488 </varlistentry>
489 <varlistentry>
490 <term><literal>parent</literal></term>
491 <listitem>
492 <para>Import the stored keys from the parent device by reading
493 the database entry of the parent device. The value assigned to
494 <option>IMPORT{parent}</option> is used as a filter of key names
495 to import (with the same shell glob pattern matching used for
496 comparisons).</para>
497 </listitem>
498 </varlistentry>
499 </variablelist>
500 <para>This can only be used for very short-running foreground tasks. For details
501 see <option>RUN</option>.</para>
502 </listitem>
503 </varlistentry>
504
505 <varlistentry>
506 <term><varname>WAIT_FOR</varname></term>
507 <listitem>
508 <para>Wait for a file to become available or until a timeout of
509 10 seconds expires. The path is relative to the sysfs device;
510 if no path is specified, this waits for an attribute to appear.</para>
511 </listitem>
512 </varlistentry>
513
514 <varlistentry>
515 <term><varname>OPTIONS</varname></term>
516 <listitem>
517 <para>Rule and device options:</para>
518 <variablelist class='udev-directives'>
519 <varlistentry>
520 <term><option>link_priority=<replaceable>value</replaceable></option></term>
521 <listitem>
522 <para>Specify the priority of the created symlinks. Devices with higher
523 priorities overwrite existing symlinks of other devices. The default is 0.</para>
524 </listitem>
525 </varlistentry>
526 <varlistentry>
527 <term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
528 <listitem>
529 <para>Usually control and other possibly unsafe characters are replaced
530 in strings used for device naming. The mode of replacement can be specified
531 with this option.</para>
532 </listitem>
533 </varlistentry>
534 <varlistentry>
535 <term><option>static_node=</option></term>
536 <listitem>
537 <para>Apply the permissions specified in this rule to the
538 static device node with the specified name. Also, for every
539 tag specified in this rule, create a symlink
540 in the directory
541 <filename>/run/udev/static_node-tags/<replaceable>tag</replaceable></filename>
542 pointing at the static device node with the specified name.
543 Static device node creation is performed by systemd-tmpfiles
544 before systemd-udevd is started. The static nodes might not
545 have a corresponding kernel device; they are used to trigger
546 automatic kernel module loading when they are accessed.</para>
547 </listitem>
548 </varlistentry>
549 <varlistentry>
550 <term><option>watch</option></term>
551 <listitem>
552 <para>Watch the device node with inotify; when the node is
553 closed after being opened for writing, a change uevent is
554 synthesized.</para>
555 </listitem>
556 </varlistentry>
557 <varlistentry>
558 <term><option>nowatch</option></term>
559 <listitem>
560 <para>Disable the watching of a device node with inotify.</para>
561 </listitem>
562 </varlistentry>
563 </variablelist>
564 </listitem>
565 </varlistentry>
566 </variablelist>
567
568 <para>The <varname>NAME</varname>, <varname>SYMLINK</varname>,
569 <varname>PROGRAM</varname>, <varname>OWNER</varname>,
570 <varname>GROUP</varname>, <varname>MODE</varname>, and
571 <varname>RUN</varname> fields support simple string substitutions.
572 The <varname>RUN</varname> substitutions are performed after all rules
573 have been processed, right before the program is executed, allowing for
574 the use of device properties set by earlier matching rules. For all other
575 fields, substitutions are performed while the individual rule is being
576 processed. The available substitutions are:</para>
577 <variablelist class='udev-directives'>
578 <varlistentry>
579 <term><option>$kernel</option>, <option>%k</option></term>
580 <listitem>
581 <para>The kernel name for this device.</para>
582 </listitem>
583 </varlistentry>
584
585 <varlistentry>
586 <term><option>$number</option>, <option>%n</option></term>
587 <listitem>
588 <para>The kernel number for this device. For example,
589 <literal>sda3</literal> has kernel number <literal>3</literal>.
590 </para>
591 </listitem>
592 </varlistentry>
593
594 <varlistentry>
595 <term><option>$devpath</option>, <option>%p</option></term>
596 <listitem>
597 <para>The devpath of the device.</para>
598 </listitem>
599 </varlistentry>
600
601 <varlistentry>
602 <term><option>$id</option>, <option>%b</option></term>
603 <listitem>
604 <para>The name of the device matched while searching the devpath
605 upwards for <option>SUBSYSTEMS</option>, <option>KERNELS</option>,
606 <option>DRIVERS</option>, and <option>ATTRS</option>.
607 </para>
608 </listitem>
609 </varlistentry>
610
611 <varlistentry>
612 <term><option>$driver</option></term>
613 <listitem>
614 <para>The driver name of the device matched while searching the
615 devpath upwards for <option>SUBSYSTEMS</option>,
616 <option>KERNELS</option>, <option>DRIVERS</option>, and
617 <option>ATTRS</option>.
618 </para>
619 </listitem>
620 </varlistentry>
621
622 <varlistentry>
623 <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
624 <listitem>
625 <para>The value of a sysfs attribute found at the device where
626 all keys of the rule have matched. If the matching device does not
627 have such an attribute, and a previous <option>KERNELS</option>,
628 <option>SUBSYSTEMS</option>, <option>DRIVERS</option>, or
629 <option>ATTRS</option> test selected a parent device, then the
630 attribute from that parent device is used.
631 </para>
632 <para>If the attribute is a symlink, the last element of the
633 symlink target is returned as the value.
634 </para>
635 </listitem>
636 </varlistentry>
637
638 <varlistentry>
639 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
640 <listitem>
641 <para>A device property value.</para>
642 </listitem>
643 </varlistentry>
644
645 <varlistentry>
646 <term><option>$major</option>, <option>%M</option></term>
647 <listitem>
648 <para>The kernel major number for the device.</para>
649 </listitem>
650 </varlistentry>
651
652 <varlistentry>
653 <term><option>$minor</option>, <option>%m</option></term>
654 <listitem>
655 <para>The kernel minor number for the device.</para>
656 </listitem>
657 </varlistentry>
658
659 <varlistentry>
660 <term><option>$result</option>, <option>%c</option></term>
661 <listitem>
662 <para>The string returned by the external program requested with
663 <varname>PROGRAM</varname>.
664 A single part of the string, separated by a space character, may be selected
665 by specifying the part number as an attribute: <literal>%c{N}</literal>.
666 If the number is followed by the <literal>+</literal> character, this part plus all remaining parts
667 of the result string are substituted: <literal>%c{N+}</literal>.</para>
668 </listitem>
669 </varlistentry>
670
671 <varlistentry>
672 <term><option>$parent</option>, <option>%P</option></term>
673 <listitem>
674 <para>The node name of the parent device.</para>
675 </listitem>
676 </varlistentry>
677
678 <varlistentry>
679 <term><option>$name</option></term>
680 <listitem>
681 <para>The current name of the device. If not changed by a rule, it is the
682 name of the kernel device.</para>
683 </listitem>
684 </varlistentry>
685
686 <varlistentry>
687 <term><option>$links</option></term>
688 <listitem>
689 <para>A space-separated list of the current symlinks. The value is
690 only set during a remove event or if an earlier rule assigned a value.</para>
691 </listitem>
692 </varlistentry>
693
694 <varlistentry>
695 <term><option>$root</option>, <option>%r</option></term>
696 <listitem>
697 <para>The udev_root value.</para>
698 </listitem>
699 </varlistentry>
700
701 <varlistentry>
702 <term><option>$sys</option>, <option>%S</option></term>
703 <listitem>
704 <para>The sysfs mount point.</para>
705 </listitem>
706 </varlistentry>
707
708 <varlistentry>
709 <term><option>$devnode</option>, <option>%N</option></term>
710 <listitem>
711 <para>The name of the device node.</para>
712 </listitem>
713 </varlistentry>
714
715 <varlistentry>
716 <term><option>%%</option></term>
717 <listitem>
718 <para>The <literal>%</literal> character itself.</para>
719 </listitem>
720 </varlistentry>
721
722 <varlistentry>
723 <term><option>$$</option></term>
724 <listitem>
725 <para>The <literal>$</literal> character itself.</para>
726 </listitem>
727 </varlistentry>
728 </variablelist>
729 </refsect1>
730
731 <refsect1><title>Hardware Database Files</title>
732 <para>The hwdb files are read from the files located in the
733 system hwdb directory <filename>/usr/lib/udev/hwdb.d</filename>,
734 the volatile runtime directory <filename>/run/udev/hwdb.d</filename>
735 and the local administration directory <filename>/etc/udev/hwdb.d</filename>.
736 All hwdb files are collectively sorted and processed in lexical order,
737 regardless of the directories in which they live. However, files with
738 identical filenames replace each other. Files in <filename>/etc</filename>
739 have the highest priority, files in <filename>/run</filename> take precedence
740 over files with the same name in <filename>/usr/lib</filename>. This can be
741 used to override a system-supplied hwdb file with a local file if needed;
742 a symlink in <filename>/etc</filename> with the same name as a hwdb file in
743 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
744 disables the hwdb file entirely. hwdb files must have the extension
745 <filename>.hwdb</filename>; other extensions are ignored.</para>
746
747 <para>The hwdb file contains data records consisting of matches and
748 associated key-value pairs. Every record in the hwdb starts with one or
749 more match string, specifying a shell glob to compare the database
750 lookup string against. Multiple match lines are specified in additional
751 consecutive lines. Every match line is compared indivdually, they are
752 combined by OR. Every match line must start at the first character of
753 the line.</para>
754
755 <para>The match lines are followed by one or more key-value pair lines, which
756 are recognized by a leading space character. The key name and value are separated
757 by <literal>=</literal>. An empty line signifies the end
758 of a record. Lines beginning with <literal>#</literal> are ignored.</para>
759
760 <para>The content of all hwdb files is read by
761 <citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
762 and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>.
763 During runtime only the binary database is used.</para>
764 </refsect1>
765
766 <refsect1>
767 <title>See Also</title>
768 <para>
769 <citerefentry>
770 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
771 </citerefentry>,
772 <citerefentry>
773 <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
774 </citerefentry>,
775 <citerefentry>
776 <refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum>
777 </citerefentry>
778 </para>
779 </refsect1>
780 </refentry>