chiark / gitweb /
[PATCH] misc code cleanups.
[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 .br
7 .B udev
8 .RI "[-q " query_type " -p " sysfs_path "] [-drVh]"
9 .SH "DESCRIPTION"
10 .B udev
11 creates or removes device node files usually located in the /dev directory.
12 Its goal is to provide a dynamic device directory that contains only the files
13 for devices that are actually present.
14 .P
15 As part of the
16 .B hotplug
17 subsystem,
18 .B udev
19 is executed if a kernel device is added or removed from the system.
20 On device creation,
21 .B udev
22 reads the sysfs directory of the given device to collect device attributes
23 like label, serial number or bus device number.
24 These attributes may used as keys to determine a
25 unique name for device file creation.
26 .B udev
27 maintains a database for devices present on the system.
28 .br
29 On device removal,
30 .B udev
31 queries its database for the name of the device file to be deleted.
32 .SH "OPTIONS"
33 .B udev
34 normally is called by
35 .B hotplug
36 with the subsystem as argument and various environment variables set.
37 .br
38 It may also called with the following options:
39 .TP
40 .B -V
41 Print the version information.
42 .TP
43 .B -r
44 Print the the
45 .B udev_root
46 directory. When used in conjunction with a query for the node name, the
47 .B udev_root
48 will be prepended.
49 .TP
50 .BI -q " query_type"
51 Query the database for specified value of a created device node.
52 Valid types are:
53 .BR name ", " symlink ", " owner " , " group " or " path.
54 .TP
55 .BI -p " sysfs_path"
56 Specify the sysfs path of the device to query.
57 .TP
58 .BI -n " name"
59 Specify the name of the node for the device to query.
60 .TP
61 .B -d
62 Dump the whole database.
63 .TP
64 .B -h
65 Print help text.
66 .SH "CONFIGURATION"
67 All
68 .B udev
69 configuration files consist of a set of lines of text.  All empty
70 lines, and lines beginning with a '#' will be ignored.
71 .P
72
73 .B udev
74 expects its main configuration file at
75 .I /etc/udev/udev.conf.
76 The file consists of a set of variables and values that allow the user to
77 override default udev values.  The current set of variables that can be
78 overridden in this file is:
79 .TP
80 .B udev_root
81 This is the where in the filesystem to place the device nodes.  The default
82 value for this is
83 .I /udev/
84 .TP
85 .B udev_db
86 The name and location of the udev database.  The default value for this is
87 .I /udev/.udev.tdb
88 .TP
89 .B udev_rules
90 This is the location of the udev rules file.  The default value for this is
91 .I /etc/udev/udev.rules
92 .TP
93 .B udev_permissions
94 This is the location of the udev permission file.  The default value for this is
95 .I /etc/udev/udev.permissions
96 .TP
97 .B default_mode
98 This is the default mode for all nodes that have no explicit match in the
99 permissions file.  The default value for this is
100 .I 0666
101 .TP
102 .B default_owner
103 This is the default owner for all nodes that have no explicit match in the
104 permissions file.  The default value for this is
105 .I root
106 .TP
107 .B default_group
108 This is the default group for all nodes that have no explicit match in the
109 permissions file.  The default value for this is
110 .I root
111 .br
112 .P
113 .RI "A sample " udev.conf " might look like this:
114 .sp
115 .nf
116 # udev_root - where in the filesystem to place the device nodes
117 udev_root="/udev/"
118
119 # udev_db - The name and location of the udev database.
120 udev_db="/udev/.udev.tdb"
121
122 # udev_rules - The name and location of the udev rules file
123 udev_rules="/etc/udev/udev.rules"
124
125 # udev_permissions - The name and location of the udev permission file
126 udev_permissions="/etc/udev/udev.permissions"
127
128 # default_mode - set the default mode for all nodes that have no
129 #                explicit match in the permissions file
130 default_mode="0666"
131
132 # default_owner - set the default owner for all nodes that have no
133 #                 explicit match in the permissions file
134 default_owner="root"
135
136 # default_group - set the default group for all nodes that have no
137 #                 explicit match in the permissions file
138 default_group="root"
139 .fi
140 .P
141 The rules for udev to use when naming devices may specified at
142 .I /etc/udev/udev.rules
143 or specified by the
144 .I udev_rules
145 value in the
146 .I /etc/udev/udev.conf
147 file.
148 .P
149 Every line in the rules file defines the mapping between device attributes
150 and the device file name. One ore more keys are specified to match a rule
151 with the current device. If all keys are matching, the rule will be applied
152 and the name is used for the device node. One or more optional symlinks
153 targeting the node may be specified.
154 .br
155 If no matching rule is found, the default kernel device name is used.
156 .P
157 The line format is:
158 .sp
159 .I key,[key,...] name [, symlink]
160 .sp
161 where keys are:
162 .TP
163 .B BUS
164 Match the bus type of the device.
165 (The sysfs device bus must be able to be determined by a "device" symlink.)
166 .TP
167 .B KERNEL
168 Match the kernel device name.
169 .TP
170 .B ID
171 Match the device number on the bus, like PCI bus id.
172 .TP
173 .B PLACE
174 Match the topological position on bus, like physical port of USB device
175 .TP
176 .BI SYSFS_ filename
177 Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
178 or file system label.  Up to 5 different sysfs files can be checked, with
179 all of the values being required in order to match the rule.
180 .TP
181 .B PROGRAM
182 Call external program. This key is valid if the program returns successful.
183 The string returned by the program may additionally matched with the
184 .B RESULT
185 key.
186 .TP
187 .B RESULT
188 Match the returned string of the last
189 .B PROGRAM
190 call. This key may used in any following rule after a
191 .B PROGRAM
192 call.
193 .P
194 .RB "The " NAME " ," SYMLINK " and " PROGRAM
195 fields support simple printf-like string substitution:
196 .TP
197 .B %n
198 The "kernel number" of the device.
199 for example, 'sda3' has a "kernel number" of '3'
200 .TP
201 .B %k
202 The "kernel name" for the device.
203 .TP
204 .B %M
205 The kernel major number for the device.
206 .TP
207 .B %m
208 The kernel minor number for the device.
209 .TP
210 .B %b
211 The bus id for the device.
212 .TP
213 .B %c
214 The
215 .B PROGRAM
216 returned string.
217 (This does not work within the
218 .B PROGRAM
219 field for the obvious reason.)
220 .TP
221 .B %%
222 The '%' char itself.
223 .P
224 .RI "A sample " udev.rules " might look like this:"
225 .sp
226 .nf
227 # if /sbin/scsi_id returns "OEM 0815" device will be called disk1
228 BUS="scsi", PROGRAM="/sbin/scsi_id", RESULT="OEM 0815", NAME="disk1"
229
230 # USB printer to be called lp_color
231 BUS="usb", SYSFS_serial="W09090207101241330", NAME="lp_color"
232
233 # SCSI disk with a specific vendor and model number is to be called boot
234 BUS="scsi", SYSFS_vendor="IBM", SYSFS_model="ST336", NAME="boot%n"
235
236 # sound card with PCI bus id 00:0b.0 to be called dsp
237 BUS="pci", ID="00:0b.0", NAME="dsp"
238
239 # USB mouse at third port of the second hub to be called mouse1
240 BUS="usb", PLACE="2.3", NAME="mouse1"
241
242 # ttyUSB1 should always be called pda with two additional symlinks
243 KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
244
245 # multiple USB webcams with symlinks to be called webcam0, webcam1, ...
246 BUS="usb", SYSFS_model="XV3", NAME="video%n", SYMLINK="webcam%n"
247 .fi
248 .P
249 Permissions and ownership for the created device files may specified at
250 .I /etc/udev/udev.permissions
251 or specified by the
252 .I udev_permission
253 value in the
254 .I /etc/udev/udev.conf
255 file.
256 .br
257 Every line lists a device name followed by owner, group and permission
258 mode. All values are separated by colons. The name field may contain a
259 pattern to apply the values to a whole class of devices.
260 .br
261 If
262 .B udev
263 was built using klibc or is used before the user database is accessible (e.g.
264 .BR initrd "(4)), only numeric owner and group values may be used."
265 .sp
266 .RI "A sample " udev.permissions " might look like this:"
267 .sp
268 .nf
269 #name:user:group:mode
270 input/*:root:root:644
271 ttyUSB1:0:8:0660
272 video*:root:video:0660
273 dsp1:::0666
274 .fi
275 .P
276 A number of different fields in the above configuration files support a simple
277 form of shell style pattern matching. It supports the following pattern characters:
278 .TP
279 .B *
280 Matches zero, one, or more characters.
281 .TP
282 .B ?
283 Matches any single character, but does not match zero characters.
284 .TP
285 .B [ ]
286 Matches any single character specified within the brackets. For example, the
287 pattern string "tty[SR]" would match either "ttyS" or "ttyR".  Ranges are also
288 supported within this match with the '-' character.  For example, to match on
289 the range of all digits, the pattern [0-9] would be used. If the first character
290 following the '[' is a '!' then any character not enclosed is matched.
291 .SH "FILES"
292 .nf
293 /sbin/udev                           udev program
294 /etc/udev/*                          udev config files
295 /etc/hotplug.d/default/udev.hotplug  hotplug symlink to udev program
296 .fi
297 .LP
298 .SH "SEE ALSO"
299 .BR hotplug (8)
300 .PP
301 The
302 .I http://linux-hotplug.sourceforge.net/
303 web site.
304 .SH AUTHORS
305 .B udev
306 was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
307 Dan Stekloff <dsteklof@us.ibm.com>, Kay Sievers <kay.sievers@vrfy.org>, and
308 many others.