chiark / gitweb /
man: add ATTR{file}="value" assignment
[elogind.git] / udev.7
1 .\"     Title: udev
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
4 .\"      Date: August 2005
5 .\"    Manual: udev
6 .\"    Source: udev
7 .\"
8 .TH "UDEV" "7" "August 2005" "udev" "udev"
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 udev \- dynamic device management
15 .SH "DESCRIPTION"
16 .PP
17 udev provides a dynamic device directory containing only the files for actually present devices. It creates or removes device node files in the
18 \fI/dev\fR
19 directory, or it renames network interfaces.
20 .PP
21 Usually udev runs as
22 \fBudevd\fR(8)
23 and receives uevents directly from the kernel if a device is added or removed form the system.
24 .PP
25 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.
26 .SH "CONFIGURATION"
27 .PP
28 All udev configuration files are placed in
29 \fI/etc/udev/*\fR. Every file consists of a set of lines of text. All empty lines or lines beginning with '#' will be ignored.
30 .SS "Configuration file"
31 .PP
32 udev expects its main configuration file at
33 \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:
34 .TP 3n
35 \fBudev_root\fR
36 Specifies where to place the device nodes in the filesystem. The default value is
37 \fI/dev\fR.
38 .TP 3n
39 \fBudev_rules\fR
40 The name of the udev rules file or directory to look for files with the suffix
41 \fI.rules\fR. Multiple rule files are read in lexical order. The default value is
42 \fI/etc/udev/rules.d\fR.
43 .TP 3n
44 \fBudev_log\fR
45 The logging priority. Valid values are the numerical syslog priorities or their textual representations:
46 \fBerr\fR,
47 \fBinfo\fR
48 and
49 \fBdebug\fR.
50 .\" end of SS subsection "Configuration file"
51 .SS "Rules files"
52 .PP
53 The udev rules are read from the files located in the
54 \fI/etc/udev/rules.d\fR
55 directory or at the location specified value in the configuration file. Every line in the rules file contains at least one key value pair. There are two kind of keys, match and assignment 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.
56 .PP
57 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:
58 .TP 3n
59 \fB==\fR
60 Compare for equality.
61 .TP 3n
62 \fB!=\fR
63 Compare for non\-equality.
64 .TP 3n
65 \fB=\fR
66 Assign a value to a key. Keys that represent a list, are reset and only this single value is assigned.
67 .TP 3n
68 \fB+=\fR
69 Add the value to a key that holds a list of entries.
70 .TP 3n
71 \fB:=\fR
72 Assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules.
73 .PP
74 The following key names can be used to match against device properties:
75 .TP 3n
76 \fBACTION\fR
77 Match the name of the event action.
78 .TP 3n
79 \fBDEVPATH\fR
80 Match the devpath of the event device.
81 .TP 3n
82 \fBKERNEL\fR
83 Match the name of the event device.
84 .TP 3n
85 \fBSUBSYSTEM\fR
86 Match the subsystem of the event device.
87 .TP 3n
88 \fBATTR{\fR\fB\fIfilename\fR\fR\fB}\fR
89 Match sysfs attribute values of the event device. Up to five
90 \fBATTR\fR
91 keys can be specified per rule. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself. Depending on the type of operator, this key is also used to set the value of a sysfs attribute.
92 .TP 3n
93 \fBKERNELS\fR
94 Search the devpath upwards for a matching device name.
95 .TP 3n
96 \fBSUBSYSTEMS\fR
97 Search the devpath upwards for a matching device subsystem name.
98 .TP 3n
99 \fBDRIVERS\fR
100 Search the devpath upwards for a matching device driver name.
101 .TP 3n
102 \fBATTRS{\fR\fB\fIfilename\fR\fR\fB}\fR
103 Search the devpath upwards for a device with matching sysfs attribute values. Up to five
104 \fBATTRS\fR
105 keys can be specified per rule. All attributes must match on the same device. Trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself.
106 .TP 3n
107 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
108 Match against the value of an environment variable. Up to five
109 \fBENV\fR
110 keys can be specified per rule. Depending on the type of operator, this key is also used to export a variable to the environment.
111 .TP 3n
112 \fBPROGRAM\fR
113 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.
114 .TP 3n
115 \fBRESULT\fR
116 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.
117 .PP
118 Most of the fields support a shell style pattern matching. The following pattern characters are supported:
119 .TP 3n
120 \fB*\fR
121 Matches zero, or any number of characters.
122 .TP 3n
123 \fB?\fR
124 Matches any single character.
125 .TP 3n
126 \fB[]\fR
127 Matches any single character specified within the brackets. For 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.
128 .PP
129 The following keys can get values assigned:
130 .TP 3n
131 \fBNAME\fR
132 The name of the node to be created, or the name the network interface should be renamed to. Only one rule can set the node name, all later rules with a NAME key will be ignored.
133 .TP 3n
134 \fBSYMLINK\fR
135 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.
136 .TP 3n
137 \fBOWNER, GROUP, MODE\fR
138 The permissions for the device node. Every specified value overwrites the compiled\-in default value.
139 .TP 3n
140 \fBATTR{\fR\fB\fIkey\fR\fR\fB}\fR
141 The value that should be written to a sysfs attribute of the event device. Depending on the type of operator, this key is also used to match against the value of a sysfs attribute.
142 .TP 3n
143 \fBENV{\fR\fB\fIkey\fR\fR\fB}\fR
144 Export a variable to the environment. Depending on the type of operator, this key is also to match against an environment variable.
145 .TP 3n
146 \fBRUN\fR
147 Add a program to the list of programs to be executed for a specific device. This can only be used for very short running tasks. Running an event process for a long period of time may block all further events for this or a dependent device. Long running tasks need to be immediately detached from the event process itself.
148 .TP 3n
149 \fBLABEL\fR
150 Named label where a GOTO can jump to.
151 .TP 3n
152 \fBGOTO\fR
153 Jumps to the next LABEL with a matching name
154 .TP 3n
155 \fBIMPORT{\fR\fB\fItype\fR\fR\fB}\fR
156 Import the printed result or the value of a file in environment key format into the event environment.
157 \fBprogram\fR
158 will execute an external program and read its output.
159 \fBfile\fR
160 will import a text file. If no option is given, udev will determine it from the executable bit of of the file permissions.
161 .TP 3n
162 \fBWAIT_FOR_SYSFS\fR
163 Wait for the specified sysfs file of the device to be created. Can be used to fight against kernel sysfs timing issues.
164 .TP 3n
165 \fBOPTIONS\fR
166 \fBlast_rule\fR
167 stops further rules application. No later rules will have any effect.
168 \fBignore_device\fR
169 will ignore this event completely.
170 \fBignore_remove\fR
171 will ignore any later remove event for this device. This may be useful as a workaround for broken device drivers.
172 \fBall_partitions\fR
173 will create the device nodes for all available partitions of a block device. This may be useful for removable media devices where media changes are not detected.
174 .PP
175 The
176 \fBNAME\fR,
177 \fBSYMLINK\fR,
178 \fBPROGRAM\fR,
179 \fBOWNER\fR,
180 \fBGROUP\fR
181 and
182 \fBRUN\fR
183 fields support simple printf\-like string substitutions. The
184 \fBRUN\fR
185 format chars gets applied after all rules have been processed, right before the program is executed. It allows the use of the complete environment set by earlier matching rules. For all other fields, substitutions are applied while the individual rule is being processed. The available substitutions are:
186 .TP 3n
187 \fB$kernel\fR, \fB%k\fR
188 The kernel name for this device.
189 .TP 3n
190 \fB$number\fR, \fB%n\fR
191 The kernel number for this device. For example, 'sda3' has kernel number of '3'
192 .TP 3n
193 \fB$devpath\fR, \fB%p\fR
194 The devpath of the device.
195 .TP 3n
196 \fB$id\fR, \fB%b\fR
197 The name of the device matched while searching the devpath upwards for
198 \fBSUBSYSTEMS\fR,
199 \fBKERNELS\fR
200 \fBDRIVERS\fR
201 and
202 \fBATTRS\fR.
203 .TP 3n
204 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
205 The value of a sysfs attribute found at the current or a parent device.
206 .TP 3n
207 \fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR
208 The value of an environment variable.
209 .TP 3n
210 \fB$major\fR, \fB%M\fR
211 The kernel major number for the device.
212 .TP 3n
213 \fB$minor\fR \fB%m\fR
214 The kernel minor number for the device.
215 .TP 3n
216 \fB$result\fR, \fB%c\fR
217 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:
218 \fB%c{N}\fR. If the number is followed by the '+' char this part plus all remaining parts of the result string are substituted:
219 \fB%c{N+}\fR
220 .TP 3n
221 \fB$parent\fR, \fB%P\fR
222 The node name of the parent device.
223 .TP 3n
224 \fB$root\fR, \fB%r\fR
225 The udev_root value.
226 .TP 3n
227 \fB$tempnode\fR, \fB%N\fR
228 The name of a created temporary device node to provide access to the device from a external program before the real node is created.
229 .TP 3n
230 \fB%%\fR
231 The '%' character itself.
232 .TP 3n
233 \fB$$\fR
234 The '$' character itself.
235 .PP
236 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
237 .\" end of SS subsection "Rules files"
238 .SH "AUTHOR"
239 .PP
240 Written by Greg Kroah\-Hartman
241 <greg@kroah.com>
242 and Kay Sievers
243 <kay.sievers@vrfy.org>. With much help from Dan Stekloff
244 <dsteklof@us.ibm.com>
245 and many others.
246 .SH "SEE ALSO"
247 .PP
248 \fBudevd\fR(8),
249 \fBudevinfo\fR(8),
250 \fBudevmonitor\fR(8)