chiark / gitweb /
[PATCH] - unlink bugfix
[elogind.git] / udev.8
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 are:
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 will continue, regardless of the state of the device representation.
29 .SH "DESCRIPTION"
30 .B udev
31 creates or removes device node files usually located in the /dev directory.
32 It provides a dynamic device directory that contains only the files for
33 devices that are actually present.
34 .P
35 As part of the
36 .B hotplug
37 subsystem,
38 .B udev
39 is executed if a kernel device is added or removed from the system.
40 On device creation,
41 .B udev
42 reads the sysfs directory of the given device to collect device attributes
43 like label, serial number or bus device number.
44 These attributes may used as keys to determine a
45 unique name for device file creation.
46 .B udev
47 maintains a database for devices present on the system.
48 .br
49 On device removal,
50 .B udev
51 queries its database for the name of the device file to be deleted.
52 .SH "CONFIGURATION"
53 All
54 .B udev
55 configuration files consist of a set of lines of text.  All empty
56 lines, and lines beginning with a '#' will be ignored.
57 .P
58
59 .B udev
60 expects its main configuration file at
61 .IR /etc/udev/udev.conf .
62 The file consists of a set of variables and values that allow the user to
63 override default udev values.  The current set of variables that can be
64 overridden in this file is:
65 .TP
66 .B udev_root
67 This is the where in the filesystem to place the device nodes.  The default
68 value for this is
69 .IR /udev/ .
70 .TP
71 .B udev_db
72 The name and location of the udev database.  The default value for this is
73 .IR /udev/.udev.tdb .
74 .TP
75 .B udev_rules
76 This is the location of the udev rules file.  The default value for this is
77 .IR /etc/udev/udev.rules .
78 If a directory is specified, the whole directory is
79 scanned for files ending with
80 .I .rules
81 and all rule files are read in lexical order.
82 .TP
83 .B udev_permissions
84 This is the location of the udev permission file. The default value for this is
85 .IR /etc/udev/udev.permissions .
86 If a directory is specified, the whole directory is scanned for files ending with
87 .I .permissions
88 and all permission files are read in lexical order.
89 .TP
90 .B udev_log
91 If you want udev to log some information to the syslog for every node created or
92 removed. The default value for this is
93 .IR yes .
94 .TP
95 .B default_mode
96 This is the default mode for all nodes that have no explicit match in the
97 permissions file.  The default value for this is
98 .IR 0666 .
99 .TP
100 .B default_owner
101 This is the default owner for all nodes that have no explicit match in the
102 permissions file.  The default value for this is
103 .IR root .
104 .TP
105 .B default_group
106 This is the default group for all nodes that have no explicit match in the
107 permissions file.  The default value for this is
108 .IR root .
109 .br
110 .P
111 .RI "A sample " udev.conf " might look like this:
112 .sp
113 .nf
114 # udev_root - where in the filesystem to place the device nodes
115 udev_root="/udev/"
116
117 # udev_db - The name and location of the udev database.
118 udev_db="/udev/.udev.tdb"
119
120 # udev_rules - The location of the directory where to look for files
121                which names ending with .rules
122 udev_rules="/etc/udev/"
123
124 # udev_permissions - The name and location of the udev permission file
125 udev_permissions="/etc/udev/udev.permissions"
126
127 # udev_log - set to "yes" if you want logging, else "no"
128 udev_log="yes"
129
130 # default_mode - set the default mode for all nodes that have no
131 #                explicit match in the permissions file
132 default_mode="0666"
133
134 # default_owner - set the default owner for all nodes that have no
135 #                 explicit match in the permissions file
136 default_owner="root"
137
138 # default_group - set the default group for all nodes that have no
139 #                 explicit match in the permissions file
140 default_group="root"
141 .fi
142 .P
143 The rules for udev to use when naming devices may specified at
144 .I /etc/udev/udev.rules
145 or specified by the
146 .I udev_rules
147 value in the
148 .I /etc/udev/udev.conf
149 file.
150 .P
151 Every line in the rules file defines the mapping between device attributes
152 and the device file name. One ore more keys are specified to match a rule
153 with the current device. If all keys are matching, the rule will be applied
154 and the name is used for the device node.
155 .br
156 If no matching rule is found, the default kernel device name is used.
157 .P
158 Every rule consists of a list a comma separated fields:
159 .sp
160 .IR "key " ,[ "key " ,...] " name " [, " symlink" ]
161 .sp
162 where possible fields are:
163 .TP
164 .B BUS
165 Match the bus type of the device.
166 (The sysfs device bus must be able to be determined by a "device" symlink.)
167 .TP
168 .B KERNEL
169 Match the kernel device name.
170 .TP
171 .B ID
172 Match the device number on the bus, like PCI bus id.
173 .TP
174 .B PLACE
175 Match the topological position on bus, like physical port of USB device
176 .TP
177 .BI SYSFS{ filename }
178 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
179 or file system label.  Up to 5 different sysfs files can be checked, with
180 all of the values being required in order to match the rule.
181 .TP
182 .B PROGRAM
183 Call external program. This key is valid if the program returns successful.
184 The environment variables of
185 .B udev
186 are also available for the program.
187 .br
188 The string returned by the program may additionally matched with the
189 .B RESULT
190 key.
191 .TP
192 .B RESULT
193 Match the returned string of the last
194 .B PROGRAM
195 call. This key may used in any following rule after a
196 .B PROGRAM
197 call.
198 .TP
199 .B NAME
200 The name of the node to be created. If the name field is omitted or its
201 value is empty, the device will be ignored and no node will be created.
202 .br
203 If given with the attribute
204 .BR NAME{ all_partitions }
205 it will  create all 15 partitions of a blockdevice.
206 This may be useful for removable media devices.
207 .TP
208 .B SYMLINK
209 The name of a symlink targeting the node. Multiple symlinks may be
210 specified by separating the names by the space character.
211 .P
212 .RB "The " NAME " ," SYMLINK " and " PROGRAM
213 fields support simple printf-like string substitution:
214 .TP
215 .B %n
216 The "kernel number" of the device.
217 For example, 'sda3' has a "kernel number" of '3'.
218 .TP
219 .B %k
220 The "kernel name" for the device.
221 .TP
222 .B %M
223 The kernel major number for the device.
224 .TP
225 .B %m
226 The kernel minor number for the device.
227 .TP
228 .B %b
229 The bus id for the device.
230 .TP
231 .B %c
232 The
233 .B PROGRAM
234 returned string.
235 (This does not work within the
236 .B PROGRAM
237 field for the obvious reason.)
238 .br
239 A single part of the string, separated by the space character
240 my be selected by specifying the part number as a attribute:
241 .BI %c{ part }
242 .TP
243 .BI %s{ filename }
244 The content of a sysfs attribute.
245 .TP
246 .B %%
247 The '%' character itself.
248 .P
249 The count of charcters to insert may be limited by specifying
250 the format length value. For example, '%3s{file}' will only insert
251 the first three characters of the sysfs attribute.
252 .P
253 .RI "A sample " udev.rules " might look like this:"
254 .sp
255 .nf
256 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
257 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
258
259 # USB printer to be called lp_color
260 BUS="usb", SYSFS{serial}="W09090207101241330", NAME="lp_color"
261
262 # SCSI disk with a specific vendor and model number is to be called boot
263 BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
264
265 # sound card with PCI bus id 00:0b.0 to be called dsp
266 BUS="pci", ID="00:0b.0", NAME="dsp"
267
268 # USB mouse at third port of the second hub to be called mouse1
269 BUS="usb", PLACE="2.3", NAME="mouse1"
270
271 # ttyUSB1 should always be called pda with two additional symlinks
272 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
273
274 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
275 BUS="usb", SYSFS{model}="XV3", NAME="video%n", SYMLINK="webcam%n"
276 .fi
277 .P
278 Permissions and ownership for the created device files may specified at
279 .I /etc/udev/udev.permissions
280 or specified by the
281 .I udev_permission
282 value in the
283 .I /etc/udev/udev.conf
284 file.
285 .br
286 Every line lists a device name followed by owner, group and permission
287 mode. All values are separated by colons. The name field may contain a
288 pattern to apply the values to a whole class of devices.
289 .sp
290 .RI "A sample " udev.permissions " might look like this:"
291 .sp
292 .nf
293 #name:user:group:mode
294 input/*:root:root:644
295 ttyUSB1:0:8:0660
296 video*:root:video:0660
297 dsp1:::0666
298 .fi
299 .P
300 The value
301 .I $local
302 can be substituted for a specific username.  In that case, udev will determine
303 the current local user at the time of device node creation and substitute
304 that username as the owner of the new device node.  This is useful, for
305 example, to let hot-plugged devices, such as cameras, be owned by the user at
306 the current console.  Note that if no user is currently logged in, or if udev
307 otherwise fails to determine a current user, the
308 .I default_owner
309 value is used in lieu.
310 .P
311 A number of different fields in the above configuration files support a simple
312 form of shell style pattern matching. It supports the following pattern characters:
313 .TP
314 .B *
315 Matches zero, one, or more characters.
316 .TP
317 .B ?
318 Matches any single character, but does not match zero characters.
319 .TP
320 .B [ ]
321 Matches any single character specified within the brackets. For example, the
322 pattern string "tty[SR]" would match either "ttyS" or "ttyR".  Ranges are also
323 supported within this match with the '\-' character.  For example, to match on
324 the range of all digits, the pattern [0\-9] would be used. If the first character
325 following the '[' is a '!' then any character not enclosed is matched.
326 .SH "FILES"
327 .nf
328 /sbin/udev                           udev program
329 /etc/udev/*                          udev config files
330 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
331 .fi
332 .LP
333 .SH "SEE ALSO"
334 .BR udevinfo (8),
335 .BR udevd (8),
336 .BR hotplug (8)
337 .PP
338 The
339 .I http://linux\-hotplug.sourceforge.net/
340 web site.
341 .SH AUTHORS
342 .B udev
343 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
344 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
345 many others.