chiark / gitweb /
[PATCH] fix up error in building extras and libsysfs
[elogind.git] / udev.8.in
1 .TH UDEV 8 "October 2003" "" "Linux Administrator's Manual"
2 .SH NAME
3 udev \- Linux configurable dynamic device naming support
4 .SH SYNOPSIS
5 .BI udev " hotplug-subsystem"
6 .P
7 The environment must provide the following variables:
8 .TP
9 .B ACTION
10 .IR add " or " remove
11 signifies the connection or disconnection of a device.
12 .TP
13 .B DEVPATH
14 The sysfs devpath of the device without the mountpoint but a leading slash.
15 .P
16 Additional optional environment variables:
17 .TP
18 .B UDEV_CONFIG_FILE
19 Overrides the default location of the
20 .B udev
21 config file.
22 .TP
23 .B UDEV_NO_SLEEP
24 The default behavior of
25 .B udev
26 is to wait until all the sysfs files of the device chain are populated. If set,
27 .B udev
28 will continue, regardless of the state of the device representation.
29 .TP
30 .B UDEV_NO_DEVD
31 The default behavior of
32 .B udev
33 is to execute programs in the
34 .I /etc/dev.d/
35 directory after device handling. If set,
36 .B udev
37 will skip this step.
38 .SH "DESCRIPTION"
39 .B udev
40 provides a dynamic device directory containing only the files for actually
41 present devices. It creates or removes device node files usually located in
42 the /dev directory, or it renames network interfaces.
43 .br
44
45 .P
46 As part of the
47 .B hotplug
48 subsystem,
49 .B udev
50 is executed if a kernel device is added or removed from the system.
51 On device creation,
52 .B udev
53 reads the sysfs directory of the given device to collect device attributes
54 like label, serial number or bus device number.
55 These attributes may be used as keys to determine a
56 unique name for the device.
57 .B udev
58 maintains a database for devices present on the system.
59 .br
60 On device removal,
61 .B udev
62 queries its database for the name of the device file to be deleted.
63 .SH "CONFIGURATION"
64 All
65 .B udev
66 configuration files consist of a set of lines of text.  All empty
67 lines and lines beginning with a '#' will be ignored.
68 .P
69
70 .B udev
71 expects its main configuration file at
72 .IR /etc/udev/udev.conf .
73 The file consists of a set of variables and values allowing the user to
74 override default udev values. The following variables can be overridden
75 in this file:
76 .TP
77 .B udev_root
78 Indicates where to place the device nodes in the filesystem. The default
79 value is
80 .IR @udevdir@/ .
81 .TP
82 .B udev_db
83 The name and location of the udev database. The default value is
84 .IR @udevdir@/.udev.tdb .
85 .TP
86 .B udev_rules
87 The name of the udev rules file or directory to look for files with the suffix
88 .IR .rules .
89 All rule files are read in lexical order. The default value is
90 .IR /etc/udev/rules.d/ .
91 .TP
92 .B udev_permissions
93 The name of the udev permission file or directory to look for files with the
94 suffix
95 .IR .permissions .
96 All permission files are read in lexical order. The default value is
97 .IR /etc/udev/permissions.d/ .
98 .TP
99 .B udev_log
100 The switch, if udev logs some information for every device handled.
101 The default value is
102 .IR yes .
103 .TP
104 .B default_mode
105 The default mode for all nodes not explicitely matching in the permissions
106 file. The default value is
107 .IR 0666 .
108 .TP
109 .B default_owner
110 The default owner for all nodes not explicitely matching in the permissions
111 file. The default value is
112 .IR root .
113 .TP
114 .B default_group
115 The default group for all nodes not explicitely matching in the permissions
116 file. The default value is
117 .IR root .
118 .br
119 .P
120 .RI "A sample " udev.conf " might look like this:
121 .sp
122 .nf
123 # udev_root - where to place the device nodes in the filesystem
124 udev_root="/udev"
125
126 # udev_db - The name and location of the udev database
127 udev_db="/udev/.udev.tdb"
128
129 # udev_rules - The name of the udev rules file or directory to look
130                for files with the suffix .rules
131 udev_rules="/etc/udev/rules.d/"
132
133 # udev_permissions - The name of the udev permission file or directory
134                      to look for files with the suffix .permissions
135 udev_permissions="/etc/udev/udev.permissions"
136
137 # udev_log - set to "yes" if you want logging, else "no"
138 udev_log="yes"
139
140 # default_mode - set the default mode for all nodes not
141 #                explicitely matching in the permissions file
142 default_mode="0666"
143
144 # default_owner - set the default owner for all nodes not
145 #                 explicitely matching in the permissions file
146 default_owner="root"
147
148 # default_group - set the default group for all nodes not
149 #                 explicitely matching in the permissions file
150 default_group="root"
151 .fi
152 .P
153 The rules for device naming, are read from the files located in the
154 .I /etc/udev/rules.d/
155 directory, or at the location specified by the
156 .I udev_rules
157 value in the
158 .I /etc/udev/udev.conf
159 file.
160 .br
161 Every line in the rules file defines the mapping between device attributes
162 and the device name. One or more keys are specified to match a rule with
163 the current device. If all keys are matching, the rule will be applied and
164 the name is used to name the device file or the network interface.
165 .br
166 If no matching rule is found, the default kernel device name is used.
167 .P
168 Every rule consists of a list of comma separated fields:
169 .sp
170 .IR "key " ,[ "key " ,...] " name " [, " symlink" ]
171 .sp
172 where fields are:
173 .TP
174 .B BUS
175 Match the bus type of the device.
176 (The sysfs device bus must be able to be determined by a "device" symlink.)
177 .TP
178 .B KERNEL
179 Match the kernel device name.
180 .TP
181 .B ID
182 Match the device number on the bus, like PCI bus id.
183 .TP
184 .B PLACE
185 Match the topological position on bus, like physical port of USB device
186 .TP
187 .BI SYSFS{ filename }
188 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
189 or file system label.  Up to 5 different sysfs files can be checked, with
190 all of the values being required to match the rule.
191 .br
192 Trailing whitespace characters in the sysfs attribute value are ignored, if
193 the key doesn't have any trailing whitespace characters by itself.
194 .TP
195 .B PROGRAM
196 Call external program. This key is valid if the program returns successful.
197 The environment variables of
198 .B udev
199 are also available for the program.
200 .br
201 The string returned by the program may be additionally matched with the
202 .B RESULT
203 key.
204 .TP
205 .B RESULT
206 Match the returned string of the last
207 .B PROGRAM
208 call. This key may be used in any following rule after a
209 .B PROGRAM
210 call.
211 .TP
212 .B NAME
213 The name of the node to be created, or the name, the network interface
214 should be renamed to.
215 .br
216 If given with the attribute
217 .BR NAME{ all_partitions }
218 it will  create all 15 partitions of a blockdevice.
219 This may be useful for removable media devices.
220 .TP
221 .B SYMLINK
222 The name of a symlink targeting the node. Multiple symlinks may be
223 specified by separating the names by the space character.
224 .br
225 If both the name and the symlink fields are omitted or its
226 values empty, the device will be ignored and no node will be created.
227 .br
228 If only the symlink field is given and the name field is omitted,
229 the rule will not be applied immediatly, but the symlink field is added
230 to the symlink list of the rule which will create the node.
231 This makes it possible to specify additional symlinks in a possibly
232 separate rules file, while the device nodes are maintained by the
233 distribution provided rules file.
234 .TP
235 .B OWNER, GROUP, MODE
236 The permissions for this device. Every specified value overwrites the value
237 given in the permissions file.
238 .P
239 .RB "The " NAME " ," SYMLINK " and " PROGRAM
240 fields support simple printf-like string substitution:
241 .TP
242 .B %n
243 The "kernel number" of the device.
244 For example, 'sda3' has a "kernel number" of '3'.
245 .TP
246 .B %k
247 The "kernel name" for the device.
248 .TP
249 .B %M
250 The kernel major number for the device.
251 .TP
252 .B %m
253 The kernel minor number for the device.
254 .TP
255 .B %b
256 The bus id for the device.
257 .TP
258 .B %c
259 The string returned from the execution of
260 .B PROGRAM
261 (This does not work within the
262 .B PROGRAM
263 field for the obvious reason.)
264 .br
265 A single part of the string, separated by a space character
266 may be selected by specifying the part number as an attribute:
267 .BI %c{ N }
268 If the number is followed by the + char this part plus
269 all remaining parts of the result string are substituted:
270 .BI %c{ N+ }
271 .TP
272 .BI %s{ filename }
273 The content of a sysfs attribute.
274 .TP
275 .B %e
276 If a device node already exists with the name, the smallest positive
277 decimal integer N is substituted such that the resulting name doesn't
278 match an existing device node. Otherwise nothing is substituted. This
279 can be used to create compatibility symlinks and enumerate devices of
280 the same type originating from different kernel subsystems.
281 .TP
282 .B %%
283 The '%' character itself.
284 .P
285 The count of charcters to insert may be limited by specifying
286 the format length value. For example, '%3s{file}' will only insert
287 the first three characters of the sysfs attribute.
288 .P
289 .RI "A sample " udev.rules " might look like this:"
290 .sp
291 .nf
292 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
293 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
294
295 # USB printer to be called lp_color
296 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
297
298 # SCSI disk with a specific vendor and model number will be called boot
299 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
300
301 # sound card with PCI bus id 00:0b.0 to be called dsp
302 BUS="pci", ID="00:0b.0", NAME="dsp"
303
304 # USB mouse at third port of the second hub to be called mouse1
305 BUS="usb", PLACE="2.3", NAME="mouse1"
306
307 # ttyUSB1 should always be called pda with two additional symlinks
308 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
309
310 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
311 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
312
313 # grouping of optical drives from multiple kernel subsystems
314 KERNEL="sr*", NAME="%k", SYMLINK="cdrom%e"
315 KERNEL="scd*", NAME="%k", SYMLINK="cdrom%e"
316 KERNEL="pcd*", NAME="%k", SYMLINK="cdrom%e"
317 KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom",
318   NAME="%k", SYMLINK="cdrom%e"
319
320 .fi
321 .P
322 The permissions and ownership of the created device file is read from
323 the files located in the
324 .I /etc/udev/permissions.d/
325 directory, or at the location specified by the
326 .I udev_permission
327 value in the
328 .I /etc/udev/udev.conf
329 file.
330 .br
331 Every line lists a device name followed by owner, group and permission
332 mode. All values are separated by colons. The name field may contain a
333 pattern to apply the values to a whole class of devices.
334 .sp
335 .RI "A sample " udev.permissions " might look like this:"
336 .sp
337 .nf
338 #name:user:group:mode
339 input/*:root:root:644
340 ttyUSB1:0:8:0660
341 video*:root:video:0660
342 dsp1:::0666
343 .fi
344 .P
345 The value
346 .I $local
347 can be used instead of a specific username.  In that case, udev will determine
348 the current local user at the time of device node creation and substitute
349 that username as the owner of the new device node.  This is useful, for
350 example, to let hot-plugged devices, such as cameras, be owned by the user at
351 the current console.  Note that if no user is currently logged in, or if udev
352 otherwise fails to determine a current user, the
353 .I default_owner
354 value is used in lieu.
355 .P
356 A number of different fields in the above configuration files support a simple
357 form of shell style pattern matching. It supports the following pattern characters:
358 .TP
359 .B *
360 Matches zero, one, or more characters.
361 .TP
362 .B ?
363 Matches any single character, but does not match zero characters.
364 .TP
365 .B [ ]
366 Matches any single character specified within the brackets. For example, the
367 pattern string "tty[SR]" would match either "ttyS" or "ttyR".  Ranges are also
368 supported within this match with the '\-' character.  For example, to match on
369 the range of all digits, the pattern [0\-9] would be used. If the first character
370 following the '[' is a '!', any character not enclosed is matched.
371 .P
372 After device node creation, removal, or network device renaming,
373 .B udev
374 executes the programs in the directory tree under
375 .IR /etc/dev.d/ .
376 The name of a program must end with
377 .I .dev
378 suffix, to be recognized.
379 .br
380 In addition to the hotplug environment variables,
381 .B DEVNAME
382 is exported to make the name of the created node, or the name the network
383 device is renamed to, available to the executed program. The programs in every
384 directory are sorted in lexical order, while the directories are searched in
385 the following order:
386 .sp
387 .nf
388 /etc/dev.d/$(DEVNAME)/*.dev
389 /etc/dev.d/$(SUBSYSTEM)/*.dev
390 /etc/dev.d/default/*.dev
391 .fi
392 .SH "FILES"
393 .nf
394 /sbin/udev                           udev program
395 /etc/udev/*                          udev config files
396 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
397 /etc/dev.d/*                         programs invoked by udev
398 .fi
399 .LP
400 .SH "SEE ALSO"
401 .BR udevinfo (8),
402 .BR udevd (8),
403 .BR hotplug (8)
404 .PP
405 The
406 .I http://linux\-hotplug.sourceforge.net/
407 web site.
408 .SH AUTHORS
409 .B udev
410 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
411 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
412 many others.