[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: help: udev rule for usb stick



Alle 05:47, giovedì 20 ottobre 2005, Jules Dubois ha scritto:
> On Wednesday 19 October 2005 17:56, Matteo Semplice
> <matteo.semplice@libero.it>
>
> (<[🔎] 200510200156.16431.matteo.semplice@libero.it>) wrote:
> > Hi everybody,
> >  is anyone willing to suggest an udev rule to SYMLINK my usb stick to
> > something like "/dev/usbpen"? I know that the web is full of suggestions
> > on how to do it, but I can't get it to work for me!
> >
> > When I plug it in, it gets recognized by the scsi emulation and assigned
> > to /dev/sda, but I've been trying in vane to write an udev rule to catch
> > this device and symlink it to something else.
>
> A simple rule, which will fail if the pen ever gets a name other
> than /dev/sda, is
>
>   KERNEL=="sda" SYMLINK="usbpen"

Thanks for your reply (and all the others, which kindly pointed out docs on 
the web that sadly already sit on my machine but had already given no help)

This of course works, but it's no good for me, since I sometimes mount a SCSI 
hard disk as well...

> What does
>
>   udevinfo -a -p $(udevinfo -q path -n /dev/sda)
>
> say?
udevinfo -a -p $(udevinfo -q path -n /dev/sda)

udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.

device '/sys/block/sda' has major:minor 8:0
  looking at class device '/sys/block/sda':
    SUBSYSTEM="block"
    SYSFS{dev}="8:0"
    SYSFS{range}="16"
    SYSFS{removable}="1"
    SYSFS{size}="1019617"
    SYSFS{stat}="       6      234      240      203        0        0        
0        0        0      133      203"

follow the class device's "device"
  looking at the device chain at 
'/sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host3/target3:0:0/3:0:0:0':
    BUS="scsi"
    ID="3:0:0:0"
    DRIVER="sd"
    SYSFS{device_blocked}="0"
    SYSFS{iocounterbits}="32"
    SYSFS{iodone_cnt}="0x2e"
    SYSFS{ioerr_cnt}="0x0"
    SYSFS{iorequest_cnt}="0x2e"
    SYSFS{max_sectors}="240"
    SYSFS{model}=".2"
    SYSFS{queue_depth}="1"
    SYSFS{queue_type}="none"
    SYSFS{rev}=""
    SYSFS{scsi_level}="3"
    SYSFS{state}="running"
    SYSFS{timeout}="30"
    SYSFS{type}="0"
    SYSFS{vendor}="linux.so"

Currently, none of the rules
BUS="usb",SYSFS{modalias}="usb:v10D6p1100d0100dc00dsc00dp00ic08isc05ip50",SYMLINK="usbstick"
BUS="scsi",SYSFS{modalias}="usb:v10D6p1100d0100dc00dsc00dp00ic08isc05ip50",SYMLINK="usbstick"
BUS="usb", SYSFS{idVendor}="10d6", SYMLINK="usbstick"
BUS="scsi", SYSFS{idVendor}="10d6", SYMLINK="usbstick"
BUS="usb", SYSFS{idProduct}="1100", SYMLINK="usbstick"
BUS="scsi", SYSFS{idProduct}="1100", SYMLINK="usbstick"
seem to work. (I've put them in /etc/udev/rules.d/010local.rules)

Again, the right info on my usb pen are found 
in  /sys/bus/usb/devices/2-2/idVendor, etc but sda seems to refer to the usb 
device 2-2/2-2:1-0

$ ls  /sys/block/sda/ -l
totale 0
-r--r--r--  1 root root 4096 2005-10-20 19:29 dev
lrwxrwxrwx  1 root root    0 2005-10-20 19:29 device 
-> ../../devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host4/target4:0:0/4:0:0:0
drwxr-xr-x  3 root root    0 2005-10-20 19:29 queue
-r--r--r--  1 root root 4096 2005-10-20 19:29 range
-r--r--r--  1 root root 4096 2005-10-20 19:29 removable
-r--r--r--  1 root root 4096 2005-10-20 19:29 size
-r--r--r--  1 root root 4096 2005-10-20 19:29 stat

Isn't this odd?

Matteo



Reply to: