[PATCH] udev - switch callout part selector to {attribute}

Here we change the magic callout part number selector to the new
atribute syntax. The syntax to select the second part of the callout string:

 '%2c' is now '%c{2}'

I think it's more clear and we no longer misuse the length argument.

The old syntax is still supported, but we should remove it some
time in the future.
This commit is contained in:
kay.sievers@vrfy.org 2004-02-17 01:29:03 -08:00 committed by Greg KH
parent 16378373cb
commit 88f09368b3
6 changed files with 13 additions and 18 deletions

View File

@ -2,7 +2,7 @@
# fields. See the udev man page for a full description of them. # fields. See the udev man page for a full description of them.
# ide block devices # ide block devices
BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c" BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
# md block devices # md block devices
KERNEL="md[0-9]*", NAME="md/%n" KERNEL="md[0-9]*", NAME="md/%n"

View File

@ -57,7 +57,7 @@ KERNEL="ttyUSB0", NAME="pl2303"
# devfs-names for ide-devices (uncomment only one) # devfs-names for ide-devices (uncomment only one)
# /dev/ide/.../{disc,cd} and /dev/{cdroms,discs}/* type names # /dev/ide/.../{disc,cd} and /dev/{cdroms,discs}/* type names
BUS="ide", PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%1c", SYMLINK="%2c %3c" BUS="ide", PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%c{1}", SYMLINK="%c{2} %c{3}"
# fb devices # fb devices
KERNEL="fb[0-9]*", NAME="fb/%n", SYMLINK="%k" KERNEL="fb[0-9]*", NAME="fb/%n", SYMLINK="%k"

View File

@ -2,7 +2,7 @@
# udev external PROGRAM script # udev external PROGRAM script
# return devfs-names for ide-devices # return devfs-names for ide-devices
# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c" # BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
HOST="${2%\.[0-9]}" HOST="${2%\.[0-9]}"
TARGET="${2#[0-9]\.}" TARGET="${2#[0-9]\.}"

View File

@ -2,7 +2,7 @@
# a horribly funny script that shows how flexible udev can really be # a horribly funny script that shows how flexible udev can really be
# This is to be executed by udev with the following rules: # This is to be executed by udev with the following rules:
# KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%1c", SYMLINK="cdrom" # KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%c{1}", SYMLINK="cdrom"
use strict; use strict;
use warnings; use warnings;

View File

@ -219,6 +219,7 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys
char *pos3; char *pos3;
char *attr; char *attr;
int num; int num;
int i;
char c; char c;
struct sysfs_attribute *tmpattr; struct sysfs_attribute *tmpattr;
@ -270,11 +271,15 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys
case 'c': case 'c':
if (strlen(udev->program_result) == 0) if (strlen(udev->program_result) == 0)
break; break;
if (num > 0) { /* get part part of the result string */
i = num; /* num syntax is deprecated and will be removed */
if (attr != NULL)
i = atoi(attr);
if (i > 0) {
strncpy(temp1, udev->program_result, sizeof(temp1)); strncpy(temp1, udev->program_result, sizeof(temp1));
pos2 = temp1; pos2 = temp1;
while (num) { while (i) {
num--; i--;
pos3 = strsep(&pos2, " "); pos3 = strsep(&pos2, " ");
if (pos3 == NULL) { if (pos3 == NULL) {
dbg("requested part of result string not found"); dbg("requested part of result string not found");

View File

@ -191,16 +191,6 @@ EOF
expected => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , expected => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" ,
conf => <<EOF conf => <<EOF
BUS="scsi", PLACE="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b" BUS="scsi", PLACE="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b"
EOF
},
{
desc => "select sysfs attribute by SYSFS{vendor}",
subsys => "block",
devpath => "block/sda",
expected => "disk-IBM-ESXS-sda" ,
conf => <<EOF
BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="disk-%s{vendor}-%k"
KERNEL="ttyUSB0", NAME="visor"
EOF EOF
}, },
{ {
@ -250,7 +240,7 @@ EOF
devpath => "block/sda/sda3", devpath => "block/sda/sda3",
expected => "link1" , expected => "link1" ,
conf => <<EOF conf => <<EOF
BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", RESULT="node *", NAME="%1c", SYMLINK="%2c %3c" BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", RESULT="node *", NAME="%c{1}", SYMLINK="%c{2} %c{3}"
EOF EOF
}, },
{ {