]>
Commit | Line | Data |
---|---|---|
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 | |
f48f7543 ZJS |
12 | --> |
13 | ||
63749b1a KS |
14 | <refentry id="udev"> |
15 | <refentryinfo> | |
7b86ada7 | 16 | <title>udev</title> |
d3a2386d KS |
17 | <productname>systemd</productname> |
18 | <authorgroup> | |
19 | <author> | |
20 | <contrib>Developer</contrib> | |
21 | <firstname>Greg</firstname> | |
22 | <surname>Kroah-Hartmann</surname> | |
23 | <email>greg@kroah.com</email> | |
24 | </author> | |
25 | <author> | |
26 | <contrib>Developer</contrib> | |
27 | <firstname>Kay</firstname> | |
28 | <surname>Sievers</surname> | |
29 | <email>kay@vrfy.org</email> | |
30 | </author> | |
31 | </authorgroup> | |
63749b1a KS |
32 | </refentryinfo> |
33 | ||
34 | <refmeta> | |
35 | <refentrytitle>udev</refentrytitle> | |
36 | <manvolnum>7</manvolnum> | |
37 | </refmeta> | |
38 | ||
39 | <refnamediv> | |
40 | <refname>udev</refname> | |
eb75d0ed | 41 | <refpurpose>Dynamic device management</refpurpose> |
63749b1a KS |
42 | </refnamediv> |
43 | ||
44 | <refsect1><title>Description</title> | |
45 | <para>udev supplies the system software with device events, manages permissions | |
46 | of device nodes and may create additional symlinks in the <filename>/dev</filename> | |
47 | directory, or renames network interfaces. The kernel usually just assigns unpredictable | |
48 | device names based on the order of discovery. Meaningful symlinks or network device | |
49 | names provide a way to reliably identify devices based on their properties or | |
50 | current configuration.</para> | |
51 | ||
b79f817b | 52 | <para>The udev daemon, <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle> |
0e4fa2ab | 53 | <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from |
63749b1a KS |
54 | the kernel whenever a device is added or removed from the system, or it changes its |
55 | state. When udev receives a device event, it matches its configured set of rules | |
0e846301 MW |
56 | against various device attributes to identify the device. Rules that match may |
57 | provide additional device information to be stored in the udev database or | |
63749b1a KS |
58 | to be used to create meaningful symlink names.</para> |
59 | ||
0e846301 | 60 | <para>All device information udev processes is stored in the udev database and |
63749b1a | 61 | sent out to possible event subscribers. Access to all stored data and the event |
17fd0f60 | 62 | sources is provided by the library libudev.</para> |
63749b1a KS |
63 | </refsect1> |
64 | ||
eb75d0ed | 65 | <refsect1><title>Rules Files</title> |
63749b1a | 66 | <para>The udev rules are read from the files located in the |
12b42c76 | 67 | system rules directory <filename>/usr/lib/udev/rules.d</filename>, |
91418155 KS |
68 | the volatile runtime directory <filename>/run/udev/rules.d</filename> |
69 | and the local administration directory <filename>/etc/udev/rules.d</filename>. | |
1021e6df KS |
70 | All rules files are collectively sorted and processed in lexical order, |
71 | regardless of the directories in which they live. However, files with | |
e9dd9f95 | 72 | identical filenames replace each other. Files in <filename>/etc</filename> |
91418155 | 73 | have the highest priority, files in <filename>/run</filename> take precedence |
12b42c76 | 74 | over files with the same name in <filename>/usr/lib</filename>. This can be |
91418155 KS |
75 | used to override a system-supplied rules file with a local file if needed; |
76 | a symlink in <filename>/etc</filename> with the same name as a rules file in | |
12b42c76 | 77 | <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>, |
eb75d0ed KS |
78 | disables the rules file entirely. Rule files must have the extension |
79 | <filename>.rules</filename>; other extensions are ignored.</para> | |
63749b1a | 80 | |
feedf8f3 | 81 | <para>Every line in the rules file contains at least one key-value pair. |
909f413d | 82 | Except for empty lines or lines beginning with <literal>#</literal>, which are ignored. |
bb31a4ac | 83 | There are two kinds of keys: match and assignment. |
6ec0ac43 TG |
84 | If all match keys match against their values, the rule gets applied and the |
85 | assignment keys get the specified values assigned.</para> | |
63749b1a KS |
86 | |
87 | <para>A matching rule may rename a network interface, add symlinks | |
88 | pointing to the device node, or run a specified program as part of | |
89 | the event handling.</para> | |
90 | ||
55f5037c MW |
91 | <para>A rule consists of a comma-separated list of one or more key-value pairs. |
92 | Each key has a distinct operation, depending on the used operator. Valid | |
63749b1a KS |
93 | operators are:</para> |
94 | <variablelist> | |
95 | <varlistentry> | |
6b76fa66 | 96 | <term><literal>==</literal></term> |
63749b1a KS |
97 | <listitem> |
98 | <para>Compare for equality.</para> | |
99 | </listitem> | |
100 | </varlistentry> | |
101 | ||
102 | <varlistentry> | |
6b76fa66 | 103 | <term><literal>!=</literal></term> |
63749b1a KS |
104 | <listitem> |
105 | <para>Compare for inequality.</para> | |
106 | </listitem> | |
107 | </varlistentry> | |
108 | ||
109 | <varlistentry> | |
6b76fa66 | 110 | <term><literal>=</literal></term> |
63749b1a | 111 | <listitem> |
0e846301 | 112 | <para>Assign a value to a key. Keys that represent a list are reset |
63749b1a KS |
113 | and only this single value is assigned.</para> |
114 | </listitem> | |
115 | </varlistentry> | |
116 | ||
117 | <varlistentry> | |
6b76fa66 | 118 | <term><literal>+=</literal></term> |
63749b1a KS |
119 | <listitem> |
120 | <para>Add the value to a key that holds a list of entries.</para> | |
121 | </listitem> | |
122 | </varlistentry> | |
123 | ||
8e3ba377 DH |
124 | <varlistentry> |
125 | <term><literal>-=</literal></term> | |
126 | <listitem> | |
127 | <para>Remove the value from a key that holds a list of entries.</para> | |
128 | </listitem> | |
129 | </varlistentry> | |
130 | ||
63749b1a | 131 | <varlistentry> |
6b76fa66 | 132 | <term><literal>:=</literal></term> |
63749b1a | 133 | <listitem> |
2bf11540 | 134 | <para>Assign a value to a key finally; disallow any later changes.</para> |
63749b1a KS |
135 | </listitem> |
136 | </varlistentry> | |
137 | </variablelist> | |
138 | ||
139 | <para>The following key names can be used to match against device properties. | |
140 | Some of the keys also match against properties of the parent devices in sysfs, | |
141 | not only the device that has generated the event. If multiple keys that match | |
142 | a parent device are specified in a single rule, all these keys must match at | |
143 | one and the same parent device.</para> | |
ccc9a4f9 | 144 | <variablelist class='udev-directives'> |
63749b1a | 145 | <varlistentry> |
909f413d | 146 | <term><varname>ACTION</varname></term> |
63749b1a KS |
147 | <listitem> |
148 | <para>Match the name of the event action.</para> | |
149 | </listitem> | |
150 | </varlistentry> | |
151 | ||
152 | <varlistentry> | |
909f413d | 153 | <term><varname>DEVPATH</varname></term> |
63749b1a KS |
154 | <listitem> |
155 | <para>Match the devpath of the event device.</para> | |
156 | </listitem> | |
157 | </varlistentry> | |
158 | ||
159 | <varlistentry> | |
909f413d | 160 | <term><varname>KERNEL</varname></term> |
63749b1a KS |
161 | <listitem> |
162 | <para>Match the name of the event device.</para> | |
163 | </listitem> | |
164 | </varlistentry> | |
165 | ||
166 | <varlistentry> | |
909f413d | 167 | <term><varname>NAME</varname></term> |
63749b1a | 168 | <listitem> |
220893b3 KS |
169 | <para>Match the name of a network interface. It can be used once the |
170 | NAME key has been set in one of the preceding rules.</para> | |
63749b1a KS |
171 | </listitem> |
172 | </varlistentry> | |
173 | ||
174 | <varlistentry> | |
909f413d | 175 | <term><varname>SYMLINK</varname></term> |
63749b1a KS |
176 | <listitem> |
177 | <para>Match the name of a symlink targeting the node. It can | |
178 | be used once a SYMLINK key has been set in one of the preceding | |
179 | rules. There may be multiple symlinks; only one needs to match. | |
180 | </para> | |
181 | </listitem> | |
182 | </varlistentry> | |
183 | ||
184 | <varlistentry> | |
909f413d | 185 | <term><varname>SUBSYSTEM</varname></term> |
63749b1a KS |
186 | <listitem> |
187 | <para>Match the subsystem of the event device.</para> | |
188 | </listitem> | |
189 | </varlistentry> | |
190 | <varlistentry> | |
909f413d | 191 | <term><varname>DRIVER</varname></term> |
63749b1a | 192 | <listitem> |
2e7f69eb | 193 | <para>Match the driver name of the event device. Only set this key for devices |
63749b1a KS |
194 | which are bound to a driver at the time the event is generated.</para> |
195 | </listitem> | |
196 | </varlistentry> | |
197 | <varlistentry> | |
909f413d | 198 | <term><varname>ATTR{<replaceable>filename</replaceable>}</varname></term> |
63749b1a KS |
199 | <listitem> |
200 | <para>Match sysfs attribute values of the event device. Trailing | |
65e039c2 MW |
201 | whitespace in the attribute values is ignored unless the specified match |
202 | value itself contains trailing whitespace. | |
63749b1a KS |
203 | </para> |
204 | </listitem> | |
f4cf2e5b KS |
205 | <term><varname>SYSCTL{<replaceable>kernel parameter</replaceable>}</varname></term> |
206 | <listitem> | |
207 | <para>Match a kernel parameter value. | |
208 | </para> | |
209 | </listitem> | |
63749b1a KS |
210 | </varlistentry> |
211 | ||
212 | <varlistentry> | |
909f413d | 213 | <term><varname>KERNELS</varname></term> |
63749b1a KS |
214 | <listitem> |
215 | <para>Search the devpath upwards for a matching device name.</para> | |
216 | </listitem> | |
217 | </varlistentry> | |
218 | ||
219 | <varlistentry> | |
909f413d | 220 | <term><varname>SUBSYSTEMS</varname></term> |
63749b1a KS |
221 | <listitem> |
222 | <para>Search the devpath upwards for a matching device subsystem name.</para> | |
223 | </listitem> | |
224 | </varlistentry> | |
225 | ||
226 | <varlistentry> | |
909f413d | 227 | <term><varname>DRIVERS</varname></term> |
63749b1a KS |
228 | <listitem> |
229 | <para>Search the devpath upwards for a matching device driver name.</para> | |
230 | </listitem> | |
231 | </varlistentry> | |
232 | ||
233 | <varlistentry> | |
909f413d | 234 | <term><varname>ATTRS{<replaceable>filename</replaceable>}</varname></term> |
63749b1a KS |
235 | <listitem> |
236 | <para>Search the devpath upwards for a device with matching sysfs attribute values. | |
909f413d | 237 | If multiple <varname>ATTRS</varname> matches are specified, all of them |
65e039c2 MW |
238 | must match on the same device. Trailing whitespace in the attribute values is ignored |
239 | unless the specified match value itself contains trailing whitespace.</para> | |
63749b1a KS |
240 | </listitem> |
241 | </varlistentry> | |
242 | ||
7df0ed83 | 243 | <varlistentry> |
909f413d | 244 | <term><varname>TAGS</varname></term> |
7df0ed83 KS |
245 | <listitem> |
246 | <para>Search the devpath upwards for a device with matching tag.</para> | |
247 | </listitem> | |
248 | </varlistentry> | |
249 | ||
63749b1a | 250 | <varlistentry> |
909f413d | 251 | <term><varname>ENV{<replaceable>key</replaceable>}</varname></term> |
63749b1a KS |
252 | <listitem> |
253 | <para>Match against a device property value.</para> | |
254 | </listitem> | |
255 | </varlistentry> | |
256 | ||
257 | <varlistentry> | |
909f413d | 258 | <term><varname>TAG</varname></term> |
63749b1a KS |
259 | <listitem> |
260 | <para>Match against a device tag.</para> | |
261 | </listitem> | |
262 | </varlistentry> | |
263 | ||
264 | <varlistentry> | |
909f413d | 265 | <term><varname>TEST{<replaceable>octal mode mask</replaceable>}</varname></term> |
63749b1a KS |
266 | <listitem> |
267 | <para>Test the existence of a file. An octal mode mask can be specified | |
268 | if needed.</para> | |
269 | </listitem> | |
270 | </varlistentry> | |
271 | ||
272 | <varlistentry> | |
909f413d | 273 | <term><varname>PROGRAM</varname></term> |
63749b1a | 274 | <listitem> |
2e9820e3 MW |
275 | <para>Execute a program to determine whether there |
276 | is a match; the key is true if the program returns | |
63749b1a | 277 | successfully. The device properties are made available to the |
f131770b | 278 | executed program in the environment. The program's standard output |
bcddd5bf JSJ |
279 | is available in the <varname>RESULT</varname> key.</para> |
280 | <para>This can only be used for very short-running foreground tasks. For details, | |
909f413d | 281 | see <varname>RUN</varname>.</para> |
63749b1a KS |
282 | </listitem> |
283 | </varlistentry> | |
284 | ||
285 | <varlistentry> | |
909f413d | 286 | <term><varname>RESULT</varname></term> |
63749b1a | 287 | <listitem> |
bcddd5bf JSJ |
288 | <para>Match the returned string of the last <varname>PROGRAM</varname> call. |
289 | This key can be used in the same or in any later rule after a | |
290 | <varname>PROGRAM</varname> call.</para> | |
63749b1a KS |
291 | </listitem> |
292 | </varlistentry> | |
293 | </variablelist> | |
294 | ||
bf2e0ece AB |
295 | <para>Most of the fields support shell glob pattern matching and |
296 | alternate patterns. The following special characters are supported:</para> | |
63749b1a KS |
297 | <variablelist> |
298 | <varlistentry> | |
6b76fa66 | 299 | <term><literal>*</literal></term> |
63749b1a | 300 | <listitem> |
954e9c52 | 301 | <para>Matches zero or more characters.</para> |
63749b1a KS |
302 | </listitem> |
303 | </varlistentry> | |
304 | <varlistentry> | |
6b76fa66 | 305 | <term><literal>?</literal></term> |
63749b1a KS |
306 | <listitem> |
307 | <para>Matches any single character.</para> | |
308 | </listitem> | |
309 | </varlistentry> | |
310 | <varlistentry> | |
6b76fa66 | 311 | <term><literal>[]</literal></term> |
63749b1a KS |
312 | <listitem> |
313 | <para>Matches any single character specified within the brackets. For | |
909f413d ZJS |
314 | example, the pattern string <literal>tty[SR]</literal> |
315 | would match either <literal>ttyS</literal> or <literal>ttyR</literal>. | |
316 | Ranges are also supported via the <literal>-</literal> character. | |
bcddd5bf JSJ |
317 | For example, to match on the range of all digits, the pattern |
318 | <literal>[0-9]</literal> could be used. If the first character | |
319 | following the <literal>[</literal> is a <literal>!</literal>, | |
320 | any characters not enclosed are matched.</para> | |
63749b1a KS |
321 | </listitem> |
322 | </varlistentry> | |
bf2e0ece AB |
323 | <varlistentry> |
324 | <term><literal>|</literal></term> | |
325 | <listitem> | |
326 | <para>Separates alternative patterns. For example, the pattern string | |
327 | <literal>abc|x*</literal> would match either <literal>abc</literal> | |
328 | or <literal>x*</literal>.</para> | |
329 | </listitem> | |
330 | </varlistentry> | |
63749b1a KS |
331 | </variablelist> |
332 | ||
333 | <para>The following keys can get values assigned:</para> | |
ccc9a4f9 | 334 | <variablelist class='udev-directives'> |
63749b1a | 335 | <varlistentry> |
909f413d | 336 | <term><varname>NAME</varname></term> |
63749b1a | 337 | <listitem> |
1ff28eae TG |
338 | <para>The name to use for a network interface. See |
339 | <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
340 | for a higher-level mechanism for setting the interface name. | |
341 | The name of a device node cannot be changed by udev, only additional | |
342 | symlinks can be created.</para> | |
63749b1a KS |
343 | </listitem> |
344 | </varlistentry> | |
345 | ||
346 | <varlistentry> | |
909f413d | 347 | <term><varname>SYMLINK</varname></term> |
63749b1a | 348 | <listitem> |
933b5623 | 349 | <para>The name of a symlink targeting the node. Every matching rule adds |
b1239c3f KS |
350 | this value to the list of symlinks to be created.</para> |
351 | <para>The set of characters to name a symlink is limited. Allowed | |
909f413d ZJS |
352 | characters are <literal>0-9A-Za-z#+-.:=@_/</literal>, valid UTF-8 character |
353 | sequences, and <literal>\x00</literal> hex encoding. All other | |
354 | characters are replaced by a <literal>_</literal> character.</para> | |
b1239c3f KS |
355 | <para>Multiple symlinks may be specified by separating the names by the |
356 | space character. In case multiple devices claim the same name, the link | |
357 | always points to the device with the highest link_priority. If the current | |
358 | device goes away, the links are re-evaluated and the device with the | |
359 | next highest link_priority becomes the owner of the link. If no | |
360 | link_priority is specified, the order of the devices (and which one of | |
361 | them owns the link) is undefined.</para> | |
362 | <para>Symlink names must never conflict with the kernel's default device | |
363 | node names, as that would result in unpredictable behavior. | |
63749b1a KS |
364 | </para> |
365 | </listitem> | |
366 | </varlistentry> | |
367 | ||
368 | <varlistentry> | |
909f413d | 369 | <term><varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname></term> |
63749b1a | 370 | <listitem> |
91418155 | 371 | <para>The permissions for the device node. Every specified value overrides |
63749b1a KS |
372 | the compiled-in default value.</para> |
373 | </listitem> | |
374 | </varlistentry> | |
375 | ||
c26547d6 KS |
376 | <varlistentry> |
377 | <term><varname>SECLABEL{<replaceable>module</replaceable>}</varname></term> | |
378 | <listitem> | |
379 | <para>Applies the specified Linux Security Module label to the device node.</para> | |
380 | </listitem> | |
381 | </varlistentry> | |
382 | ||
63749b1a | 383 | <varlistentry> |
909f413d | 384 | <term><varname>ATTR{<replaceable>key</replaceable>}</varname></term> |
63749b1a KS |
385 | <listitem> |
386 | <para>The value that should be written to a sysfs attribute of the | |
387 | event device.</para> | |
388 | </listitem> | |
389 | </varlistentry> | |
390 | ||
f4cf2e5b KS |
391 | <varlistentry> |
392 | <term><varname>SYSCTL{<replaceable>kernel parameter</replaceable>}</varname></term> | |
393 | <listitem> | |
394 | <para>The value that should be written to kernel parameter.</para> | |
395 | </listitem> | |
396 | </varlistentry> | |
397 | ||
63749b1a | 398 | <varlistentry> |
909f413d | 399 | <term><varname>ENV{<replaceable>key</replaceable>}</varname></term> |
63749b1a | 400 | <listitem> |
909f413d | 401 | <para>Set a device property value. Property names with a leading <literal>.</literal> |
ed9c5fb7 | 402 | are neither stored in the database nor exported to events or |
bcddd5bf JSJ |
403 | external tools (run by, for example, the <varname>PROGRAM</varname> |
404 | match key).</para> | |
63749b1a KS |
405 | </listitem> |
406 | </varlistentry> | |
407 | ||
408 | <varlistentry> | |
909f413d | 409 | <term><varname>TAG</varname></term> |
63749b1a KS |
410 | <listitem> |
411 | <para>Attach a tag to a device. This is used to filter events for users | |
412 | of libudev's monitor functionality, or to enumerate a group of tagged | |
413 | devices. The implementation can only work efficiently if only a few | |
414 | tags are attached to a device. It is only meant to be used in | |
415 | contexts with specific device filter requirements, and not as a | |
416 | general-purpose flag. Excessive use might result in inefficient event | |
417 | handling.</para> | |
418 | </listitem> | |
419 | </varlistentry> | |
420 | ||
421 | <varlistentry> | |
909f413d | 422 | <term><varname>RUN{<replaceable>type</replaceable>}</varname></term> |
63749b1a | 423 | <listitem> |
bcddd5bf JSJ |
424 | <para>Add a program to the list of programs to be executed after |
425 | processing all the rules for a specific event, depending on | |
426 | <literal>type</literal>:</para> | |
72c6cf8f TG |
427 | <variablelist> |
428 | <varlistentry> | |
429 | <term><literal>program</literal></term> | |
430 | <listitem> | |
431 | <para>Execute an external program specified as the assigned | |
bcddd5bf | 432 | value. If no absolute path is given, the program is expected |
12b42c76 | 433 | to live in <filename>/usr/lib/udev</filename>; otherwise, the |
bcddd5bf JSJ |
434 | absolute path must be specified.</para> |
435 | <para>This is the default if no <replaceable>type</replaceable> | |
436 | is specified.</para> | |
72c6cf8f TG |
437 | </listitem> |
438 | </varlistentry> | |
439 | <varlistentry> | |
440 | <term><literal>builtin</literal></term> | |
441 | <listitem> | |
bcddd5bf JSJ |
442 | <para>As <varname>program</varname>, but use one of the |
443 | built-in programs rather than an external one.</para> | |
72c6cf8f TG |
444 | </listitem> |
445 | </varlistentry> | |
446 | </variablelist> | |
447 | <para>The program name and following arguments are separated by spaces. | |
448 | Single quotes can be used to specify arguments with spaces.</para> | |
b45f770f | 449 | <para>This can only be used for very short-running foreground tasks. Running an |
2b76eb68 | 450 | event process for a long period of time may block all further events for |
b45f770f | 451 | this or a dependent device.</para> |
bcddd5bf | 452 | <para>Starting daemons or other long-running processes is not appropriate |
b45f770f KS |
453 | for udev; the forked processes, detached or not, will be unconditionally |
454 | killed after the event handling has finished.</para> | |
877dce40 MS |
455 | <para>Note that running programs that access the network or mount/unmount |
456 | filesystems is not allowed inside of udev rules, due to the default sandbox | |
457 | that is enforced on <filename>systemd-udevd.service</filename>.</para> | |
63749b1a KS |
458 | </listitem> |
459 | </varlistentry> | |
460 | ||
461 | <varlistentry> | |
909f413d | 462 | <term><varname>LABEL</varname></term> |
63749b1a | 463 | <listitem> |
bcddd5bf | 464 | <para>A named label to which a <varname>GOTO</varname> may jump.</para> |
63749b1a KS |
465 | </listitem> |
466 | </varlistentry> | |
467 | ||
468 | <varlistentry> | |
909f413d | 469 | <term><varname>GOTO</varname></term> |
63749b1a | 470 | <listitem> |
bcddd5bf | 471 | <para>Jumps to the next <varname>LABEL</varname> with a matching name.</para> |
63749b1a KS |
472 | </listitem> |
473 | </varlistentry> | |
474 | ||
475 | <varlistentry> | |
909f413d | 476 | <term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term> |
63749b1a KS |
477 | <listitem> |
478 | <para>Import a set of variables as device properties, | |
6b76fa66 | 479 | depending on <literal>type</literal>:</para> |
63749b1a KS |
480 | <variablelist> |
481 | <varlistentry> | |
6b76fa66 | 482 | <term><literal>program</literal></term> |
63749b1a | 483 | <listitem> |
9de4d0ce | 484 | <para>Execute an external program specified as the assigned |
b938cb90 | 485 | value and, if it returns successfully, |
63749b1a KS |
486 | import its output, which must be in environment key |
487 | format. Path specification, command/argument separation, | |
909f413d | 488 | and quoting work like in <varname>RUN</varname>.</para> |
63749b1a KS |
489 | </listitem> |
490 | </varlistentry> | |
491 | <varlistentry> | |
72c6cf8f TG |
492 | <term><literal>builtin</literal></term> |
493 | <listitem> | |
909f413d ZJS |
494 | <para>Similar to <literal>program</literal>, but use one of the |
495 | built-in programs rather than an external one.</para> | |
72c6cf8f TG |
496 | </listitem> |
497 | </varlistentry> | |
498 | <varlistentry> | |
6b76fa66 | 499 | <term><literal>file</literal></term> |
63749b1a | 500 | <listitem> |
b6a49cd6 MW |
501 | <para>Import a text file specified as the assigned value, the content |
502 | of which must be in environment key format.</para> | |
63749b1a KS |
503 | </listitem> |
504 | </varlistentry> | |
505 | <varlistentry> | |
6b76fa66 | 506 | <term><literal>db</literal></term> |
63749b1a KS |
507 | <listitem> |
508 | <para>Import a single property specified as the assigned value from the | |
509 | current device database. This works only if the database is already populated | |
510 | by an earlier event.</para> | |
511 | </listitem> | |
512 | </varlistentry> | |
c4f6dcc4 | 513 | <varlistentry> |
6b76fa66 | 514 | <term><literal>cmdline</literal></term> |
c4f6dcc4 | 515 | <listitem> |
ad9c70a8 | 516 | <para>Import a single property from the kernel command line. For simple flags |
909f413d | 517 | the value of the property is set to <literal>1</literal>.</para> |
c4f6dcc4 KS |
518 | </listitem> |
519 | </varlistentry> | |
63749b1a | 520 | <varlistentry> |
6b76fa66 | 521 | <term><literal>parent</literal></term> |
63749b1a KS |
522 | <listitem> |
523 | <para>Import the stored keys from the parent device by reading | |
524 | the database entry of the parent device. The value assigned to | |
525 | <option>IMPORT{parent}</option> is used as a filter of key names | |
eb75d0ed | 526 | to import (with the same shell glob pattern matching used for |
63749b1a KS |
527 | comparisons).</para> |
528 | </listitem> | |
529 | </varlistentry> | |
530 | </variablelist> | |
b45f770f KS |
531 | <para>This can only be used for very short-running foreground tasks. For details |
532 | see <option>RUN</option>.</para> | |
63749b1a KS |
533 | </listitem> |
534 | </varlistentry> | |
535 | ||
63749b1a | 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> | |
b938cb90 | 551 | <para>Usually, control and other possibly unsafe characters are replaced |
63749b1a KS |
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>, | |
4f985bd8 MS |
592 | <varname>GROUP</varname>, <varname>MODE</varname>, <varname>SECLABEL</varname>, |
593 | and <varname>RUN</varname> fields support simple string substitutions. | |
bcddd5bf JSJ |
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> |