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