On Thu, Nov 29, 2012 at 10:35 PM, Walter Dnes <waltd...@waltdnes.org> wrote: > On Thu, Nov 29, 2012 at 07:31:10PM +0000, Jorge Almeida wrote > > > I have a couple of scripts that automount USB devices under mdev. See > https://wiki.gentoo.org/wiki/Mdev for the general setup, and > https://wiki.gentoo.org/wiki/Mdev/Automount_USB and > https://wiki.gentoo.org/wiki/Mdev/Automount_USB/automount >
I don't care for automounting, I just want customized symlinks. Using fstab is not a second choice, it is how I want it. > > The output below shows that not every USB device has a serial number, > and the "Patriot Memory" key has a serial number but no manufacturer... > > [d531][waltdnes][~] find /sys/devices/pci0* -name serial | xargs cat > OK. I found that my pens have serial numbers. I setup /proc/sys/kernel/hotplug with a script that prints the environment. When a pen is inserted, this is what is set: ACTION=add DEVPATH=/devices/pci0000:00/0000:00:04.1/usb1/1-4/1-4:1.0/host12/target12:0:0/12:0:0:0/block/sdd SUBSYSTEM=block MAJOR=8 MINOR=48 DEVNAME=sdd DEVTYPE=disk SEQNUM=1750 Following your suggestion: # find /sys/devices/pci0* -name serial /sys/devices/pci0000:00/0000:00:04.0/usb5/serial /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/serial /sys/devices/pci0000:00/0000:00:04.1/usb1/serial /sys/devices/pci0000:00/0000:00:06.0/usb6/serial /sys/devices/pci0000:00/0000:00:06.1/usb3/3-4/serial /sys/devices/pci0000:00/0000:00:06.1/usb3/serial /sys/devices/pci0000:00/0000:00:0c.0/0000:02:00.0/0000:03:01.0/0000:04:00.0/usb2/serial /sys/devices/pci0000:00/0000:00:0c.0/0000:02:00.0/0000:03:01.0/0000:04:00.0/usb4/serial # cat /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/serial AA04012700011287 So, the serial number is here. To retrieve it out of $DEVPATH, I can do (in this case, at least!): # cat /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/1-4:1.0/host12/target12:0:0/12:0:0:0/block/sdd/../../../../../../serial AA04012700011287 I'm assuming that this scenario is consistent for usb pen drives. I'll think of external hard disks next... BTW, the idea behind this is: -- have s6-devd listen to the netlink interface (http://www.skarnet.org/software/s6-linux-utils/s6-devd.html) -- when a device is inserted, s6-devd launches a program that tries to obtain the serial number, uses it as key to seek a string some_name in a constant database, and creates the symlink /dev/some_name --> $DEVNAME. On failure, exec mdev with the environment passed by the kernel. I'm supposing that the environment on netlink is the same as with the hotplug mechanism. Would this be true? I would be interested in hearing any comments... Thanks Joreg Almeida > > -- > Walter Dnes <waltd...@waltdnes.org> > We are apparently better off trying to avoid udev like the plague. Precisely. > Linus Torvalds; 2012/10/03 https://lkml.org/lkml/2012/10/3/349 >