udev.xml revision b45f770f0049fbdf3f6c9db0ab11deeff4ccd86d
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <refentryinfo>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <authorgroup>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd </authorgroup>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd </refentryinfo>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <refnamediv>
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem <refpurpose>Linux dynamic device management</refpurpose>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </refnamediv>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>udev supplies the system software with device events, manages permissions
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd of device nodes and may create additional symlinks in the <filename>/dev</filename>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd directory, or renames network interfaces. The kernel usually just assigns unpredictable
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd device names based on the order of discovery. Meaningful symlinks or network device
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd names provide a way to reliably identify devices based on their properties or
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd current configuration.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>The udev daemon, <citerefentry><refentrytitle>udevd</refentrytitle>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd the kernel whenever a device is added or removed from the system, or it changes its
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd state. When udev receives a device event, it matches its configured set of rules
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd against various device attributes to identify the device. Rules that match may
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd provide additional device information to be stored in the udev database or
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd to be used to create meaningful symlink names.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>All device information udev processes is stored in the udev database and
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd sent out to possible event subscribers. Access to all stored data and the event
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd sources is provided by the library libudev.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </refsect1>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>udev configuration files are placed in <filename>/etc/udev</filename>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd and <filename>/usr/lib/udev</filename>. All empty lines or lines beginning with
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd '#' are ignored.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>udev expects its main configuration file at <filename>/etc/udev/udev.conf</filename>.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd It consists of a set of variables allowing the user to override default udev values.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd The following variables can be set:</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Specifies where to place the device nodes in the filesystem.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>The logging priority. Valid values are the numerical syslog priorities
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd or their textual representations: <option>err</option>, <option>info</option>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </refsect2>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>The udev rules are read from the files located in the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd system rules directory <filename>/usr/lib/udev/rules.d</filename>,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd the volatile runtime directory <filename>/run/udev/rules.d</filename>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd and the local administration directory <filename>/etc/udev/rules.d</filename>.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd All rules files are collectively sorted and processed in lexical order,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd regardless of the directories in which they live. However, files with
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd identical file names replace each other. Files in <filename>/etc</filename>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd have the highest priority, files in <filename>/run</filename> take precedence
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd over files with the same name in <filename>/lib</filename>. This can be
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd used to override a system-supplied rules file with a local file if needed;
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd a symlink in <filename>/etc</filename> with the same name as a rules file in
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <filename>/lib</filename>, pointing to <filename>/dev/null</filename>,
71fccc298df6a1540d408151a26aa22beed55d0bnd disables the rules file entirely.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Rule files must have the extension <filename>.rules</filename>; other
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd extensions are ignored.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Every line in the rules file contains at least one key-value pair.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd There are two kind of keys: match and assignment.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd If all match keys are matching against its value, the rule gets applied and the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd assignment keys get the specified value assigned.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>A matching rule may rename a network interface, add symlinks
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd pointing to the device node, or run a specified program as part of
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd the event handling.</para>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <para>A rule consists of a comma-separated list of one or more key-value pairs.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Each key has a distinct operation, depending on the used operator. Valid
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd operators are:</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Assign a value to a key. Keys that represent a list are reset
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd and only this single value is assigned.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Add the value to a key that holds a list of entries.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Assign a value to a key finally; disallow any later changes.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
71fccc298df6a1540d408151a26aa22beed55d0bnd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>The following key names can be used to match against device properties.
71fccc298df6a1540d408151a26aa22beed55d0bnd Some of the keys also match against properties of the parent devices in sysfs,
71fccc298df6a1540d408151a26aa22beed55d0bnd not only the device that has generated the event. If multiple keys that match
71fccc298df6a1540d408151a26aa22beed55d0bnd a parent device are specified in a single rule, all these keys must match at
71fccc298df6a1540d408151a26aa22beed55d0bnd one and the same parent device.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
22d5d84393d960a2027f472036f3fee15d7dbce9nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl <varlistentry>
ffb88a4885747797937e30a5ac8b1606da3cb4adnd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
42af92a661a06b3cebc88d585aad75064a309d51nd <varlistentry>
6fe26506780e73be2a412d758af77fafdf03291and <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Match the name of a network interface. It can be used once the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd NAME key has been set in one of the preceding rules.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin <para>Match the name of a symlink targeting the node. It can
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd be used once a SYMLINK key has been set in one of the preceding
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd rules. There may be multiple symlinks; only one needs to match.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd <listitem>
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
611049e38bfbaeb173d2d7fab2e44a48753436a1nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Match the driver name of the event device. Only set this key for devices
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd which are bound to a driver at the time the event is generated.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
03a4ff9ac4c9b8009249010e7c53bb86ff05915and <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <term><option>ATTR{<replaceable>filename</replaceable>}</option></term>
d0828c8a321dc5e9ea60550f052294669c08cf93jim <listitem>
d0828c8a321dc5e9ea60550f052294669c08cf93jim <para>Match sysfs attribute values of the event device. Trailing
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd whitespace in the attribute values is ignored unless the specified match
4b5981e276e93df97c34e4da05ca5cf8bbd937dand value itself contains trailing whitespace.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
2704de98885368683621b01c8f8f4e4b01557611takashi <varlistentry>
d0828c8a321dc5e9ea60550f052294669c08cf93jim <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Search the devpath upwards for a matching device name.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
c819c19c2f1ffbf3a3f12a4070cc6c3f4ea2a6f2sf </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Search the devpath upwards for a matching device subsystem name.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Search the devpath upwards for a matching device driver name.</para>
438b4817913a5ff55d9cad4c7ddf133330b4466ejim </listitem>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf <term><option>ATTRS{<replaceable>filename</replaceable>}</option></term>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <para>Search the devpath upwards for a device with matching sysfs attribute values.
4ed26c413f67a5aae20b95909828f30bb5dc2286poirier If multiple <option>ATTRS</option> matches are specified, all of them
6d20aeba2c4aa0938bc6e0659d13adc7670ff421poirier must match on the same device. Trailing whitespace in the attribute values is ignored
5f4e50966b2b9b58436a1651cbe588d1b595657ewrowe unless the specified match value itself contains trailing whitespace.</para>
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun </listitem>
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi </varlistentry>
79b024b81f6bb3c44dce77a7552191daf8b522d2jim <varlistentry>
f772e8f448c223e5ea306f1bf92d97d968f972d5jim <listitem>
f772e8f448c223e5ea306f1bf92d97d968f972d5jim <para>Search the devpath upwards for a device with matching tag.</para>
fac8c35bfb158112226ab43ddf84d59daca5dc30nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
1de1266f0ea387d6373be8415745dfd2ab876341jim <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <term><option>ENV{<replaceable>key</replaceable>}</option></term>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
898711b68797304101de0882fa576c8908acfae6nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <term><option>TEST{<replaceable>octal mode mask</replaceable>}</option></term>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Test the existence of a file. An octal mode mask can be specified
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd if needed.</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Execute a program to determine whether there
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd is a match; the key is true if the program returns
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd successfully. The device properties are made available to the
71fccc298df6a1540d408151a26aa22beed55d0bnd executed program in the environment. The program's stdout
71fccc298df6a1540d408151a26aa22beed55d0bnd is available in the RESULT key.</para>
71fccc298df6a1540d408151a26aa22beed55d0bnd <para>This can only be used for very short-running foreground tasks. For details
71fccc298df6a1540d408151a26aa22beed55d0bnd </listitem>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd </varlistentry>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <listitem>
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi <para>Match the returned string of the last PROGRAM call. This key can
c04f76acce77126cf88b09350e56ea8c6b4a064enilgun be used in the same or in any later rule after a PROGRAM call.</para>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd </listitem>
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end </varlistentry>
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen </variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <para>Most of the fields support shell-style pattern matching. The following
9c1260efa52c82c2a58e5b5f20cd6902563d95f5rbowen pattern characters are supported:</para>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <variablelist>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <varlistentry>
<option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
<option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
<term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>