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