diff options
-rw-r--r-- | etc/udev/udev.rules.devfs | 2 | ||||
-rw-r--r-- | etc/udev/udev.rules.gentoo | 2 | ||||
-rw-r--r-- | extras/ide-devfs.sh | 2 | ||||
-rw-r--r-- | extras/name_cdrom.pl | 2 | ||||
-rw-r--r-- | namedev.c | 11 | ||||
-rw-r--r-- | test/udev-test.pl | 12 |
6 files changed, 13 insertions, 18 deletions
diff --git a/etc/udev/udev.rules.devfs b/etc/udev/udev.rules.devfs index f9333e91c4..77d3cf5414 100644 --- a/etc/udev/udev.rules.devfs +++ b/etc/udev/udev.rules.devfs @@ -2,7 +2,7 @@ # fields. See the udev man page for a full description of them. # 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 KERNEL="md[0-9]*", NAME="md/%n" diff --git a/etc/udev/udev.rules.gentoo b/etc/udev/udev.rules.gentoo index b3ca042224..7e8966961d 100644 --- a/etc/udev/udev.rules.gentoo +++ b/etc/udev/udev.rules.gentoo @@ -57,7 +57,7 @@ KERNEL="ttyUSB0", NAME="pl2303" # devfs-names for ide-devices (uncomment only one) # /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 KERNEL="fb[0-9]*", NAME="fb/%n", SYMLINK="%k" diff --git a/extras/ide-devfs.sh b/extras/ide-devfs.sh index 1cf6f9c9e4..0a9369dff4 100644 --- a/extras/ide-devfs.sh +++ b/extras/ide-devfs.sh @@ -2,7 +2,7 @@ # udev external PROGRAM script # 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]}" TARGET="${2#[0-9]\.}" diff --git a/extras/name_cdrom.pl b/extras/name_cdrom.pl index 3a4772e6d9..766f6f366a 100644 --- a/extras/name_cdrom.pl +++ b/extras/name_cdrom.pl @@ -2,7 +2,7 @@ # a horribly funny script that shows how flexible udev can really be # 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 warnings; @@ -219,6 +219,7 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys char *pos3; char *attr; int num; + int i; char c; struct sysfs_attribute *tmpattr; @@ -270,11 +271,15 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys case 'c': if (strlen(udev->program_result) == 0) 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)); pos2 = temp1; - while (num) { - num--; + while (i) { + i--; pos3 = strsep(&pos2, " "); if (pos3 == NULL) { dbg("requested part of result string not found"); diff --git a/test/udev-test.pl b/test/udev-test.pl index e238c909fa..6e031c4c2c 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -194,16 +194,6 @@ 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 - }, - { desc => "sustitution of sysfs value (%s{file})", subsys => "block", devpath => "block/sda", @@ -250,7 +240,7 @@ EOF devpath => "block/sda/sda3", expected => "link1" , 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 }, { |