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