3
3
.\" Author: [see the "Author" section]
4
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
4
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
8
8
.\" Language: English
10
.TH "UDEV" "7" "04/22/2011" "udev" "udev"
10
.TH "UDEV" "7" "05/19/2011" "udev" "udev"
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
20
.\" -----------------------------------------------------------------
12
21
.\" * set default formatting
13
22
.\" -----------------------------------------------------------------
27
36
directory, or renames network interfaces\&. The kernel usually just assigns unpredictable device names based on the order of discovery\&. Meaningful symlinks or network device names provide a way to reliably identify devices based on their properties or current configuration\&.
31
receives device uevents directly from the kernel whenever a device is added or removed from the system, or it changes its state\&. When udev receives a device event, it matches its configured set of rules against various device attributes to identify the device\&. Rules that match, may provide additional device information to be stored in the udev database, or information to be used to create meaningful symlink names\&.
39
\fBudevd\fR(8), receives device uevents directly from the kernel whenever a device is added or removed from the system, or it changes its state\&. When udev receives a device event, it matches its configured set of rules against various device attributes to identify the device\&. Rules that match may provide additional device information to be stored in the udev database or to be used to create meaningful symlink names\&.
33
All device information udev processes, is stored in the udev database and sent out to possible event subscribers\&. Access to all stored data and the event sources are provided by the library libudev\&.
41
All device information udev processes is stored in the udev database and sent out to possible event subscribers\&. Access to all stored data and the event sources is provided by the library libudev\&.
34
42
.SH "CONFIGURATION"
36
44
udev configuration files are placed in
39
/lib/udev/\&. All empty lines, or lines beginning with \'#\' will be ignored\&.
47
/lib/udev/\&. All empty lines or lines beginning with \*(Aq#\*(Aq are ignored\&.
40
48
.SS "Configuration file"
42
50
udev expects its main configuration file at
62
70
/lib/udev/rules\&.d/, the custom rules directory
63
71
/etc/udev/rules\&.d/
64
72
and the temporary rules directory
65
/run/udev/rules\&.d/\&. All rule files are sorted and processed in lexical order, regardless in which of these directories they live\&. Files in
73
/run/udev/rules\&.d/\&. All rule files are collectively sorted and processed in lexical order, regardless of the directories in which they live\&. However, files in
66
74
/etc/udev/rules\&.d/
67
have precedence over files with the same name in
68
/lib/udev/rules\&.d/\&. This can be used to ignore a default rules file if needed\&.
70
Rule files must end in
71
\&.rules, other extensions are ignored\&.
73
Every line in the rules file contains at least one key value pair\&. There are two kind of keys, match and assignment keys\&. If all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned\&.
75
take precedence over files with the same name in
76
/lib/udev/rules\&.d/; this can be used to ignore a default rules file if needed\&.
78
Rule files must have the extension
79
\&.rules; other extensions are ignored\&.
81
Every line in the rules file contains at least one key\-value pair\&. There are two kind of keys: match and assignment\&. If all match keys are matching against its value, the rule gets applied and the assignment keys get the specified value assigned\&.
75
83
A matching rule may rename a network interface, add symlinks pointing to the device node, or run a specified program as part of the event handling\&.
77
A rule consists of a list of one or more key value pairs separated by a comma\&. Each key has a distinct operation, depending on the used operator\&. Valid operators are:
85
A rule consists of a comma\-separated list of one or more key\-value pairs\&. Each key has a distinct operation, depending on the used operator\&. Valid operators are:
101
Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules\&.
109
Assign a value to a key finally; disallow any later changes\&.
104
112
The following key names can be used to match against device properties\&. Some of the keys also match against properties of the parent devices in sysfs, not only the device that has generated the event\&. If multiple keys that match a parent device are specified in a single rule, all these keys must match at one and the same parent device\&.
138
Match the driver name of the event device\&. Only set for devices which are bound to a driver at the time the event is generated\&.
146
Match the driver name of the event device\&. Only set this key for devices which are bound to a driver at the time the event is generated\&.
141
149
\fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
143
Match sysfs attribute values of the event device\&. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself\&.
151
Match sysfs attribute values of the event device\&. Trailing whitespace in the attribute values is ignored unless the specified match value itself contains trailing whitespace\&.
163
171
Search the devpath upwards for a device with matching sysfs attribute values\&. If multiple
165
matches are specified, all of them must match on the same device\&. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself\&.
173
matches are specified, all of them must match on the same device\&. Trailing whitespace in the attribute values is ignored unless the specified match value itself contains trailing whitespace\&.
168
176
\fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
185
Execute a program\&. The key is true, if the program returns successfully\&. The device properties are made available to the executed program in the environment\&. The program\'s output printed to stdout, is available in the RESULT key\&.
193
Execute a program to determine whether there is a match; the key is true if the program returns successfully\&. The device properties are made available to the executed program in the environment\&. The program\*(Aqs stdout is available in the RESULT key\&.
190
198
Match the returned string of the last PROGRAM call\&. This key can be used in the same or in any later rule after a PROGRAM call\&.
193
Most of the fields support a shell style pattern matching\&. The following pattern characters are supported:
201
Most of the fields support shell\-style pattern matching\&. The following pattern characters are supported:
197
Matches zero, or any number of characters\&.
205
Matches zero or more characters\&.
207
Matches any single character specified within the brackets\&. For example, the pattern string \'tty[SR]\' would match either \'ttyS\' or \'ttyR\'\&. Ranges are also supported within this match with the \'\-\' character\&. For example, to match on the range of all digits, the pattern [0\-9] would be used\&. If the first character following the \'[\' is a \'!\', any characters not enclosed are matched\&.
215
Matches any single character specified within the brackets\&. For example, the pattern string \*(Aqtty[SR]\*(Aq would match either \*(AqttyS\*(Aq or \*(AqttyR\*(Aq\&. Ranges are also supported via the \*(Aq\-\*(Aq character\&. For example, to match on the range of all digits, the pattern [0\-9] could be used\&. If the first character following the \*(Aq[\*(Aq is a \*(Aq!\*(Aq, any characters not enclosed are matched\&.
210
218
The following keys can get values assigned:
214
The name, a network interface should be renamed to\&. Or as a temporary workaround, the name a device node should be named\&. Usually the kernel provides the defined node name, or even creates and removes the node before udev even receives any event\&. Changing the node name from the kernel\'s default creates inconsistencies and is not supported\&. If the kernel and NAME specify different names, an error will be logged\&. Udev is only expected to handle device node permissions and to create additional symlinks, not to change kernel\-provided device node names\&. Instead of renaming a device node, SYMLINK should be used\&. Symlink names must never conflict with device node names, it will result in unpredictable behavior\&.
222
What a network interface should be named\&.
224
Also, as a temporary workaround, this is what a device node should be named; usually the kernel provides the defined node name or creates and removes the node before udev even receives any event\&. Changing the node name from the kernel\*(Aqs default creates inconsistencies and is not supported\&. If the kernel and NAME specify different names, an error is logged\&. udev is only expected to handle device node permissions and to create additional symlinks, not to change kernel\-provided device node names\&. Instead of renaming a device node, SYMLINK should be used\&. However, symlink names must never conflict with device node names, as that would result in unpredictable behavior\&.
219
The name of a symlink targeting the node\&. Every matching rule will add this value to the list of symlinks to be created\&. Multiple symlinks may be specified by separating the names by the space character\&. In case multiple devices claim the same name, the link will always point to the device with the highest link_priority\&. If the current device goes away, the links will be re\-evaluated and the device with the next highest link_priority will own the link\&. If no link_priority is specified, the order of the devices, and which one of them will own the link, is undefined\&. Claiming the same name for a symlink, which is or might be used for a device node, may result in unexpected behavior and is not supported\&.
229
The name of a symlink targeting the node\&. Every matching rule adds this value to the list of symlinks to be created\&. Multiple symlinks may be specified by separating the names by the space character\&. In case multiple devices claim the same name, the link always points to the device with the highest link_priority\&. If the current device goes away, the links are re\-evaluated and the device with the next highest link_priority becomes the owner of the link\&. If no link_priority is specified, the order of the devices (and which one of them owns the link) is undefined\&. Also, symlink names must never conflict with the kernel\*(Aqs default device node names, as that would result in unpredictable behavior\&.
222
232
\fBOWNER, GROUP, MODE\fR
232
242
\fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
234
Set a device property value\&. Property names with a leading \'\&.\' are not stored in the database or exported to external tool or events\&.
244
Set a device property value\&. Property names with a leading \*(Aq\&.\*(Aq are neither stored in the database nor exported to events or external tools (run by, say, the PROGRAM match key)\&.
239
Attach a tag to a device\&. This is used to filter events for users of libudev\'s monitor functionality, or to enumerate a group of tagged devices\&. The implementation can only work efficiently if only a few tags are attached to a device\&. It is only meant to be used in contexts with specific device filter requirements, and not as a general\-purpose flag\&. Excessive use might result in inefficient event handling\&.
249
Attach a tag to a device\&. This is used to filter events for users of libudev\*(Aqs monitor functionality, or to enumerate a group of tagged devices\&. The implementation can only work efficiently if only a few tags are attached to a device\&. It is only meant to be used in contexts with specific device filter requirements, and not as a general\-purpose flag\&. Excessive use might result in inefficient event handling\&.
244
254
Add a program to the list of programs to be executed for a specific device\&. This can only be used for very short running tasks\&. Running an event process for a long period of time may block all further events for this or a dependent device\&. Long running tasks need to be immediately detached from the event process itself\&.
246
If no absolute path is given, the program is expected to live in
247
/lib/udev, otherwise the absolute path must be specified\&. Program name and arguments are separated by spaces\&. Single quotes can be used to specify arguments with spaces\&.
256
If no absolute path is given, the program is expected to live in the directory provided at compile\-time to configure via \-\-libexecdir (this is usually
257
/lib/udev), otherwise the absolute path must be specified\&. The program name and following arguments are separated by spaces\&. Single quotes can be used to specify arguments with spaces\&.
252
Named label where a GOTO can jump to\&.
262
A named label to which a GOTO may jump\&.
257
Jumps to the next LABEL with a matching name
267
Jumps to the next LABEL with a matching name\&.
260
270
\fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
290
300
is used as a filter of key names to import (with the same shell\-style pattern matching used for comparisons)\&.
293
If no option is given, udev will choose between
303
If no option is given, udev chooses between
324
334
\fBstatic_node=\fR
326
Apply the permissions specified in this rule to a static device node with the specified name\&. Static device nodes might be provided by kernel modules, or copied from
327
/lib/udev/devices\&. These nodes might not have a corresponding kernel device at the time udevd is started, and allow to trigger automatic kernel module on\-demand loading\&.
336
Apply the permissions specified in this rule to the static device node with the specified name\&. Static device nodes might be provided by kernel modules or copied from
337
/lib/udev/devices\&. These nodes might not have a corresponding kernel device at the time udevd is started; they can trigger automatic kernel module loading\&.
332
Watch the device node with inotify, when closed after being opened for writing, a change uevent will be synthesised\&.
342
Watch the device node with inotify; when the node is closed after being opened for writing, a change uevent is synthesized\&.
350
fields support simple printf\-like string substitutions\&. The
360
fields support simple string substitutions\&. The
352
format chars gets applied after all rules have been processed, right before the program is executed\&. It allows the use of device properties set by earlier matching rules\&. For all other fields, substitutions are applied while the individual rule is being processed\&. The available substitutions are:
362
substitutions are performed after all rules have been processed, right before the program is executed, allowing for the use of device properties set by earlier matching rules\&. For all other fields, substitutions are performed while the individual rule is being processed\&. The available substitutions are:
354
364
\fB$kernel\fR, \fB%k\fR
389
399
\fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
391
The value of a sysfs attribute found at the device, where all keys of the rule have matched\&. If the matching device does not have such an attribute, and a previous KERNELS, SUBSYSTEMS, DRIVERS, or ATTRS test selected a parent device, use the attribute from that parent device\&. If the attribute is a symlink, the last element of the symlink target is returned as the value\&.
401
The value of a sysfs attribute found at the device where all keys of the rule have matched\&. If the matching device does not have such an attribute, and a previous KERNELS, SUBSYSTEMS, DRIVERS, or ATTRS test selected a parent device, then the attribute from that parent device is used\&.
403
If the attribute is a symlink, the last element of the symlink target is returned as the value\&.
394
406
\fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
409
421
\fB$result\fR, \fB%c\fR
411
The string returned by the external program requested with PROGRAM\&. A single part of the string, separated by a space character may be selected by specifying the part number as an attribute:
412
\fB%c{N}\fR\&. If the number is followed by the \'+\' char this part plus all remaining parts of the result string are substituted:
423
The string returned by the external program requested with PROGRAM\&. A single part of the string, separated by a space character, may be selected by specifying the part number as an attribute:
424
\fB%c{N}\fR\&. If the number is followed by the \*(Aq+\*(Aq character, this part plus all remaining parts of the result string are substituted:
441
453
\fB$tempnode\fR, \fB%N\fR
443
The name of a created temporary device node to provide access to the device from a external program before the real node is created\&.
455
The name of a temporary device node created to provide access to the device from a external program before the real node is created\&.
448
The \'%\' character itself\&.
460
The \*(Aq%\*(Aq character itself\&.
453
The \'$\' character itself\&.
465
The \*(Aq$\*(Aq character itself\&.