Influencing Kernel Device Event Handling With Udev Rules - Novell LINUX ENTERPRISE SERVER 11 - ADMINISTRATION Administration Manual

Hide thumbs Also See for LINUX ENTERPRISE SERVER 11 - ADMINISTRATION:
Table of Contents

Advertisement

11.6 Influencing Kernel Device Event
Handling with udev Rules
A udev rule can match any property the kernel adds to the event itself or any information
that the kernel exports to sysfs. The rule can also request additional information from
external programs. Every event is matched against all provided rules. All rules are lo-
cated in the /etc/udev/rules.d directory.
Every line in the rules file contains at least one key value pair. There are two kinds of
keys, match and assignment keys. If all match keys match their values, the rule is applied
and the assignment keys are assigned the specified value. A matching rule may specify
the name of the device node, add symlinks pointing to the node or run a specified pro-
gram as part of the event handling. If no matching rule is found, the default device node
name is used to create the device node. Detailed information about the rule syntax and
the provided keys to match or import data are described in the udev man page. The
following example rules provide a basic introduction to udev rule syntax. The example
rules are all taken from the udev default rule set that is located under /etc/udev/
rules.d/50-udev-default.rules.
Example 11.1 Example udev Rules
# console
KERNEL=="console", MODE="0600", OPTIONS="last_rule"
# serial devices
KERNEL=="ttyUSB*", ATTRS{product}=="[Pp]alm*Handheld*", SYMLINK+="pilot"
# printer
SUBSYSTEM=="usb", KERNEL=="lp*", NAME="usb/%k", SYMLINK+="usb%k", GROUP="lp"
# kernel firmware loader
SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware.sh"
The console rule consists of three keys: one match key (KERNEL) and two assign
keys (MODE, OPTIONS). The KERNEL match rule searches the device list for any items
of the type console. Only exact matches are valid and trigger this rule to be executed.
The MODE key assigns special permissions to the device node, in this case, read and
write permissions to the owner of this device only. The OPTIONS key makes this rule
the last rule to be applied to any device of this type. Any later rule matching this partic-
ular device type does not have any effect.
Dynamic Kernel Device Management with udev
135

Advertisement

Table of Contents
loading

This manual is also suitable for:

Suse linux enterprise server 11

Table of Contents