chiark / gitweb /
udevtrigger: add --retry-failed
[elogind.git] / udev.7
1 .\"     Title: udev
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
4 .\"      Date: August 2005
5 .\"    Manual: udev
6 .\"    Source: udev
7 .\"
8 .TH "UDEV" "7" "August 2005" "udev" "udev"
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 udev \- dynamic device management
15 .SH "DESCRIPTION"
16 .PP
17 udev provides a dynamic device directory containing only the files for actually present devices. It creates or removes device node files in the
18 \fI/dev\fR
19 directory, or it renames network interfaces.
20 .PP
21 Usually udev runs as
22 \fBudevd\fR(8)
23 and receives uevents directly from the kernel if a device is added or removed form the system.
24 .PP
25 If udev receives a device event, it matches its configured rules against the available device attributes provided in sysfs to identify the device. Rules that match, may provide additional device information or specify a device node name and multiple symlink names and instruct udev to run additional programs as part of the device event handling.
26 .SH "CONFIGURATION"
27 .PP
28 All udev configuration files are placed in
29 \fI/etc/udev/*\fR. Every file consists of a set of lines of text. All empty lines or lines beginning with '#' will be ignored.
30 .SS "Configuration file"
31 .PP
32 udev expects its main configuration file at
33 \fI/etc/udev/udev.conf\fR. It consists of a set of variables allowing the user to override default udev values. The following variables can be set:
34 .TP 3n
35 \fBudev_root\fR
36 Specifies where to place the device nodes in the filesystem. The default value is
37 \fI/dev\fR.
38 .TP 3n
39 \fBudev_rules\fR
40 The name of the udev rules file or directory to look for files with the suffix
41 \fI.rules\fR. Multiple rule files are read in lexical order. The default value is
42 \fI/etc/udev/rules.d\fR.
43 .TP 3n
44 \fBudev_log\fR
45 The logging priority. Valid values are the numerical syslog priorities or their textual representations:
46 \fBerr\fR,
47 \fBinfo\fR
48 and
49 \fBdebug\fR.
50 .\" end of SS subsection "Configuration file"
51 .SS "Rules files"
52 .PP
53 The udev rules are read from the files located in the
54 \fI/etc/udev/rules.d\fR
55 directory or at the location specified value in the configuration file. 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. A matching rule may specify the name of the device node, add a symlink pointing to the node, or run a specified program as part of the event handling. If no matching rule is found, the default device node name is used.
56 .PP
57 A rule may 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:
58 .TP 3n
59 \fB==\fR
60 Compare for equality.
61 .TP 3n
62 \fB!=\fR
63 Compare for non\-equality.
64 .TP 3n
65 \fB=\fR
66 Assign a value to a key. Keys that represent a list, are reset and only this single value is assigned.
67 .TP 3n
68 \fB+=\fR
69 Add the value to a key that holds a list of entries.
70 .TP 3n
71 \fB:=\fR
72 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules.
73 .PP
74 The following key names can be used to match against device properties:
75 .TP 3n
76 \fBACTION\fR
77 Match the name of the event action.
78 .TP 3n
79 \fBDEVPATH\fR
80 Match the devpath of the event device.
81 .TP 3n
82 \fBKERNEL\fR
83 Match the name of the event device.
84 .TP 3n
85 \fBSUBSYSTEM\fR
86 Match the subsystem of the event device.
87 .TP 3n
88 \fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
89 Match sysfs attribute values of the event device. Up to five
90 \fBATTR\fR
91 keys can be specified per rule. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself.
92 .TP 3n
93 \fBKERNELS\fR
94 Search the devpath upwards for a matching device name.
95 .TP 3n
96 \fBSUBSYSTEMS\fR
97 Search the devpath upwards for a matching device subsystem name.
98 .TP 3n
99 \fBDRIVERS\fR
100 Search the devpath upwards for a matching device driver name.
101 .TP 3n
102 \fBATTRS{\fR\fB\fIfilename\fR\fR\fB}\fR
103 Search the devpath upwards for a device with matching sysfs attribute values. Up to five
104 \fBATTRS\fR
105 keys can be specified per rule. All attributes 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.
106 .TP 3n
107 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
108 Match against the value of an environment variable. Up to five
109 \fBENV\fR
110 keys can be specified per rule. This key can also be used to export a variable to the environment.
111 .TP 3n
112 \fBPROGRAM\fR
113 Execute external program. The key is true, if the program returns without exit code zero. The whole event environment is available to the executed program. The program's output printed to stdout is available for the RESULT key.
114 .TP 3n
115 \fBRESULT\fR
116 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.
117 .PP
118 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
119 .TP 3n
120 \fB*\fR
121 Matches zero, or any number of characters.
122 .TP 3n
123 \fB?\fR
124 Matches any single character.
125 .TP 3n
126 \fB[]\fR
127 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.
128 .PP
129 The following keys can get values assigned:
130 .TP 3n
131 \fBNAME\fR
132 The name of the node to be created, or the name the network interface should be renamed to. Only one rule can set the node name, all later rules with a NAME key will be ignored.
133 .TP 3n
134 \fBSYMLINK\fR
135 The name of a symlink targeting the node. Every matching rule can add this value to the list of symlinks to be created along with the device node. Multiple symlinks may be specified by separating the names by the space character.
136 .TP 3n
137 \fBOWNER, GROUP, MODE\fR
138 The permissions for the device node. Every specified value overwrites the compiled\-in default value.
139 .TP 3n
140 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
141 Export a variable to the environment. This key can also be used to match against an environment variable.
142 .TP 3n
143 \fBRUN\fR
144 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.
145 .TP 3n
146 \fBLABEL\fR
147 Named label where a GOTO can jump to.
148 .TP 3n
149 \fBGOTO\fR
150 Jumps to the next LABEL with a matching name
151 .TP 3n
152 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
153 Import the printed result or the value of a file in environment key format into the event environment.
154 \fBprogram\fR
155 will execute an external program and read its output.
156 \fBfile\fR
157 will import a text file. If no option is given, udev will determine it from the executable bit of of the file permissions.
158 .TP 3n
159 \fBWAIT_FOR_SYSFS\fR
160 Wait for the specified sysfs file of the device to be created. Can be used to fight against kernel sysfs timing issues.
161 .TP 3n
162 \fBOPTIONS\fR
163 \fBlast_rule\fR
164 stops further rules application. No later rules will have any effect.
165 \fBignore_device\fR
166 will ignore this event completely.
167 \fBignore_remove\fR
168 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers.
169 \fBall_partitions\fR
170 will create the device nodes for all available partitions of a block device. This may be useful for removable media devices where media changes are not detected.
171 .PP
172 The
173 \fBNAME\fR,
174 \fBSYMLINK\fR,
175 \fBPROGRAM\fR,
176 \fBOWNER\fR,
177 \fBGROUP\fR
178 and
179 \fBRUN\fR
180 fields support simple printf\-like string substitutions. The
181 \fBRUN\fR
182 format chars gets applied after all rules have been processed, right before the program is executed. It allows the use of the complete environment set by earlier matching rules. For all other fields, substitutions are applied while the individual rule is being processed. The available substitutions are:
183 .TP 3n
184 \fB$kernel\fR, \fB%k\fR
185 The kernel name for this device.
186 .TP 3n
187 \fB$number\fR, \fB%n\fR
188 The kernel number for this device. For example, 'sda3' has kernel number of '3'
189 .TP 3n
190 \fB$devpath\fR, \fB%p\fR
191 The devpath of the device.
192 .TP 3n
193 \fB$id\fR, \fB%b\fR
194 The name of the device matched while searching the devpath upwards for
195 \fBSUBSYSTEMS\fR,
196 \fBKERNELS\fR
197 \fBDRIVERS\fR
198 and
199 \fBATTRS\fR.
200 .TP 3n
201 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
202 The value of a sysfs attribute found at the current or a parent device.
203 .TP 3n
204 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
205 The value of an environment variable.
206 .TP 3n
207 \fB$major\fR, \fB%M\fR
208 The kernel major number for the device.
209 .TP 3n
210 \fB$minor\fR \fB%m\fR
211 The kernel minor number for the device.
212 .TP 3n
213 \fB$result\fR, \fB%c\fR
214 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:
215 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted:
216 \fB%c{N+}\fR
217 .TP 3n
218 \fB$parent\fR, \fB%P\fR
219 The node name of the parent device.
220 .TP 3n
221 \fB$root\fR, \fB%r\fR
222 The udev_root value.
223 .TP 3n
224 \fB$tempnode\fR, \fB%N\fR
225 The name of a created temporary device node to provide access to the device from a external program before the real node is created.
226 .TP 3n
227 \fB%%\fR
228 The '%' character itself.
229 .TP 3n
230 \fB$$\fR
231 The '$' character itself.
232 .PP
233 The count of characters to be substituted may be limited by specifying the format length value. For example, '%3s{file}' will only insert the first three characters of the sysfs attribute
234 .\" end of SS subsection "Rules files"
235 .SH "AUTHOR"
236 .PP
237 Written by Greg Kroah\-Hartman
238 <greg@kroah.com>
239 and Kay Sievers
240 <kay.sievers@vrfy.org>. With much help from Dan Stekloff
241 <dsteklof@us.ibm.com>
242 and many others.
243 .SH "SEE ALSO"
244 .PP
245 \fBudevd\fR(8),
246 \fBudevinfo\fR(8),
247 \fBudevmonitor\fR(8)