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