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