Re: Does sysfs really provides persistent hardware path to devices?

From: Olaf Hering
Date: Mon Jan 19 2004 - 08:09:19 EST


On Sat, Jan 17, Andrey Borzenkov wrote:

> > > Well, we did not move a tiny bit since the beginning of this thread :)
> > > You still did not show me namedev configuration that implements
> > > persistent name for a device based on its physical location :)))
> >
> > Ok, do you have any other ideas of how to do this?
> >
>
> given current sysfs implementation - using wildcards remains the only
> solution. I for now am using this trivial script:
>
> pts/0}% cat /etc/udev/scripts/removables
> #!/usr/bin/perl
>
> my $devpath, $base;
>
> $base = $1 if ($ARGV[0] =~ /(.*\D)\d*$/);
> $devpath = readlink "/sys/block/$base/device";
>
> if ($devpath =~
> m|/devices/pci0000:00/0000:00:1f.4/usb2/2-2/2-2.4/2-2.4:1.0/host\d+/\d+:0:0:0|)
> {
> print "flash0";
> } elsif ($devpath =~
> m|/devices/pci0000:00/0000:00:1f.4/usb2/2-2/2-2.1/2-2.1:1.0/host\d+/\d+:0:0:0|)
> {
> print "flash1";
> } elsif ($devpath =~ m|/devices/legacy/host\d+/\d+:0:4:0|) {
> print "jaz";
> } else {
> exit(1);
> }

I'm not sure what you are trying to do. Working with the 'physical
location' of removeable devices will probably fail. The usb-storage
devices here have a serial field, I really hope it is unique, use it.

--
USB is for mice, FireWire is for men!

sUse lINUX ag, nÃRNBERG
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/