chiark / gitweb /
lookup_user, lookup_group: report "unknown user" and "lookup 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 \fBKERNEL\fR
80 Match the name of the device.
81 .TP 3n
82 \fBDEVPATH\fR
83 Match the devpath of the device.
84 .TP 3n
85 \fBSUBSYSTEM\fR
86 Match the subsystem of the device.
87 .TP 3n
88 \fBBUS\fR
89 Search the devpath upwards for a matching device subsystem name.
90 .TP 3n
91 \fBDRIVER\fR
92 Search the devpath upwards for a matching device driver name.
93 .TP 3n
94 \fBID\fR
95 Search the devpath upwards for a matching device name.
96 .TP 3n
97 \fBSYSFS{\fR\fB\fIfilename\fR\fR\fB}\fR
98 Search the devpath upwards for a device with matching sysfs attribute values. Up to five
99 \fBSYSFS\fR
100 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.
101 .TP 3n
102 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
103 Match against the value of an environment variable. Up to five
104 \fBENV\fR
105 keys can be specified per rule. This key can also be used to export a variable to the environment.
106 .TP 3n
107 \fBPROGRAM\fR
108 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.
109 .TP 3n
110 \fBRESULT\fR
111 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.
112 .PP
113 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
114 .TP 3n
115 \fB*\fR
116 Matches zero, or any number of characters.
117 .TP 3n
118 \fB?\fR
119 Matches any single character.
120 .TP 3n
121 \fB[]\fR
122 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.
123 .PP
124 The following keys can get values assigned:
125 .TP 3n
126 \fBNAME\fR
127 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.
128 .TP 3n
129 \fBSYMLINK\fR
130 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.
131 .TP 3n
132 \fBOWNER, GROUP, MODE\fR
133 The permissions for the device node. Every specified value overwrites the compiled\-in default value.
134 .TP 3n
135 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
136 Export a variable to the environment. This key can also be used to match against an environment variable.
137 .TP 3n
138 \fBRUN\fR
139 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.
140 .TP 3n
141 \fBLABEL\fR
142 Named label where a GOTO can jump to.
143 .TP 3n
144 \fBGOTO\fR
145 Jumps to the next LABEL with a matching name
146 .TP 3n
147 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
148 Import the printed result or the value of a file in environment key format into the event environment.
149 \fBprogram\fR
150 will execute an external program and read its output.
151 \fBfile\fR
152 will import a text file. If no option is given, udev will determine it from the executable bit of of the file permissions.
153 .TP 3n
154 \fBWAIT_FOR_SYSFS\fR
155 Wait for the specified sysfs file of the device to be created. Can be used to fight against kernel sysfs timing issues.
156 .TP 3n
157 \fBOPTIONS\fR
158 \fBlast_rule\fR
159 stops further rules application. No later rules will have any effect.
160 \fBignore_device\fR
161 will ignore this event completely.
162 \fBignore_remove\fR
163 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers.
164 \fBall_partitions\fR
165 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.
166 .PP
167 The
168 \fBNAME\fR,
169 \fBSYMLINK\fR,
170 \fBPROGRAM\fR,
171 \fBOWNER\fR,
172 \fBGROUP\fR
173 and
174 \fBRUN\fR
175 fields support simple printf\-like string substitutions. The
176 \fBRUN\fR
177 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:
178 .TP 3n
179 \fB$kernel\fR, \fB%k\fR
180 The kernel name for this device.
181 .TP 3n
182 \fB$number\fR, \fB%n\fR
183 The kernel number for this device. For example, 'sda3' has kernel number of '3'
184 .TP 3n
185 \fB$devpath\fR, \fB%p\fR
186 The devpath of the device.
187 .TP 3n
188 \fB$id\fR, \fB%b\fR
189 The name of the device matched while searching the devpath upwards for
190 \fBBUS\fR,
191 \fBID\fR
192 \fBDRIVER\fR
193 and
194 \fBSYSFS\fR.
195 .TP 3n
196 \fB$sysfs{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
197 The value of a sysfs attribute found at the current or a parent device.
198 .TP 3n
199 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
200 The value of an environment variable.
201 .TP 3n
202 \fB$major\fR, \fB%M\fR
203 The kernel major number for the device.
204 .TP 3n
205 \fB$minor\fR \fB%m\fR
206 The kernel minor number for the device.
207 .TP 3n
208 \fB$result\fR, \fB%c\fR
209 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:
210 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted:
211 \fB%c{N+}\fR
212 .TP 3n
213 \fB$parent\fR, \fB%P\fR
214 The node name of the parent device.
215 .TP 3n
216 \fB$root\fR, \fB%r\fR
217 The udev_root value.
218 .TP 3n
219 \fB$tempnode\fR, \fB%N\fR
220 The name of a created temporary device node to provide access to the device from a external program before the real node is created.
221 .TP 3n
222 \fB%%\fR
223 The '%' character itself.
224 .TP 3n
225 \fB$$\fR
226 The '$' character itself.
227 .PP
228 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
229 .\" end of SS subsection "Rules files"
230 .SH "AUTHOR"
231 .PP
232 Written by Greg Kroah\-Hartman
233 <greg@kroah.com>
234 and Kay Sievers
235 <kay.sievers@vrfy.org>. With much help from Dan Stekloff
236 <dsteklof@us.ibm.com>
237 and many others.
238 .SH "SEE ALSO"
239 .PP
240 \fBudevd\fR(8),
241 \fBudevinfo\fR(8),
242 \fBudevmonitor\fR(8)