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