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