]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/udev.xml
man: update version information
[thirdparty/systemd.git] / man / udev.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1-or-later
7 Copyright © 2014 Jason St. John
8 -->
9
10 <refentry id="udev" xmlns:xi="http://www.w3.org/2001/XInclude">
11 <refentryinfo>
12 <title>udev</title>
13 <productname>systemd</productname>
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>udev</refentrytitle>
18 <manvolnum>7</manvolnum>
19 </refmeta>
20
21 <refnamediv>
22 <refname>udev</refname>
23 <refpurpose>Dynamic device management</refpurpose>
24 </refnamediv>
25
26 <refsect1>
27 <title>Description</title>
28 <para>udev supplies the system software with device events, manages permissions
29 of device nodes and may create additional symlinks in the <filename>/dev/</filename>
30 directory, or renames network interfaces. The kernel usually just assigns unpredictable
31 device names based on the order of discovery. Meaningful symlinks or network device
32 names provide a way to reliably identify devices based on their properties or
33 current configuration.</para>
34
35 <para>The udev daemon, <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle>
36 <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from
37 the kernel whenever a device is added or removed from the system, or it changes its
38 state. When udev receives a device event, it matches its configured set of rules
39 against various device attributes to identify the device. Rules that match may
40 provide additional device information to be stored in the udev database or
41 to be used to create meaningful symlink names.</para>
42
43 <para>All device information udev processes is stored in the udev database and
44 sent out to possible event subscribers. Access to all stored data and the event
45 sources is provided by the library libudev.</para>
46 </refsect1>
47
48 <refsect1>
49 <title>Rules Files</title>
50 <para>The udev rules are read from the files located in the system rules directories
51 <filename>/usr/lib/udev/rules.d</filename> and <filename>/usr/local/lib/udev/rules.d</filename>, the
52 volatile runtime directory <filename>/run/udev/rules.d</filename> and the local administration
53 directory <filename>/etc/udev/rules.d</filename>. All rules files are collectively sorted and
54 processed in lexical order, regardless of the directories in which they live. However, files with
55 identical filenames replace each other. Files in <filename>/etc/</filename> have the highest priority,
56 files in <filename>/run/</filename> take precedence over files with the same name under
57 <filename>/usr/</filename>. This can be used to override a system-supplied rules file with a local
58 file if needed; a symlink in <filename>/etc/</filename> with the same name as a rules file in
59 <filename>/usr/lib/</filename>, pointing to <filename>/dev/null</filename>, disables the rules file
60 entirely. Rule files must have the extension <filename>.rules</filename>; other extensions are
61 ignored.</para>
62
63 <para>Every line in the rules file contains at least one key-value pair.
64 Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
65 There are two kinds of keys: match and assignment.
66 If all match keys match against their values, the rule gets applied and the
67 assignment keys get the specified values assigned.</para>
68
69 <para>A matching rule may rename a network interface, add symlinks
70 pointing to the device node, or run a specified program as part of
71 the event handling.</para>
72
73 <para>A rule consists of a comma-separated list of one or more key-operator-value expressions.
74 Each expression has a distinct effect, depending on the key and operator used.</para>
75
76 <refsect2>
77 <title>Operators</title>
78 <variablelist>
79 <varlistentry>
80 <term><literal>==</literal></term>
81 <listitem>
82 <para>Compare for equality. (The specified key has the specified value.)</para>
83 </listitem>
84 </varlistentry>
85
86 <varlistentry>
87 <term><literal>!=</literal></term>
88 <listitem>
89 <para>Compare for inequality. (The specified key doesn't have the specified value, or the
90 specified key is not present at all.)
91 </para>
92 </listitem>
93 </varlistentry>
94
95 <varlistentry>
96 <term><literal>=</literal></term>
97 <listitem>
98 <para>Assign a value to a key. Keys that represent a list are reset
99 and only this single value is assigned.</para>
100 </listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><literal>+=</literal></term>
105 <listitem>
106 <para>Add the value to a key that holds a list of entries.</para>
107 </listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><literal>-=</literal></term>
112 <listitem>
113 <para>Remove the value from a key that holds a list of entries.</para>
114
115 <xi:include href="version-info.xml" xpointer="v217"/>
116 </listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><literal>:=</literal></term>
121 <listitem>
122 <para>Assign a value to a key finally; disallow any later changes.</para>
123
124 <xi:include href="version-info.xml" xpointer="v247"/>
125 </listitem>
126 </varlistentry>
127 </variablelist>
128 </refsect2>
129
130 <refsect2>
131 <title>Values</title>
132 <para>Values are written as double quoted strings, such as ("string").
133 To include a quotation mark (") in the value, precede it by a backslash (\").
134 Any other occurrences of a backslash followed by a character are not unescaped.
135 That is, "\t\n" is treated as four characters:
136 backslash, lowercase t, backslash, lowercase n.</para>
137
138 <para>The string can be prefixed with a lowercase e (e"string\n") to mark the string as
139 <ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C-style escaped</ulink>.
140 For example, e"string\n" is parsed as 7 characters: 6 lowercase letters and a newline.
141 This can be useful for writing special characters when a kernel driver requires them.</para>
142
143 <para>Please note that <constant>NUL</constant> is not allowed in either string variant.</para>
144 </refsect2>
145
146 <refsect2>
147 <title>Keys</title>
148 <para>The following key names can be used to match against device properties.
149 Some of the keys also match against properties of the parent devices in sysfs,
150 not only the device that has generated the event. If multiple keys that match
151 a parent device are specified in a single rule, all these keys must match at
152 one and the same parent device.</para>
153 <variablelist class='udev-directives'>
154 <varlistentry>
155 <term><varname>ACTION</varname></term>
156 <listitem>
157 <para>Match the name of the event action.</para>
158 </listitem>
159 </varlistentry>
160
161 <varlistentry>
162 <term><varname>DEVPATH</varname></term>
163 <listitem>
164 <para>Match the devpath of the event device.</para>
165 </listitem>
166 </varlistentry>
167
168 <varlistentry>
169 <term><varname>KERNEL</varname></term>
170 <listitem>
171 <para>Match the name of the event device.</para>
172 </listitem>
173 </varlistentry>
174
175 <varlistentry>
176 <term><varname>KERNELS</varname></term>
177 <listitem>
178 <para>Search the devpath upwards for a matching device name.</para>
179 </listitem>
180 </varlistentry>
181
182 <varlistentry>
183 <term><varname>NAME</varname></term>
184 <listitem>
185 <para>Match the name of a network interface. It can be used once the
186 NAME key has been set in one of the preceding rules.</para>
187 </listitem>
188 </varlistentry>
189
190 <varlistentry>
191 <term><varname>SYMLINK</varname></term>
192 <listitem>
193 <para>Match the name of a symlink targeting the node. It can be used once a SYMLINK key has
194 been set in one of the preceding rules. There may be multiple symlinks; only one needs to
195 match. If the operator is <literal>!=</literal>, the token returns true only if there is no
196 symlink matched.</para>
197 </listitem>
198 </varlistentry>
199
200 <varlistentry>
201 <term><varname>SUBSYSTEM</varname></term>
202 <listitem>
203 <para>Match the subsystem of the event device.</para>
204 </listitem>
205 </varlistentry>
206
207 <varlistentry>
208 <term><varname>SUBSYSTEMS</varname></term>
209 <listitem>
210 <para>Search the devpath upwards for a matching device subsystem name.</para>
211 </listitem>
212 </varlistentry>
213
214 <varlistentry>
215 <term><varname>DRIVER</varname></term>
216 <listitem>
217 <para>Match the driver name of the event device. Only set this key for devices
218 which are bound to a driver at the time the event is generated.</para>
219 </listitem>
220 </varlistentry>
221
222 <varlistentry>
223 <term><varname>DRIVERS</varname></term>
224 <listitem>
225 <para>Search the devpath upwards for a matching device driver name.</para>
226 </listitem>
227 </varlistentry>
228
229 <varlistentry>
230 <term><varname>ATTR{<replaceable>filename</replaceable>}</varname></term>
231 <listitem>
232 <para>Match sysfs attribute value of the event device.</para>
233
234 <para>Trailing whitespace in the attribute values is ignored unless the specified match value
235 itself contains trailing whitespace.</para>
236 </listitem>
237 </varlistentry>
238
239 <varlistentry>
240 <term><varname>ATTRS{<replaceable>filename</replaceable>}</varname></term>
241 <listitem>
242 <para>Search the devpath upwards for a device with matching sysfs attribute values. If
243 multiple <varname>ATTRS</varname> matches are specified, all of them must match on the same
244 device.</para>
245
246 <para>Trailing whitespace in the attribute values is ignored unless the specified match value
247 itself contains trailing whitespace.</para>
248 </listitem>
249 </varlistentry>
250
251 <varlistentry>
252 <term><varname>SYSCTL{<replaceable>kernel parameter</replaceable>}</varname></term>
253 <listitem>
254 <para>Match a kernel parameter value.</para>
255
256 <xi:include href="version-info.xml" xpointer="v240"/>
257 </listitem>
258 </varlistentry>
259
260 <varlistentry>
261 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
262 <listitem>
263 <para>Match against a device property value.</para>
264 </listitem>
265 </varlistentry>
266
267 <varlistentry>
268 <term><varname>CONST{<replaceable>key</replaceable>}</varname></term>
269 <listitem>
270 <para>Match against a system-wide constant. Supported keys are:</para>
271 <variablelist>
272 <varlistentry>
273 <term><literal>arch</literal></term>
274 <listitem>
275 <para>System's architecture. See <option>ConditionArchitecture=</option> in
276 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
277 for possible values.</para>
278
279 <xi:include href="version-info.xml" xpointer="v244"/>
280 </listitem>
281 </varlistentry>
282 <varlistentry>
283 <term><literal>virt</literal></term>
284 <listitem>
285 <para>System's virtualization environment. See
286 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
287 for possible values.</para>
288
289 <xi:include href="version-info.xml" xpointer="v244"/>
290 </listitem>
291 </varlistentry>
292 <varlistentry>
293 <term><literal>cvm</literal></term>
294 <listitem>
295 <para>System's confidential virtualization technology. See
296 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
297 for possible values.</para>
298
299 <xi:include href="version-info.xml" xpointer="v254"/>
300 </listitem>
301 </varlistentry>
302 </variablelist>
303 <para>Unknown keys will never match.</para>
304
305 <xi:include href="version-info.xml" xpointer="v244"/>
306 </listitem>
307 </varlistentry>
308
309 <varlistentry>
310 <term><varname>TAG</varname></term>
311 <listitem>
312 <para>Match against one of device tags. It can be used once a TAG key has been set in one of
313 the preceding rules. There may be multiple tags; only one needs to match. If the operator is
314 <literal>!=</literal>, the token returns true only if there is no tag matched.</para>
315 </listitem>
316 </varlistentry>
317
318 <varlistentry>
319 <term><varname>TAGS</varname></term>
320 <listitem>
321 <para>Search the devpath upwards for a device with matching tag. If the operator is
322 <literal>!=</literal>, the token returns true only if there is no tag matched.</para>
323 </listitem>
324 </varlistentry>
325
326 <varlistentry>
327 <term><varname>TEST{<replaceable>octal mode mask</replaceable>}</varname></term>
328 <listitem>
329 <para>Test the existence of a file. An octal mode mask can be specified
330 if needed.</para>
331 </listitem>
332 </varlistentry>
333
334 <varlistentry>
335 <term><varname>PROGRAM</varname></term>
336 <listitem>
337 <para>Execute a program to determine whether there is a match; the key is true if the program
338 returns successfully. The device properties are made available to the executed program in the
339 environment. The program's standard output is available in the <varname>RESULT</varname>
340 key.</para>
341
342 <para>This can only be used for very short-running foreground tasks. For details, see
343 <varname>RUN</varname>.</para>
344
345 <para>Note that multiple <varname>PROGRAM</varname> keys may be specified in one rule, and
346 <literal>=</literal>, <literal>:=</literal>, and <literal>+=</literal> have the same effect as
347 <literal>==</literal>.</para>
348 </listitem>
349 </varlistentry>
350
351 <varlistentry>
352 <term><varname>RESULT</varname></term>
353 <listitem>
354 <para>Match the returned string of the last <varname>PROGRAM</varname> call.
355 This key can be used in the same or in any later rule after a
356 <varname>PROGRAM</varname> call.</para>
357 </listitem>
358 </varlistentry>
359 </variablelist>
360
361 <para>Most of the fields support shell glob pattern matching and
362 alternate patterns. The following special characters are supported:</para>
363 <variablelist>
364 <varlistentry>
365 <term><literal>*</literal></term>
366 <listitem>
367 <para>Matches zero or more characters.</para>
368 </listitem>
369 </varlistentry>
370 <varlistentry>
371 <term><literal>?</literal></term>
372 <listitem>
373 <para>Matches any single character.</para>
374 </listitem>
375 </varlistentry>
376 <varlistentry>
377 <term><literal>[]</literal></term>
378 <listitem>
379 <para>Matches any single character specified within the brackets. For
380 example, the pattern string <literal>tty[SR]</literal>
381 would match either <literal>ttyS</literal> or <literal>ttyR</literal>.
382 Ranges are also supported via the <literal>-</literal> character.
383 For example, to match on the range of all digits, the pattern
384 <literal>[0-9]</literal> could be used. If the first character
385 following the <literal>[</literal> is a <literal>!</literal>,
386 any characters not enclosed are matched.</para>
387 </listitem>
388 </varlistentry>
389 <varlistentry>
390 <term><literal>|</literal></term>
391 <listitem>
392 <para>Separates alternative patterns. For example, the pattern string
393 <literal>abc|x*</literal> would match either <literal>abc</literal>
394 or <literal>x*</literal>.</para>
395
396 <xi:include href="version-info.xml" xpointer="v217"/>
397 </listitem>
398 </varlistentry>
399 </variablelist>
400
401 <para>The following keys can get values assigned:</para>
402 <variablelist class='udev-directives'>
403 <varlistentry>
404 <term><varname>NAME</varname></term>
405 <listitem>
406 <para>The name to use for a network interface. See
407 <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
408 for a higher-level mechanism for setting the interface name.
409 The name of a device node cannot be changed by udev, only additional
410 symlinks can be created.</para>
411 </listitem>
412 </varlistentry>
413
414 <varlistentry>
415 <term><varname>SYMLINK</varname></term>
416 <listitem>
417 <para>The name of a symlink targeting the node. Every matching rule adds
418 this value to the list of symlinks to be created.</para>
419 <para>The set of characters to name a symlink is limited. Allowed
420 characters are <literal>0-9A-Za-z#+-.:=@_/</literal>, valid UTF-8 character
421 sequences, and <literal>\x00</literal> hex encoding. All other
422 characters are replaced by a <literal>_</literal> character.</para>
423 <para>Multiple symlinks may be specified by separating the names by the
424 space character. In case multiple devices claim the same name, the link
425 always points to the device with the highest link_priority. If the current
426 device goes away, the links are re-evaluated and the device with the
427 next highest link_priority becomes the owner of the link. If no
428 link_priority is specified, the order of the devices (and which one of
429 them owns the link) is undefined.</para>
430 <para>Symlink names must never conflict with the kernel's default device
431 node names, as that would result in unpredictable behavior.
432 </para>
433 </listitem>
434 </varlistentry>
435
436 <varlistentry>
437 <term><varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname></term>
438 <listitem>
439 <para>The permissions for the device node. Every specified value overrides
440 the compiled-in default value.</para>
441 </listitem>
442 </varlistentry>
443
444 <varlistentry>
445 <term><varname>SECLABEL{<replaceable>module</replaceable>}</varname></term>
446 <listitem>
447 <para>Applies the specified Linux Security Module label to the device node.</para>
448
449 <xi:include href="version-info.xml" xpointer="v209"/>
450 </listitem>
451 </varlistentry>
452
453 <varlistentry>
454 <term><varname>ATTR{<replaceable>key</replaceable>}</varname></term>
455 <listitem>
456 <para>The value that should be written to a sysfs attribute of the
457 event device.</para>
458 </listitem>
459 </varlistentry>
460
461 <varlistentry>
462 <term><varname>SYSCTL{<replaceable>kernel parameter</replaceable>}</varname></term>
463 <listitem>
464 <para>The value that should be written to kernel parameter.</para>
465
466 <xi:include href="version-info.xml" xpointer="v220"/>
467 </listitem>
468 </varlistentry>
469
470 <varlistentry>
471 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
472 <listitem>
473 <para>Set a device property value. Property names with a leading <literal>.</literal>
474 are neither stored in the database nor exported to events or
475 external tools (run by, for example, the <varname>PROGRAM</varname>
476 match key).</para>
477 </listitem>
478 </varlistentry>
479
480 <varlistentry>
481 <term><varname>TAG</varname></term>
482 <listitem>
483 <para>Attach a tag to a device. This is used to filter events for users
484 of libudev's monitor functionality, or to enumerate a group of tagged
485 devices. The implementation can only work efficiently if only a few
486 tags are attached to a device. It is only meant to be used in
487 contexts with specific device filter requirements, and not as a
488 general-purpose flag. Excessive use might result in inefficient event
489 handling.</para>
490 </listitem>
491 </varlistentry>
492
493 <varlistentry>
494 <term><varname>RUN{<replaceable>type</replaceable>}</varname></term>
495 <listitem>
496 <para>Specify a program to be executed after processing of all the rules for the event. With
497 <literal>+=</literal>, this invocation is added to the list, and with <literal>=</literal> or
498 <literal>:=</literal>, it replaces any previous contents of the list. Please note that both
499 <literal>program</literal> and <literal>builtin</literal> types described below share a common
500 list, so clearing the list with <literal>:=</literal> and <literal>=</literal> affects both
501 types.</para>
502
503 <para><replaceable>type</replaceable> may be:</para>
504 <variablelist>
505 <varlistentry>
506 <term><literal>program</literal></term>
507 <listitem>
508 <para>Execute an external program specified as the assigned
509 value. If no absolute path is given, the program is expected
510 to live in <filename>/usr/lib/udev</filename>; otherwise, the
511 absolute path must be specified.</para>
512 <para>This is the default if no <replaceable>type</replaceable>
513 is specified.</para>
514 </listitem>
515 </varlistentry>
516 <varlistentry>
517 <term><literal>builtin</literal></term>
518 <listitem>
519 <para>As <varname>program</varname>, but use one of the
520 built-in programs rather than an external one.</para>
521
522 <xi:include href="version-info.xml" xpointer="v199"/>
523 </listitem>
524 </varlistentry>
525 </variablelist>
526
527 <para>The program name and following arguments are separated by spaces. Single quotes can be
528 used to specify arguments with spaces.</para>
529
530 <para>This can only be used for very short-running foreground tasks. Running an event process for
531 a long period of time may block all further events for this or a dependent device.</para>
532
533 <para>Note that running programs that access the network or mount/unmount filesystems is not
534 allowed inside of udev rules, due to the default sandbox that is enforced on
535 <filename>systemd-udevd.service</filename>.</para>
536
537 <para>Starting daemons or other long-running processes is not allowed; the forked processes,
538 detached or not, will be unconditionally killed after the event handling has finished. In order
539 to activate long-running processes from udev rules, provide a service unit and pull it in from a
540 udev device using the <varname>SYSTEMD_WANTS</varname> device property. See
541 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
542 for details.</para>
543 </listitem>
544 </varlistentry>
545
546 <varlistentry>
547 <term><varname>LABEL</varname></term>
548 <listitem>
549 <para>A named label to which a <varname>GOTO</varname> may jump.</para>
550 </listitem>
551 </varlistentry>
552
553 <varlistentry>
554 <term><varname>GOTO</varname></term>
555 <listitem>
556 <para>Jumps to the next <varname>LABEL</varname> with a matching name.</para>
557 </listitem>
558 </varlistentry>
559
560 <varlistentry>
561 <term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term>
562 <listitem>
563 <para>Import a set of variables as device properties, depending on
564 <replaceable>type</replaceable>:</para>
565
566 <variablelist>
567 <varlistentry>
568 <term><literal>program</literal></term>
569 <listitem>
570 <para>Execute an external program specified as the assigned
571 value and, if it returns successfully,
572 import its output, which must be in environment key
573 format. Path specification, command/argument separation,
574 and quoting work like in <varname>RUN</varname>.</para>
575
576 <xi:include href="version-info.xml" xpointer="v199"/>
577 </listitem>
578 </varlistentry>
579 <varlistentry>
580 <term><literal>builtin</literal></term>
581 <listitem>
582 <para>Similar to <literal>program</literal>, but use one of the
583 built-in programs rather than an external one.</para>
584
585 <xi:include href="version-info.xml" xpointer="v199"/>
586 </listitem>
587 </varlistentry>
588 <varlistentry>
589 <term><literal>file</literal></term>
590 <listitem>
591 <para>Import a text file specified as the assigned value, the content
592 of which must be in environment key format.</para>
593 </listitem>
594 </varlistentry>
595 <varlistentry>
596 <term><literal>db</literal></term>
597 <listitem>
598 <para>Import a single property specified as the assigned value from the
599 current device database. This works only if the database is already populated
600 by an earlier event.</para>
601 </listitem>
602 </varlistentry>
603 <varlistentry>
604 <term><literal>cmdline</literal></term>
605 <listitem>
606 <para>Import a single property from the kernel command line. For simple flags
607 the value of the property is set to <literal>1</literal>.</para>
608 </listitem>
609 </varlistentry>
610 <varlistentry>
611 <term><literal>parent</literal></term>
612 <listitem>
613 <para>Import the stored keys from the parent device by reading
614 the database entry of the parent device. The value assigned to
615 <option>IMPORT{parent}</option> is used as a filter of key names
616 to import (with the same shell glob pattern matching used for
617 comparisons).</para>
618 </listitem>
619 </varlistentry>
620 </variablelist>
621
622 <para>This can only be used for very short-running foreground tasks. For details see
623 <option>RUN</option>.</para>
624
625 <para>Note that multiple <varname>IMPORT{}</varname> keys may be specified in one rule, and
626 <literal>=</literal>, <literal>:=</literal>, and <literal>+=</literal> have the same effect as
627 <literal>==</literal>. The key is true if the import is successful, unless <literal>!=</literal>
628 is used as the operator which causes the key to be true if the import failed.</para>
629 </listitem>
630 </varlistentry>
631
632 <varlistentry>
633 <term><varname>OPTIONS</varname></term>
634 <listitem>
635 <para>Rule and device options:</para>
636 <variablelist class='udev-directives'>
637 <varlistentry>
638 <term><option>link_priority=<replaceable>value</replaceable></option></term>
639 <listitem>
640 <para>Specify the priority of the created symlinks. Devices with higher
641 priorities overwrite existing symlinks of other devices. The default is 0.</para>
642 </listitem>
643 </varlistentry>
644 <varlistentry>
645 <term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
646 <listitem>
647 <para>When <literal>replace</literal>, possibly unsafe characters in strings
648 assigned to <varname>NAME</varname>, <varname>SYMLINK</varname>, and
649 <varname>ENV{<replaceable>key</replaceable>}</varname> are replaced. When
650 <literal>none</literal>, no replacement is performed. When unset, the replacement
651 is performed for <varname>NAME</varname>, <varname>SYMLINK</varname>, but not for
652 <varname>ENV{<replaceable>key</replaceable>}</varname>. Defaults to unset.</para>
653 </listitem>
654 </varlistentry>
655 <varlistentry>
656 <term><option>static_node=</option></term>
657 <listitem>
658 <para>Apply the permissions specified in this rule to the
659 static device node with the specified name. Also, for every
660 tag specified in this rule, create a symlink
661 in the directory
662 <filename>/run/udev/static_node-tags/<replaceable>tag</replaceable></filename>
663 pointing at the static device node with the specified name.
664 Static device node creation is performed by systemd-tmpfiles
665 before systemd-udevd is started. The static nodes might not
666 have a corresponding kernel device; they are used to trigger
667 automatic kernel module loading when they are accessed.</para>
668 </listitem>
669 </varlistentry>
670 <varlistentry>
671 <term><option>watch</option></term>
672 <listitem>
673 <para>Watch the device node with inotify; when the node is
674 closed after being opened for writing, a change uevent is
675 synthesized.</para>
676 </listitem>
677 </varlistentry>
678 <varlistentry>
679 <term><option>nowatch</option></term>
680 <listitem>
681 <para>Disable the watching of a device node with inotify.</para>
682 </listitem>
683 </varlistentry>
684 <varlistentry>
685 <term><option>db_persist</option></term>
686 <listitem>
687 <para>Set the flag (sticky bit) on the udev database entry of the event device. Device
688 properties are then kept in the database even when <command>udevadm info
689 --cleanup-db</command> is called. This option can be useful in certain cases
690 (e.g. Device Mapper devices) for persisting device state on the transition from
691 initrd.</para>
692
693 <xi:include href="version-info.xml" xpointer="v241"/>
694 </listitem>
695 </varlistentry>
696 <varlistentry>
697 <term><option>log_level=<replaceable>level</replaceable></option></term>
698 <listitem>
699 <para>Takes a log level name like <literal>debug</literal> or
700 <literal>info</literal>, or a special value <literal>reset</literal>. When a log
701 level name is specified, the maximum log level is changed to that level. When
702 <literal>reset</literal> is set, then the previously specified log level is
703 revoked. Defaults to the log level of the main process of
704 <command>systemd-udevd</command>.</para>
705 <para>This may be useful when debugging events for certain devices. Note that the
706 log level is applied when the line including this rule is processed. So, for
707 debugging, it is recommended that this is specified at earlier place, e.g., the
708 first line of <filename>00-debug.rules</filename>.</para>
709 <para>Example for debugging uevent processing for network interfaces:
710 <programlisting># /etc/udev/rules.d/00-debug-net.rules
711 SUBSYSTEM=="net", OPTIONS="log_level=debug"</programlisting></para>
712
713 <xi:include href="version-info.xml" xpointer="v248"/>
714 </listitem>
715 </varlistentry>
716 </variablelist>
717 </listitem>
718 </varlistentry>
719 </variablelist>
720
721 <para>The <varname>NAME</varname>, <varname>SYMLINK</varname>,
722 <varname>PROGRAM</varname>, <varname>OWNER</varname>,
723 <varname>GROUP</varname>, <varname>MODE</varname>, <varname>SECLABEL</varname>,
724 and <varname>RUN</varname> fields support simple string substitutions.
725 The <varname>RUN</varname> substitutions are performed after all rules
726 have been processed, right before the program is executed, allowing for
727 the use of device properties set by earlier matching rules. For all other
728 fields, substitutions are performed while the individual rule is being
729 processed. The available substitutions are:</para>
730 <variablelist class='udev-directives'>
731 <varlistentry>
732 <term><option>$kernel</option>, <option>%k</option></term>
733 <listitem>
734 <para>The kernel name for this device.</para>
735 </listitem>
736 </varlistentry>
737
738 <varlistentry>
739 <term><option>$number</option>, <option>%n</option></term>
740 <listitem>
741 <para>The kernel number for this device. For example, <literal>sda3</literal> has kernel number
742 3.</para>
743 </listitem>
744 </varlistentry>
745
746 <varlistentry>
747 <term><option>$devpath</option>, <option>%p</option></term>
748 <listitem>
749 <para>The devpath of the device.</para>
750 </listitem>
751 </varlistentry>
752
753 <varlistentry>
754 <term><option>$id</option>, <option>%b</option></term>
755 <listitem>
756 <para>The name of the device matched while searching the devpath
757 upwards for <option>SUBSYSTEMS</option>, <option>KERNELS</option>,
758 <option>DRIVERS</option>, and <option>ATTRS</option>.
759 </para>
760 </listitem>
761 </varlistentry>
762
763 <varlistentry>
764 <term><option>$driver</option></term>
765 <listitem>
766 <para>The driver name of the device matched while searching the
767 devpath upwards for <option>SUBSYSTEMS</option>,
768 <option>KERNELS</option>, <option>DRIVERS</option>, and
769 <option>ATTRS</option>.
770 </para>
771 </listitem>
772 </varlistentry>
773
774 <varlistentry>
775 <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
776 <listitem>
777 <para>The value of a sysfs attribute found at the device where
778 all keys of the rule have matched. If the matching device does not
779 have such an attribute, and a previous <option>KERNELS</option>,
780 <option>SUBSYSTEMS</option>, <option>DRIVERS</option>, or
781 <option>ATTRS</option> test selected a parent device, then the
782 attribute from that parent device is used.
783 </para>
784 <para>If the attribute is a symlink, the last element of the
785 symlink target is returned as the value.
786 </para>
787 </listitem>
788 </varlistentry>
789
790 <varlistentry>
791 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
792 <listitem>
793 <para>A device property value.</para>
794 </listitem>
795 </varlistentry>
796
797 <varlistentry>
798 <term><option>$major</option>, <option>%M</option></term>
799 <listitem>
800 <para>The kernel major number for the device.</para>
801 </listitem>
802 </varlistentry>
803
804 <varlistentry>
805 <term><option>$minor</option>, <option>%m</option></term>
806 <listitem>
807 <para>The kernel minor number for the device.</para>
808 </listitem>
809 </varlistentry>
810
811 <varlistentry>
812 <term><option>$result</option>, <option>%c</option></term>
813 <listitem>
814 <para>The string returned by the external program requested with
815 <varname>PROGRAM</varname>.
816 A single part of the string, separated by a space character, may be selected
817 by specifying the part number as an attribute: <literal>%c{N}</literal>.
818 If the number is followed by the <literal>+</literal> character, this part plus all remaining parts
819 of the result string are substituted: <literal>%c{N+}</literal>.</para>
820 </listitem>
821 </varlistentry>
822
823 <varlistentry>
824 <term><option>$parent</option>, <option>%P</option></term>
825 <listitem>
826 <para>The node name of the parent device.</para>
827 </listitem>
828 </varlistentry>
829
830 <varlistentry>
831 <term><option>$name</option></term>
832 <listitem>
833 <para>The current name of the device. If not changed by a rule, it is the
834 name of the kernel device.</para>
835 </listitem>
836 </varlistentry>
837
838 <varlistentry>
839 <term><option>$links</option></term>
840 <listitem>
841 <para>A space-separated list of the current symlinks. The value is
842 only set during a remove event or if an earlier rule assigned a value.</para>
843 </listitem>
844 </varlistentry>
845
846 <varlistentry>
847 <term><option>$root</option>, <option>%r</option></term>
848 <listitem>
849 <para>The udev_root value.</para>
850 </listitem>
851 </varlistentry>
852
853 <varlistentry>
854 <term><option>$sys</option>, <option>%S</option></term>
855 <listitem>
856 <para>The sysfs mount point.</para>
857 </listitem>
858 </varlistentry>
859
860 <varlistentry>
861 <term><option>$devnode</option>, <option>%N</option></term>
862 <listitem>
863 <para>The name of the device node.</para>
864 </listitem>
865 </varlistentry>
866
867 <varlistentry>
868 <term><option>%%</option></term>
869 <listitem>
870 <para>The <literal>%</literal> character itself.</para>
871 </listitem>
872 </varlistentry>
873
874 <varlistentry>
875 <term><option>$$</option></term>
876 <listitem>
877 <para>The <literal>$</literal> character itself.</para>
878 </listitem>
879 </varlistentry>
880 </variablelist>
881 </refsect2>
882 </refsect1>
883
884 <refsect1>
885 <title>See Also</title>
886 <para>
887 <citerefentry>
888 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
889 </citerefentry>,
890 <citerefentry>
891 <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
892 </citerefentry>,
893 <citerefentry>
894 <refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum>
895 </citerefentry>
896 </para>
897 </refsect1>
898 </refentry>