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