Datasheet

“main” (Installation and Administration) 2004/6/25 13:29 page 325 #351
i
i
i
i
i
i
i
i
15
Dynamic Device Nodes with udev
In this example, there are two keys, BUS and SYSFS{serial}. udev com-
pares the serial number to the serial number of the device that is connected
to the USB bus. To assign the name lp_hp to the device in the /dev direc-
tory, all the keys must agree. In addition, a symbolic /dev/printers/hp,
which refers to the device node, is created. During this operation, the
printers directory is automatically created. Print jobs can then be sent
to /dev/printers/hp or /dev/lp_hp.
15.2 Automization with NAME and
SYMLINK
The parameters NAME and SYMLINK allow the use of operators for auto-
matic assignments. These operators refer to kernel data on the correspond-
ing device. A simple example illustrates the procedure:
BUS="usb", SYSFS{vendor}="abc", SYSFS{model}="xyz", NAME="camera%n"
The operator %n in the name is replaced by the number of the camera
device: for example, camera0, camera1. Another useful operator is %k,
which is replaced by the standard device name of the kernel, for example,
hda1. Find a list of all the operators in the man page for udev.
15.3 Regular Expressions in Keys
Regular expressions, such as wild cards, can be used in the shell. For exam-
ple, the character * can be used as a placeholder for any characters or ? can
be used for precisely one character.
KERNEL="ts*", NAME="input/%k"
This rule assigns the standard kernel name in the standard directory to a
device whose designation begins with the letters "ts". Detailed information
about the use of regular expressions in udev rules can be found in the man
page man udev.
325SUSE LINUX Enterprise Server