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