String Substitutions

The following table describes the string substitutions that are commonly used with the GROUP, MODE, NAME, OWNER, PROGRAM, RUN, and SYMLINK keys.

String Substitution Description

$attr{file} or

%s{file}

Specifies the value of a device attribute from a file under /sys, such as ENV{MATCHADDR}="$attr{address}".

$devpath or

%p

The device path of the device in the sysfs file system under /sys, such as RUN+="keyboard-force-release.sh $devpath common-volume-keys".

$env{key} or

%E{key}

Specifies the value of a device property, such as SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n".

$kernel or

%k

Specifies the kernel name for the device.

$major or

%M

Specifies the major number of a device, such as IMPORT{program}="udisks-dm-export %M %m".

$minor or

%m

Specifies the minor number of a device, such as RUN+="$env{LVM_SBIN_PATH}/lvm pvscan --cache --major $major --minor $minor".

$name

Specifies the device file of the current device, such as TEST=="/lib/udev/devices/$name".

udev expands the strings specified for RUN immediately before its program is run, which is after udev has finished processing all other rules for the device. For the other keys, udev expands the strings while it's processing the rules.