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