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