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