chiark / gitweb /
udevd: don't daemonize before initialization
[elogind.git] / udev.8
1 .\" ** You probably do not want to edit this file directly **
2 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.0).
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" "8" "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. The program 
21 \fBudev\fR 
22 itself may be used as an event handler in situations, where running the daemon is not appropriate, like in initramfs.
23 .PP
24 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.
25 .SH "CONFIGURATION"
26 .PP
27 All udev configuration files are placed in 
28 \fI/etc/udev/*\fR. Every file consist of a set of lines of text. All empty lines or lines beginning with '#' will be ignored.
29 .SS "Configuration file"
30 .PP
31 udev expects its main configuration file at 
32 \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:
33 .TP
34 \fBudev_root\fR
35 Specifies where to place the device nodes in the filesystem. The default value is 
36 \fI/dev\fR.
37 .TP
38 \fBudev_db\fR
39 The name and location of the udev database. The default value is 
40 \fI/dev/.udevdb\fR.
41 .TP
42 \fBudev_rules\fR
43 The name of the udev rules file or directory to look for files with the suffix 
44 \fI.rules\fR. Multiple rule files are read in lexical order. The default value is 
45 \fI/etc/udev/rules.d\fR.
46 .TP
47 \fBudev_log\fR
48 The logging priority. Valid values are the numerical syslog priorities or their textual representations: 
49 \fBerr\fR, 
50 \fBinfo\fR 
51 and 
52 \fBdebug\fR.
53 .SS "Rules files"
54 .PP
55 The udev rules are read from the files located in the 
56 \fI/etc/udev/rules.d\fR 
57 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.
58 .PP
59 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:
60 .TP
61 \fB==\fR
62 Compare for equality.
63 .TP
64 \fB!=\fR
65 Compare for non\-equality.
66 .TP
67 \fB=\fR
68 Asign a value to a key. Keys that represent a list, are reset and only this single value is assigned.
69 .TP
70 \fB+=\fR
71 Add the value to a key that holds a list of entries.
72 .TP
73 \fB:=\fR
74 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules.
75 .PP
76 The following key names can be used to match against device properties:
77 .TP
78 \fBACTION\fR
79 Match the kernel action name.
80 .TP
81 \fBKERNEL\fR
82 Match the kernel device name
83 .TP
84 \fBDEVPATH\fR
85 Match the kernel devpath.
86 .TP
87 \fBSUBSYSTEM\fR
88 Match the kernel subsystem name
89 .TP
90 \fBBUS\fR
91 Match the typ of bus the device is connected to.
92 .TP
93 \fBDRIVER\fR
94 Match the kernel driver name.
95 .TP
96 \fBID\fR
97 Match the device number on the bus.
98 .TP
99 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
100 Match against the value of an environment key. Depending on the specified operation, this key is also used as a assignment.
101 .TP
102 \fBSYSFS{\fR\fB\fIfilename\fR\fR\fB}\fR
103 Match the sysfs attribute value. Up to five values can be specified. Trailing whitespace is ignored, if the specified match value does not contain trailing whitespace itself.
104 .TP
105 \fBPROGRAM\fR
106 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.
107 .TP
108 \fBRESULT\fR
109 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.
110 .PP
111 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
112 .TP
113 \fB*\fR
114 Matches zero, or any number of characters.
115 .TP
116 \fB?\fR
117 Matches any single character.
118 .TP
119 \fB[]\fR
120 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.
121 .PP
122 The following keys can get values assigned:
123 .TP
124 \fBNAME\fR
125 The name of the node to be created, or the name, the network interface should be renamed to. Only one rule can set the a name, all later rules with a NAME key will be ignored.
126 .TP
127 \fBSYMLINK\fR
128 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.
129 .TP
130 \fBOWNER, GROUP, MODE\fR
131 The permissions for the device node. Every specified value over writes the compiled\-in default value.
132 .TP
133 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
134 Export the key to the environment. Depending on the specified operation, this key is also used as a match.
135 .TP
136 \fBRUN\fR
137 Add a program to the list of programs to be executed for a specific device.
138 .TP
139 \fBLABEL\fR
140 Named label where a GOTO can jump to.
141 .TP
142 \fBGOTO\fR
143 Jumps to the next LABEL with a matching gname
144 .TP
145 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
146 Import the printed result or the content of a file in environment key format into the event environment. 
147 \fBprogram\fR 
148 will execute an external program and read its output. 
149 \fBfile\fR 
150 will inport a text file. If no option is given, udev will determine it from the executable bit of of the file permissions.
151 .TP
152 \fBWAIT_FOR_SYSFS\fR
153 Wait for the specified sysfs file of the device to be created. May be used to fight agains timing issues wth the kernel.
154 .TP
155 \fBOPTIONS\fR
156 \fBlast_rule\fR 
157 stops further rules application. No later rules will have any effect. 
158 \fBignore_device\fR 
159 will ignore this event completely. 
160 \fBignore_remove\fR 
161 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers. 
162 \fBall_partitions\fR 
163 will create device nodes for all available partitions of a block device. This may be useful for removable media.
164 .PP
165 The 
166 \fBNAME\fR, 
167 \fBSYMLINK\fR, 
168 \fBPROGRAM\fR, 
169 \fBOWNER\fR 
170 and 
171 \fBGROUP\fR 
172 fields support simple printf\-like string substitutions:
173 .TP
174 \fB%k\fR, \fB$kernel\fR
175 The kernel name for this device.
176 .TP
177 \fB%b\fR, \fB$id\fR
178 The kernel bus id for this device.
179 .TP
180 \fB%n\fR, \fB$number\fR
181 The kernel number for this device. For example, 'sda3' has kernel number of '3'
182 .TP
183 \fB%p\fR, \fB$devpath\fR
184 The devpath of the device.
185 .TP
186 \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR, \fB$sysfs{\fR\fB\fIfile\fR\fR\fB}\fR
187 The content of a sysfs attribute.
188 .TP
189 \fB%e{\fR\fB\fIkey\fR\fR\fB}\fR, \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR
190 The value of an environment variable.
191 .TP
192 \fB%m\fR, \fB$major\fR
193 The kernel major number for the device.
194 .TP
195 \fB%M\fR \fB$minor\fR
196 The kernel minor number for the device.
197 .TP
198 \fB%c\fR, \fB$result\fR
199 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: 
200 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted: 
201 \fB%c{N+}\fR
202 .TP
203 \fB%e\fR, \fB$enum\fR
204 If a device node already exists with the name, the smallest next free number is used. This can be used to create compatibility symlinks and enumerate devices of the same type originating from different kernel subsystems.
205
206 Note: The use of the enumeration facility is unreliable for events that request a number at the same time. The use of enumerations in todays setups where devices can come and go at any time is not recommended.
207 .TP
208 \fB%P\fR, \fB$parent\fR
209 The node name of the parent device.
210 .TP
211 \fB%r\fR, \fB$root\fR
212 The udev_root value.
213 .TP
214 \fB%N\fR, \fB$tempnode\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 \fBudev\fR(8), 
251 \fBudevinfo\fR(8), 
252 \fBudevd\fR(8), 
253 \fBudevmonitor\fR(8)