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