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