| 1 |
'\" t |
| 2 |
.TH "UDEV" "7" "" "systemd 261~rc3" "udev" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
udev \- Dynamic device management |
| 24 |
.SH "DESCRIPTION" |
| 25 |
.PP |
| 26 |
udev supplies the system software with device events, manages permissions of device nodes and may create additional symlinks in the |
| 27 |
/dev/ |
| 28 |
directory, or renames network interfaces\&. The kernel usually just assigns unpredictable device names based on the order of discovery\&. Meaningful symlinks or network device names provide a way to reliably identify devices based on their properties or current configuration\&. |
| 29 |
.PP |
| 30 |
The udev daemon, |
| 31 |
\fBsystemd-udevd.service\fR(8), receives device uevents directly from the kernel whenever a device is added or removed from the system, or it changes its state\&. When udev receives a device event, it matches its configured set of rules against various device attributes to identify the device\&. Rules that match may provide additional device information to be stored in the udev database or to be used to create meaningful symlink names\&. |
| 32 |
.PP |
| 33 |
All device information udev processes is stored in the udev database and sent out to possible event subscribers\&. Access to all stored data and the event sources is provided by the library libudev\&. |
| 34 |
.SH "RULES FILES" |
| 35 |
.PP |
| 36 |
The udev rules are read from the files located in the system rules directories |
| 37 |
/usr/lib/udev/rules\&.d |
| 38 |
and |
| 39 |
/usr/local/lib/udev/rules\&.d, the volatile runtime directory |
| 40 |
/run/udev/rules\&.d |
| 41 |
and the local administration directory |
| 42 |
/etc/udev/rules\&.d\&. All rules files are collectively sorted and processed in lexicographic order, regardless of the directories in which they live\&. However, files with identical filenames replace each other\&. Files in |
| 43 |
/etc/ |
| 44 |
have the highest priority, files in |
| 45 |
/run/ |
| 46 |
take precedence over files with the same name under |
| 47 |
/usr/\&. This can be used to override a system\-supplied rules file with a local file if needed; a symlink in |
| 48 |
/etc/ |
| 49 |
with the same name as a rules file in |
| 50 |
/usr/lib/, pointing to |
| 51 |
/dev/null, disables the rules file entirely\&. Rule files must have the extension |
| 52 |
\&.rules; other extensions are ignored\&. |
| 53 |
.PP |
| 54 |
Every line in the rules file contains at least one key\-value pair\&. Except for empty lines or lines beginning with |
| 55 |
"#", which are ignored\&. There are two kinds of keys: match and assignment\&. If all match keys match against their values, the rule gets applied and the assignment keys get the specified values assigned\&. |
| 56 |
.PP |
| 57 |
A matching rule may rename a network interface, add symlinks pointing to the device node, or run a specified program as part of the event handling\&. |
| 58 |
.PP |
| 59 |
A rule consists of a comma\-separated list of one or more key\-operator\-value expressions\&. Each expression has a distinct effect, depending on the key and operator used\&. |
| 60 |
.SS "Operators" |
| 61 |
.PP |
| 62 |
"==" |
| 63 |
.RS 4 |
| 64 |
Compare for equality\&. (The specified key has the specified value\&.) |
| 65 |
.RE |
| 66 |
.PP |
| 67 |
"!=" |
| 68 |
.RS 4 |
| 69 |
Compare for inequality\&. (The specified key does not have the specified value, or the specified key is not present at all\&.) |
| 70 |
.RE |
| 71 |
.PP |
| 72 |
"=" |
| 73 |
.RS 4 |
| 74 |
Assign a value to a key\&. Keys that represent a list are reset and only this single value is assigned\&. |
| 75 |
.RE |
| 76 |
.PP |
| 77 |
"+=" |
| 78 |
.RS 4 |
| 79 |
Add the value to a key that holds a list of entries\&. |
| 80 |
.RE |
| 81 |
.PP |
| 82 |
"\-=" |
| 83 |
.RS 4 |
| 84 |
Remove the value from a key that holds a list of entries\&. |
| 85 |
.sp |
| 86 |
Added in version 217\&. |
| 87 |
.RE |
| 88 |
.PP |
| 89 |
":=" |
| 90 |
.RS 4 |
| 91 |
Assign a value to a key finally; disallow any later changes\&. |
| 92 |
.sp |
| 93 |
Added in version 247\&. |
| 94 |
.RE |
| 95 |
.SS "Values" |
| 96 |
.PP |
| 97 |
Values are written as double quoted strings, such as ("string")\&. To include a quotation mark (") in the value, precede it by a backslash (\e")\&. Any other occurrences of a backslash followed by a character are not unescaped\&. That is, "\et\en" is treated as four characters: backslash, lowercase t, backslash, lowercase n\&. |
| 98 |
.PP |
| 99 |
The string can be prefixed with a lowercase e (e"string\en") to mark the string as C\-style escaped, see |
| 100 |
\m[blue]\fBEscape sequences in C\fR\m[]\&\s-2\u[1]\d\s+2\&. For example, e"string\en" is parsed as 7 characters: 6 lowercase letters and a newline\&. This can be useful for writing special characters when a kernel driver requires them\&. |
| 101 |
.PP |
| 102 |
The string can be prefixed with a lowercase i (i"string") to mark that the string or pattern will match case\-insensitively\&. For example, i"foo" will match |
| 103 |
"foo", |
| 104 |
"FOO", |
| 105 |
"FoO" |
| 106 |
and so on\&. The prefix can be used only for match ("==") or unmatch ("!=") rules, e\&.g\&. |
| 107 |
\fIATTR{foo}==i"abcd"\fR\&. |
| 108 |
.PP |
| 109 |
Please note that |
| 110 |
\fBNUL\fR |
| 111 |
is not allowed in either string variant\&. |
| 112 |
.SS "Keys" |
| 113 |
.PP |
| 114 |
The following key names can be used to match against device properties\&. Some of the keys also match against properties of the parent devices in sysfs, not only the device that has generated the event\&. If multiple keys that match a parent device are specified in a single rule, all these keys must match at one and the same parent device\&. |
| 115 |
.PP |
| 116 |
\fIACTION\fR |
| 117 |
.RS 4 |
| 118 |
Match the name of the event action\&. |
| 119 |
.RE |
| 120 |
.PP |
| 121 |
\fIDEVPATH\fR |
| 122 |
.RS 4 |
| 123 |
Match the devpath of the event device\&. |
| 124 |
.RE |
| 125 |
.PP |
| 126 |
\fIKERNEL\fR |
| 127 |
.RS 4 |
| 128 |
Match the name of the event device\&. |
| 129 |
.RE |
| 130 |
.PP |
| 131 |
\fIKERNELS\fR |
| 132 |
.RS 4 |
| 133 |
Search the devpath upwards for a matching device name\&. |
| 134 |
.RE |
| 135 |
.PP |
| 136 |
\fINAME\fR |
| 137 |
.RS 4 |
| 138 |
Match the name of a network interface\&. It can be used once the NAME key has been set in one of the preceding rules\&. |
| 139 |
.RE |
| 140 |
.PP |
| 141 |
\fISYMLINK\fR |
| 142 |
.RS 4 |
| 143 |
Match the name of a symlink targeting the node\&. It can be used once a SYMLINK key has been set in one of the preceding rules\&. There may be multiple symlinks; only one needs to match\&. If the operator is |
| 144 |
"!=", the token returns true only if there is no symlink matched\&. |
| 145 |
.RE |
| 146 |
.PP |
| 147 |
\fISUBSYSTEM\fR |
| 148 |
.RS 4 |
| 149 |
Match the subsystem of the event device\&. |
| 150 |
.RE |
| 151 |
.PP |
| 152 |
\fISUBSYSTEMS\fR |
| 153 |
.RS 4 |
| 154 |
Search the devpath upwards for a matching device subsystem name\&. |
| 155 |
.RE |
| 156 |
.PP |
| 157 |
\fIDRIVER\fR |
| 158 |
.RS 4 |
| 159 |
Match the driver name of the event device\&. Only set this key for devices which are bound to a driver at the time the event is generated\&. |
| 160 |
.RE |
| 161 |
.PP |
| 162 |
\fIDRIVERS\fR |
| 163 |
.RS 4 |
| 164 |
Search the devpath upwards for a matching device driver name\&. |
| 165 |
.RE |
| 166 |
.PP |
| 167 |
\fIATTR{\fR\fI\fIfilename\fR\fR\fI}\fR |
| 168 |
.RS 4 |
| 169 |
Match sysfs attribute value of the event device\&. |
| 170 |
.sp |
| 171 |
Trailing whitespace in the attribute values is ignored unless the specified match value itself contains trailing whitespace\&. |
| 172 |
.RE |
| 173 |
.PP |
| 174 |
\fIATTRS{\fR\fI\fIfilename\fR\fR\fI}\fR |
| 175 |
.RS 4 |
| 176 |
Search the devpath upwards for a device with matching sysfs attribute values\&. If multiple |
| 177 |
\fIATTRS\fR |
| 178 |
matches are specified, all of them must match on the same device\&. |
| 179 |
.sp |
| 180 |
Trailing whitespace in the attribute values is ignored unless the specified match value itself contains trailing whitespace\&. |
| 181 |
.RE |
| 182 |
.PP |
| 183 |
\fISYSCTL{\fR\fI\fIkernel parameter\fR\fR\fI}\fR |
| 184 |
.RS 4 |
| 185 |
Match a kernel parameter value\&. |
| 186 |
.sp |
| 187 |
Added in version 240\&. |
| 188 |
.RE |
| 189 |
.PP |
| 190 |
\fIENV{\fR\fI\fIkey\fR\fR\fI}\fR |
| 191 |
.RS 4 |
| 192 |
Match against a device property value\&. |
| 193 |
.RE |
| 194 |
.PP |
| 195 |
\fICONST{\fR\fI\fIkey\fR\fR\fI}\fR |
| 196 |
.RS 4 |
| 197 |
Match against a system\-wide constant\&. Supported keys are: |
| 198 |
.PP |
| 199 |
"arch" |
| 200 |
.RS 4 |
| 201 |
System\*(Aqs architecture\&. See |
| 202 |
\fBConditionArchitecture=\fR |
| 203 |
in |
| 204 |
\fBsystemd.unit\fR(5) |
| 205 |
for possible values\&. |
| 206 |
.sp |
| 207 |
Added in version 244\&. |
| 208 |
.RE |
| 209 |
.PP |
| 210 |
"virt" |
| 211 |
.RS 4 |
| 212 |
System\*(Aqs virtualization environment\&. See |
| 213 |
\fBsystemd-detect-virt\fR(1) |
| 214 |
for possible values\&. |
| 215 |
.sp |
| 216 |
Added in version 244\&. |
| 217 |
.RE |
| 218 |
.PP |
| 219 |
"cvm" |
| 220 |
.RS 4 |
| 221 |
System\*(Aqs confidential virtualization technology\&. See |
| 222 |
\fBsystemd-detect-virt\fR(1) |
| 223 |
for possible values\&. |
| 224 |
.sp |
| 225 |
Added in version 254\&. |
| 226 |
.RE |
| 227 |
.sp |
| 228 |
Unknown keys will never match\&. |
| 229 |
.sp |
| 230 |
Added in version 244\&. |
| 231 |
.RE |
| 232 |
.PP |
| 233 |
\fITAG\fR |
| 234 |
.RS 4 |
| 235 |
Match against one of device tags\&. It can be used once a TAG key has been set in one of the preceding rules\&. There may be multiple tags; only one needs to match\&. If the operator is |
| 236 |
"!=", the token returns true only if there is no tag matched\&. |
| 237 |
.RE |
| 238 |
.PP |
| 239 |
\fITAGS\fR |
| 240 |
.RS 4 |
| 241 |
Search the devpath upwards for a device with matching tag\&. If the operator is |
| 242 |
"!=", the token returns true only if there is no tag matched\&. |
| 243 |
.RE |
| 244 |
.PP |
| 245 |
\fITEST{\fR\fI\fIoctal mode mask\fR\fR\fI}\fR |
| 246 |
.RS 4 |
| 247 |
Test the existence of a file\&. An octal mode mask can be specified if needed\&. |
| 248 |
.RE |
| 249 |
.PP |
| 250 |
\fIPROGRAM\fR |
| 251 |
.RS 4 |
| 252 |
Execute a program to determine whether there is a match; the key is true if the program returns successfully\&. The device properties are made available to the executed program in the environment\&. The program\*(Aqs standard output is available in the |
| 253 |
\fIRESULT\fR |
| 254 |
key\&. |
| 255 |
.sp |
| 256 |
This can only be used for very short\-running foreground tasks\&. For details, see |
| 257 |
\fIRUN\fR\&. |
| 258 |
.sp |
| 259 |
Note that multiple |
| 260 |
\fIPROGRAM\fR |
| 261 |
keys may be specified in one rule, and |
| 262 |
"=", |
| 263 |
":=", and |
| 264 |
"+=" |
| 265 |
have the same effect as |
| 266 |
"=="\&. |
| 267 |
.RE |
| 268 |
.PP |
| 269 |
\fIRESULT\fR |
| 270 |
.RS 4 |
| 271 |
Match the returned string of the last |
| 272 |
\fIPROGRAM\fR |
| 273 |
call\&. This key can be used in the same or in any later rule after a |
| 274 |
\fIPROGRAM\fR |
| 275 |
call\&. |
| 276 |
.RE |
| 277 |
.PP |
| 278 |
Most of the fields support shell glob pattern matching and alternate patterns\&. The following special characters are supported: |
| 279 |
.PP |
| 280 |
"*" |
| 281 |
.RS 4 |
| 282 |
Matches zero or more characters\&. |
| 283 |
.RE |
| 284 |
.PP |
| 285 |
"?" |
| 286 |
.RS 4 |
| 287 |
Matches any single character\&. |
| 288 |
.RE |
| 289 |
.PP |
| 290 |
"[]" |
| 291 |
.RS 4 |
| 292 |
Matches any single character specified within the brackets\&. For example, the pattern string |
| 293 |
"tty[SR]" |
| 294 |
would match either |
| 295 |
"ttyS" |
| 296 |
or |
| 297 |
"ttyR"\&. Ranges are also supported via the |
| 298 |
"\-" |
| 299 |
character\&. For example, to match on the range of all digits, the pattern |
| 300 |
"[0\-9]" |
| 301 |
could be used\&. If the first character following the |
| 302 |
"[" |
| 303 |
is a |
| 304 |
"!", any characters not enclosed are matched\&. |
| 305 |
.RE |
| 306 |
.PP |
| 307 |
"|" |
| 308 |
.RS 4 |
| 309 |
Separates alternative patterns\&. For example, the pattern string |
| 310 |
"abc|x*" |
| 311 |
would match either |
| 312 |
"abc" |
| 313 |
or |
| 314 |
"x*"\&. |
| 315 |
.sp |
| 316 |
Added in version 217\&. |
| 317 |
.RE |
| 318 |
.PP |
| 319 |
The following keys can get values assigned: |
| 320 |
.PP |
| 321 |
\fINAME\fR |
| 322 |
.RS 4 |
| 323 |
The name to use for a network interface\&. See |
| 324 |
\fBsystemd.link\fR(5) |
| 325 |
for a higher\-level mechanism for setting the interface name\&. The name of a device node cannot be changed by udev, only additional symlinks can be created\&. |
| 326 |
.RE |
| 327 |
.PP |
| 328 |
\fISYMLINK\fR |
| 329 |
.RS 4 |
| 330 |
The name of a symlink targeting the node\&. Every matching rule adds this value to the list of symlinks to be created\&. |
| 331 |
.sp |
| 332 |
The set of characters to name a symlink is limited\&. Allowed characters are |
| 333 |
"0\-9A\-Za\-z#+\-\&.:=@_/", valid UTF\-8 character sequences, and |
| 334 |
"\ex00" |
| 335 |
hex encoding\&. All other characters are replaced by a |
| 336 |
"_" |
| 337 |
character\&. |
| 338 |
.sp |
| 339 |
Multiple symlinks may be specified by separating the names by the space character\&. In case multiple devices claim the same name, the link always points to the device with the highest link_priority\&. If the current device goes away, the links are re\-evaluated and the device with the next highest link_priority becomes the owner of the link\&. If no link_priority is specified, the order of the devices (and which one of them owns the link) is undefined\&. |
| 340 |
.sp |
| 341 |
Symlink names must never conflict with the kernel\*(Aqs default device node names, as that would result in unpredictable behavior\&. |
| 342 |
.RE |
| 343 |
.PP |
| 344 |
\fIOWNER\fR, \fIGROUP\fR, \fIMODE\fR |
| 345 |
.RS 4 |
| 346 |
The permissions for the device node\&. Every specified value overrides the compiled\-in default value\&. |
| 347 |
.RE |
| 348 |
.PP |
| 349 |
\fISECLABEL{\fR\fI\fImodule\fR\fR\fI}\fR |
| 350 |
.RS 4 |
| 351 |
Applies the specified Linux Security Module label to the device node\&. |
| 352 |
.sp |
| 353 |
Added in version 209\&. |
| 354 |
.RE |
| 355 |
.PP |
| 356 |
\fIATTR{\fR\fI\fIkey\fR\fR\fI}\fR |
| 357 |
.RS 4 |
| 358 |
The value that should be written to a sysfs attribute of the event device\&. |
| 359 |
.RE |
| 360 |
.PP |
| 361 |
\fISYSCTL{\fR\fI\fIkernel parameter\fR\fR\fI}\fR |
| 362 |
.RS 4 |
| 363 |
The value that should be written to kernel parameter\&. |
| 364 |
.sp |
| 365 |
Added in version 220\&. |
| 366 |
.RE |
| 367 |
.PP |
| 368 |
\fIENV{\fR\fI\fIkey\fR\fR\fI}\fR |
| 369 |
.RS 4 |
| 370 |
Set a device property value\&. Property names with a leading |
| 371 |
"\&." |
| 372 |
are neither stored in the database nor exported to events or external tools (run by, for example, the |
| 373 |
\fIPROGRAM\fR |
| 374 |
match key)\&. |
| 375 |
.RE |
| 376 |
.PP |
| 377 |
\fITAG\fR |
| 378 |
.RS 4 |
| 379 |
Attach a tag to a device\&. This is used to filter events for users of libudev\*(Aqs monitor functionality, or to enumerate a group of tagged devices\&. The implementation can only work efficiently if only a few tags are attached to a device\&. It is only meant to be used in contexts with specific device filter requirements, and not as a general\-purpose flag\&. Excessive use might result in inefficient event handling\&. |
| 380 |
.RE |
| 381 |
.PP |
| 382 |
\fIRUN{\fR\fI\fItype\fR\fR\fI}\fR |
| 383 |
.RS 4 |
| 384 |
Specify a program to be executed after processing of all the rules for the event\&. With |
| 385 |
"+=", this invocation is added to the list, and with |
| 386 |
"=" |
| 387 |
or |
| 388 |
":=", it replaces any previous contents of the list\&. Please note that both |
| 389 |
"program" |
| 390 |
and |
| 391 |
"builtin" |
| 392 |
types described below share a common list, so clearing the list with |
| 393 |
":=" |
| 394 |
and |
| 395 |
"=" |
| 396 |
affects both types\&. |
| 397 |
.sp |
| 398 |
\fItype\fR |
| 399 |
may be: |
| 400 |
.PP |
| 401 |
"program" |
| 402 |
.RS 4 |
| 403 |
Execute an external program specified as the assigned value\&. If no absolute path is given, the program is expected to live in |
| 404 |
/usr/lib/udev; otherwise, the absolute path must be specified\&. |
| 405 |
.sp |
| 406 |
This is the default if no |
| 407 |
\fItype\fR |
| 408 |
is specified\&. |
| 409 |
.RE |
| 410 |
.PP |
| 411 |
"builtin" |
| 412 |
.RS 4 |
| 413 |
As |
| 414 |
\fIprogram\fR, but use one of the built\-in programs rather than an external one\&. |
| 415 |
.sp |
| 416 |
Added in version 199\&. |
| 417 |
.RE |
| 418 |
.sp |
| 419 |
The program name and following arguments are separated by spaces\&. Single quotes can be used to specify arguments with spaces\&. |
| 420 |
.sp |
| 421 |
This can only be used for very short\-running foreground tasks\&. Running an event process for a long period of time may block all further events for this or a dependent device\&. |
| 422 |
.sp |
| 423 |
Note that running programs that access the network or mount/unmount filesystems is not allowed inside of udev rules, due to the default sandbox that is enforced on |
| 424 |
systemd\-udevd\&.service\&. |
| 425 |
.sp |
| 426 |
Starting daemons or other long\-running processes is not allowed; the forked processes, detached or not, will be unconditionally killed after the event handling has finished\&. In order to activate long\-running processes from udev rules, provide a service unit and pull it in from a udev device using the |
| 427 |
\fISYSTEMD_WANTS\fR |
| 428 |
device property\&. See |
| 429 |
\fBsystemd.device\fR(5) |
| 430 |
for details\&. |
| 431 |
.RE |
| 432 |
.PP |
| 433 |
\fILABEL\fR |
| 434 |
.RS 4 |
| 435 |
A named label to which a |
| 436 |
\fIGOTO\fR |
| 437 |
may jump\&. |
| 438 |
.RE |
| 439 |
.PP |
| 440 |
\fIGOTO\fR |
| 441 |
.RS 4 |
| 442 |
Jumps to the next |
| 443 |
\fILABEL\fR |
| 444 |
with a matching name\&. |
| 445 |
.RE |
| 446 |
.PP |
| 447 |
\fIIMPORT{\fR\fI\fItype\fR\fR\fI}\fR |
| 448 |
.RS 4 |
| 449 |
Import a set of variables as device properties, depending on |
| 450 |
\fItype\fR: |
| 451 |
.PP |
| 452 |
"program" |
| 453 |
.RS 4 |
| 454 |
Execute an external program specified as the assigned value and, if it returns successfully, import its output, which must be in environment key format\&. Path specification, command/argument separation, and quoting work like in |
| 455 |
\fIRUN\fR\&. |
| 456 |
.sp |
| 457 |
Added in version 199\&. |
| 458 |
.RE |
| 459 |
.PP |
| 460 |
"builtin" |
| 461 |
.RS 4 |
| 462 |
Similar to |
| 463 |
"program", but use one of the built\-in programs rather than an external one\&. |
| 464 |
.sp |
| 465 |
Added in version 199\&. |
| 466 |
.RE |
| 467 |
.PP |
| 468 |
"file" |
| 469 |
.RS 4 |
| 470 |
Import a text file specified as the assigned value, the content of which must be in environment key format\&. |
| 471 |
.RE |
| 472 |
.PP |
| 473 |
"db" |
| 474 |
.RS 4 |
| 475 |
Import a single property specified as the assigned value from the current device database\&. This works only if the database is already populated by an earlier event\&. |
| 476 |
.RE |
| 477 |
.PP |
| 478 |
"cmdline" |
| 479 |
.RS 4 |
| 480 |
Import a single property from the kernel command line\&. For simple flags the value of the property is set to |
| 481 |
"1"\&. |
| 482 |
.RE |
| 483 |
.PP |
| 484 |
"parent" |
| 485 |
.RS 4 |
| 486 |
Import the stored keys from the parent device by reading the database entry of the parent device\&. The value assigned to |
| 487 |
\fBIMPORT{parent}\fR |
| 488 |
is used as a filter of key names to import (with the same shell glob pattern matching used for comparisons)\&. |
| 489 |
.RE |
| 490 |
.sp |
| 491 |
This can only be used for very short\-running foreground tasks\&. For details see |
| 492 |
\fBRUN\fR\&. |
| 493 |
.sp |
| 494 |
Note that multiple |
| 495 |
\fIIMPORT{}\fR |
| 496 |
keys may be specified in one rule, and |
| 497 |
"=", |
| 498 |
":=", and |
| 499 |
"+=" |
| 500 |
have the same effect as |
| 501 |
"=="\&. The key is true if the import is successful, unless |
| 502 |
"!=" |
| 503 |
is used as the operator which causes the key to be true if the import failed\&. |
| 504 |
.RE |
| 505 |
.PP |
| 506 |
\fIOPTIONS\fR |
| 507 |
.RS 4 |
| 508 |
Rule and device options: |
| 509 |
.PP |
| 510 |
\fBlink_priority=\fR\fB\fIvalue\fR\fR |
| 511 |
.RS 4 |
| 512 |
Specify the priority of the created symlinks\&. Devices with higher priorities overwrite existing symlinks of other devices\&. The default is 0\&. |
| 513 |
.RE |
| 514 |
.PP |
| 515 |
\fBstring_escape=\fR\fB\fInone|replace\fR\fR |
| 516 |
.RS 4 |
| 517 |
When |
| 518 |
"replace", possibly unsafe characters in strings assigned to |
| 519 |
\fINAME\fR, |
| 520 |
\fISYMLINK\fR, and |
| 521 |
\fIENV{\fR\fI\fIkey\fR\fR\fI}\fR |
| 522 |
are replaced\&. When |
| 523 |
"none", no replacement is performed\&. When unset, the replacement is performed for |
| 524 |
\fINAME\fR, |
| 525 |
\fISYMLINK\fR, but not for |
| 526 |
\fIENV{\fR\fI\fIkey\fR\fR\fI}\fR\&. Defaults to unset\&. |
| 527 |
.RE |
| 528 |
.PP |
| 529 |
\fBstatic_node=\fR |
| 530 |
.RS 4 |
| 531 |
Apply the permissions specified in this rule to the static device node with the specified name\&. Also, for every tag specified in this rule, create a symlink in the directory |
| 532 |
/run/udev/static_node\-tags/\fItag\fR |
| 533 |
pointing at the static device node with the specified name\&. Static device node creation is performed by systemd\-tmpfiles before systemd\-udevd is started\&. The static nodes might not have a corresponding kernel device; they are used to trigger automatic kernel module loading when they are accessed\&. |
| 534 |
.RE |
| 535 |
.PP |
| 536 |
\fBwatch\fR |
| 537 |
.RS 4 |
| 538 |
Watch the device node with inotify; when the node is closed after being opened for writing, a change uevent is synthesized\&. |
| 539 |
.RE |
| 540 |
.PP |
| 541 |
\fBnowatch\fR |
| 542 |
.RS 4 |
| 543 |
Disable the watching of a device node with inotify\&. |
| 544 |
.RE |
| 545 |
.PP |
| 546 |
\fBdb_persist\fR |
| 547 |
.RS 4 |
| 548 |
Set the flag (sticky bit) on the udev database entry of the event device\&. Device properties are then kept in the database even when |
| 549 |
\fBudevadm info \-\-cleanup\-db\fR |
| 550 |
is called\&. This option can be useful in certain cases (e\&.g\&. Device Mapper devices) for persisting device state on the transition from initrd\&. |
| 551 |
.sp |
| 552 |
Added in version 241\&. |
| 553 |
.RE |
| 554 |
.PP |
| 555 |
\fBlog_level=\fR\fB\fIlevel\fR\fR |
| 556 |
.RS 4 |
| 557 |
Takes a log level name like |
| 558 |
"debug" |
| 559 |
or |
| 560 |
"info", or a special value |
| 561 |
"reset"\&. When a log level name is specified, the maximum log level is changed to that level\&. When |
| 562 |
"reset" |
| 563 |
is set, then the previously specified log level is revoked\&. Defaults to the log level of the main process of |
| 564 |
\fBsystemd\-udevd\fR\&. |
| 565 |
.sp |
| 566 |
This may be useful when debugging events for certain devices\&. Note that the log level is applied when the line including this rule is processed\&. So, for debugging, it is recommended that this is specified at earlier place, e\&.g\&., the first line of |
| 567 |
00\-debug\&.rules\&. |
| 568 |
.sp |
| 569 |
Example for debugging uevent processing for network interfaces: |
| 570 |
.sp |
| 571 |
.if n \{\ |
| 572 |
.RS 4 |
| 573 |
.\} |
| 574 |
.nf |
| 575 |
# /etc/udev/rules\&.d/00\-debug\-net\&.rules |
| 576 |
SUBSYSTEM=="net", OPTIONS="log_level=debug" |
| 577 |
.fi |
| 578 |
.if n \{\ |
| 579 |
.RE |
| 580 |
.\} |
| 581 |
.sp |
| 582 |
Added in version 248\&. |
| 583 |
.RE |
| 584 |
.PP |
| 585 |
\fBdump\fR |
| 586 |
.RS 4 |
| 587 |
Dump the status of the event currently processing\&. It may be useful for debugging udev rules by inserting this option\&. |
| 588 |
.sp |
| 589 |
Added in version 258\&. |
| 590 |
.RE |
| 591 |
.PP |
| 592 |
\fBdump\-json\fR |
| 593 |
.RS 4 |
| 594 |
Similar to |
| 595 |
\fBdump\fR, but dump the status of the event in JSON format\&. |
| 596 |
.sp |
| 597 |
Added in version 259\&. |
| 598 |
.RE |
| 599 |
.RE |
| 600 |
.PP |
| 601 |
The |
| 602 |
\fIENV\fR, |
| 603 |
\fIGROUP\fR, |
| 604 |
\fIMODE\fR, |
| 605 |
\fINAME\fR, |
| 606 |
\fIOWNER\fR, |
| 607 |
\fIPROGRAM\fR, |
| 608 |
\fIRUN\fR, |
| 609 |
\fISECLABEL\fR, and |
| 610 |
\fISYMLINK\fR |
| 611 |
fields support simple string substitutions\&. The |
| 612 |
\fIRUN\fR |
| 613 |
substitutions are performed after all rules have been processed, right before the program is executed, allowing for the use of device properties set by earlier matching rules\&. For all other fields, substitutions are performed while the individual rule is being processed\&. The available substitutions are: |
| 614 |
.PP |
| 615 |
\fB$kernel\fR, \fB%k\fR |
| 616 |
.RS 4 |
| 617 |
The kernel name for this device\&. |
| 618 |
.RE |
| 619 |
.PP |
| 620 |
\fB$number\fR, \fB%n\fR |
| 621 |
.RS 4 |
| 622 |
The kernel number for this device\&. For example, |
| 623 |
"sda3" |
| 624 |
has kernel number 3\&. |
| 625 |
.RE |
| 626 |
.PP |
| 627 |
\fB$devpath\fR, \fB%p\fR |
| 628 |
.RS 4 |
| 629 |
The devpath of the device\&. |
| 630 |
.RE |
| 631 |
.PP |
| 632 |
\fB$id\fR, \fB%b\fR |
| 633 |
.RS 4 |
| 634 |
The name of the device matched while searching the devpath upwards for |
| 635 |
\fBSUBSYSTEMS\fR, |
| 636 |
\fBKERNELS\fR, |
| 637 |
\fBDRIVERS\fR, and |
| 638 |
\fBATTRS\fR\&. |
| 639 |
.RE |
| 640 |
.PP |
| 641 |
\fB$driver\fR |
| 642 |
.RS 4 |
| 643 |
The driver name of the device matched while searching the devpath upwards for |
| 644 |
\fBSUBSYSTEMS\fR, |
| 645 |
\fBKERNELS\fR, |
| 646 |
\fBDRIVERS\fR, and |
| 647 |
\fBATTRS\fR\&. |
| 648 |
.RE |
| 649 |
.PP |
| 650 |
\fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR |
| 651 |
.RS 4 |
| 652 |
The value of a sysfs attribute found at the device where all keys of the rule have matched\&. If the matching device does not have such an attribute, and a previous |
| 653 |
\fBKERNELS\fR, |
| 654 |
\fBSUBSYSTEMS\fR, |
| 655 |
\fBDRIVERS\fR, or |
| 656 |
\fBATTRS\fR |
| 657 |
test selected a parent device, then the attribute from that parent device is used\&. |
| 658 |
.sp |
| 659 |
If the attribute is a symlink, the last element of the symlink target is returned as the value\&. |
| 660 |
.RE |
| 661 |
.PP |
| 662 |
\fB$env{\fR\fB\fIkey\fR\fR\fB}\fR, \fB%E{\fR\fB\fIkey\fR\fR\fB}\fR |
| 663 |
.RS 4 |
| 664 |
A device property value\&. |
| 665 |
.RE |
| 666 |
.PP |
| 667 |
\fB$major\fR, \fB%M\fR |
| 668 |
.RS 4 |
| 669 |
The kernel major number for the device\&. |
| 670 |
.RE |
| 671 |
.PP |
| 672 |
\fB$minor\fR, \fB%m\fR |
| 673 |
.RS 4 |
| 674 |
The kernel minor number for the device\&. |
| 675 |
.RE |
| 676 |
.PP |
| 677 |
\fB$result\fR, \fB%c\fR |
| 678 |
.RS 4 |
| 679 |
The string returned by the external program requested with |
| 680 |
\fIPROGRAM\fR\&. A single part of the string, separated by a space character, may be selected by specifying the part number as an attribute: |
| 681 |
"%c{N}"\&. If the number is followed by the |
| 682 |
"+" |
| 683 |
character, this part plus all remaining parts of the result string are substituted: |
| 684 |
"%c{N+}"\&. |
| 685 |
.RE |
| 686 |
.PP |
| 687 |
\fB$parent\fR, \fB%P\fR |
| 688 |
.RS 4 |
| 689 |
The node name of the parent device\&. |
| 690 |
.RE |
| 691 |
.PP |
| 692 |
\fB$name\fR |
| 693 |
.RS 4 |
| 694 |
The current name of the device\&. If not changed by a rule, it is the name of the kernel device\&. |
| 695 |
.RE |
| 696 |
.PP |
| 697 |
\fB$links\fR |
| 698 |
.RS 4 |
| 699 |
A space\-separated list of the current symlinks\&. The value is only set during a remove event or if an earlier rule assigned a value\&. |
| 700 |
.RE |
| 701 |
.PP |
| 702 |
\fB$root\fR, \fB%r\fR |
| 703 |
.RS 4 |
| 704 |
The udev_root value\&. |
| 705 |
.RE |
| 706 |
.PP |
| 707 |
\fB$sys\fR, \fB%S\fR |
| 708 |
.RS 4 |
| 709 |
The sysfs mount point\&. |
| 710 |
.RE |
| 711 |
.PP |
| 712 |
\fB$devnode\fR, \fB%N\fR |
| 713 |
.RS 4 |
| 714 |
The name of the device node\&. |
| 715 |
.RE |
| 716 |
.PP |
| 717 |
\fB%%\fR |
| 718 |
.RS 4 |
| 719 |
The |
| 720 |
"%" |
| 721 |
character itself\&. |
| 722 |
.RE |
| 723 |
.PP |
| 724 |
\fB$$\fR |
| 725 |
.RS 4 |
| 726 |
The |
| 727 |
"$" |
| 728 |
character itself\&. |
| 729 |
.RE |
| 730 |
.SH "SEE ALSO" |
| 731 |
.PP |
| 732 |
\fBsystemd-udevd.service\fR(8), \fBudevadm\fR(8), \fBsystemd.link\fR(5) |
| 733 |
.SH "NOTES" |
| 734 |
.IP " 1." 4 |
| 735 |
Escape sequences in C |
| 736 |
.RS 4 |
| 737 |
\%https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences |
| 738 |
.RE |