On Wed, May 5, 2010 at 07:23, Yan Zhang <yanzhang012@xxxxxxxxx> wrote: > Dear Madam/Sir. > > I am writing to seek help from you over a rule. This is my rule > > IMPORT{program}="/bin/echo iii=0" > > KERNEL=="sdb", SUBSYSTEM=="block", IMPORT{program}="/sbin/scsi_id -g -u -x -a -s %p -d $tempnode", ENV{ID_SERIAL}=="360a980006e424539576f57487a4b6232", NAME="sdz$ENV{iii}", ENV{iii}="1" > KERNEL=="sdc", SUBSYSTEM=="block", IMPORT{program}="/sbin/scsi_id -g -u -x -a -s %p -d $tempnode", ENV{ID_SERIAL}=="360a980006e424539576f57487a4b6232", NAME="sdz$ENV{iii}", ENV{iii}="2" > KERNEL=="sdd", SUBSYSTEM=="block", IMPORT{program}="/sbin/scsi_id -g -u -x -a -s %p -d $tempnode", ENV{ID_SERIAL}=="360a980006e424539576f57487a4b6232", NAME="sdz$ENV{iii}", ENV{iii}="3" > KERNEL=="sde", SUBSYSTEM=="block", IMPORT{program}="/sbin/scsi_id -g -u -x -a -s %p -d $tempnode", ENV{ID_SERIAL}=="360a980006e424539576f57487a4b6232", NAME="sdz$ENV{iii}", ENV{iii}="4" > > It is working and I can get /dev/sdz0, /dev/sdz1, /dev/sdz2, and /dev/sdz3. But, could you tell me how to let rule increasing ENV{iii} automatically? Here I have to set ENV{iii}="1", ENV{iii}="2", ENV{iii}="3", and ENV{iii}="4" manually. > > By any change, could you tell me a single line rule, just like the following format, to realize my rule's function? > > KERNEL=="sd*", SUBSYSTEM=="block", IMPORT{program}="/sbin/scsi_id -g -u > -x -a -s %p -d $tempnode", > ENV{ID_SERIAL}=="360a980006e424539576f57487a4b6232", > NAME="sdz <automatically increase number by 1>" You can't to any simple enumeration in udev. Udev does not provide this for the simple reason, that it is unpredictable and can never work as expected. Events run in parallel without any defined order, there can be no counter to increase. There is no global environment where these variables would be visible from multiple events, all events run independent, if you set something in one event the others will not see it. All this should be already solved with the standard symlinks in /dev/disk. Please just use the by-id/ links there, they are reliably created and contain unique strings to identify devices. Also don't call scsi_id again, udev already did that as part of the standard device identification. And the primary node names must never be changed, the names will no longer match the kernel log, sysfs, /proc/partitions, ... Future udev versions will not even allow you to rename kernel-supplied primary device nodes with NAME=, so please don't do this. Thanks, Kay -- To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html