Hi,
I am trying to create udev rules for my Sandisk 8 in 1 card reader. If i put in a card, it successfully detects the card and assigns it a block, such as /dev/sdc1 or /dev/sdf1
For instance the reader has 4 slots. SD, MS, CF, and SM
Right now as an example, i put a card in the MS slot, and got:
Code:
SCSI device sdf: 63424 512-byte hdwr sectors (32 MB)
sdf: Write Protect is off
sdf: Mode Sense: 02 00 00 00
sdf: assuming drive cache: write through
SCSI device sdf: 63424 512-byte hdwr sectors (32 MB)
sdf: Write Protect is off
sdf: Mode Sense: 02 00 00 00
sdf: assuming drive cache: write through
sdf: sdf1
I then put a card in the CF slot and got:
Code:
SCSI device sdc: 2014992 512-byte hdwr sectors (1032 MB)
sdc: Write Protect is off
sdc: Mode Sense: 02 00 00 00
sdc: assuming drive cache: write through
SCSI device sdc: 2014992 512-byte hdwr sectors (1032 MB)
sdc: Write Protect is off
sdc: Mode Sense: 02 00 00 00
sdc: assuming drive cache: write through
sdc: sdc1
Great, one is at /dev/sdf1 and the other at /dev/sdc1
However, with udev I would like to create a symlink for the SD slot to /dev/sd_card, and /dev/cf_card for the CF slot
I am having a hard time doing this though because it seems as though the same serial numbers are used:
Code:
monster hedpe # udevinfo -a -p `udevinfo -q path -n /dev/sdc1` | grep serial
SYSFS{serial}=="0300092566"
SYSFS{serial}=="0000:00:1d.7"
monster hedpe # udevinfo -a -p `udevinfo -q path -n /dev/sdf1` | grep serial
SYSFS{serial}=="0300092566"
SYSFS{serial}=="0000:00:1d.7"
In my udev rules I have:
Code:
BUS="usb", SYSFS{serial}="0300092566", NAME="%k", SYMLINK="sd_card"
That works great if I only plugin one card at a time, no matter which slot I plug it into, it always creates a symlink to sd_card. The problem is that I cannot have two cards in at the same time or else it tries to create the symlink twice, which is fine, but then my IVMAN mounts it twice
I guess what I am looking for help is if I can distinguish these ports with udev in any way to create different symlinks for the different ports.
Here are my full device chains incase they help:
Code:
sh-3.00# udevinfo -a -p /sys/block/sdc
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/sdc' has major:minor 8:32
looking at class device '/sys/block/sdc':
KERNEL=="sdc"
SUBSYSTEM=="block"
SYSFS{dev}=="8:32"
SYSFS{range}=="16"
SYSFS{removable}=="1"
SYSFS{size}=="0"
SYSFS{stat}==" 54 294 586 116 0 0 0 0 0 100 116"
follow the "device"-link to the physical device:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2/target2:0:0/2:0:0:0':
BUS=="scsi"
ID=="2:0:0:0"
DRIVER=="sd"
SYSFS{device_blocked}=="0"
SYSFS{iocounterbits}=="32"
SYSFS{iodone_cnt}=="0x7d1"
SYSFS{ioerr_cnt}=="0x653"
SYSFS{iorequest_cnt}=="0x7d1"
SYSFS{max_sectors}=="240"
SYSFS{model}=="STORAGE DEVICE "
SYSFS{queue_depth}=="1"
SYSFS{queue_type}=="none"
SYSFS{rev}=="0001"
SYSFS{scsi_level}=="3"
SYSFS{state}=="running"
SYSFS{timeout}=="30"
SYSFS{type}=="0"
SYSFS{vendor}=="Generic "
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2/target2:0:0':
BUS==""
ID=="target2:0:0"
DRIVER=="unknown"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2':
BUS==""
ID=="host2"
DRIVER=="unknown"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0':
BUS=="usb"
ID=="1-1:1.0"
DRIVER=="usb-storage"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceClass}=="08"
SYSFS{bInterfaceNumber}=="00"
SYSFS{bInterfaceProtocol}=="50"
SYSFS{bInterfaceSubClass}=="06"
SYSFS{bNumEndpoints}=="02"
SYSFS{modalias}=="usb:v0781p8989d0001dc00dsc00dp00ic08isc06ip50"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1':
BUS=="usb"
ID=="1-1"
DRIVER=="usb"
SYSFS{bConfigurationValue}=="1"
SYSFS{bDeviceClass}=="00"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bMaxPower}=="500mA"
SYSFS{bNumConfigurations}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bcdDevice}=="0001"
SYSFS{bmAttributes}=="80"
SYSFS{configuration}==""
SYSFS{devnum}=="2"
SYSFS{idProduct}=="8989"
SYSFS{idVendor}=="0781"
SYSFS{manufacturer}=="SanDisk "
SYSFS{maxchild}=="0"
SYSFS{product}=="ImageMate 12 in 1 Reader/Writer "
SYSFS{serial}=="0300092566"
SYSFS{speed}=="480"
SYSFS{version}==" 2.00"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1':
BUS=="usb"
ID=="usb1"
DRIVER=="usb"
SYSFS{bConfigurationValue}=="1"
SYSFS{bDeviceClass}=="09"
SYSFS{bDeviceProtocol}=="01"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bMaxPacketSize0}=="8"
SYSFS{bMaxPower}==" 0mA"
SYSFS{bNumConfigurations}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bcdDevice}=="0206"
SYSFS{bmAttributes}=="e0"
SYSFS{configuration}==""
SYSFS{devnum}=="1"
SYSFS{idProduct}=="0000"
SYSFS{idVendor}=="0000"
SYSFS{manufacturer}=="Linux 2.6.14-gentoo-r5 ehci_hcd"
SYSFS{maxchild}=="8"
SYSFS{product}=="EHCI Host Controller"
SYSFS{serial}=="0000:00:1d.7"
SYSFS{speed}=="480"
SYSFS{version}==" 2.00"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7':
BUS=="pci"
ID=="0000:00:1d.7"
DRIVER=="ehci_hcd"
SYSFS{class}=="0x0c0320"
SYSFS{device}=="0x24dd"
SYSFS{irq}=="17"
SYSFS{local_cpus}=="ff"
SYSFS{modalias}=="pci:v00008086d000024DDsv0000147Bsd00001021bc0Csc03i20"
SYSFS{subsystem_device}=="0x1021"
SYSFS{subsystem_vendor}=="0x147b"
SYSFS{vendor}=="0x8086"
looking at the device chain at '/sys/devices/pci0000:00':
BUS==""
ID=="pci0000:00"
DRIVER=="unknown"
Code:
sh-3.00# udevinfo -a -p /sys/block/sdf
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/sdf' has major:minor 8:80
looking at class device '/sys/block/sdf':
KERNEL=="sdf"
SUBSYSTEM=="block"
SYSFS{dev}=="8:80"
SYSFS{range}=="16"
SYSFS{removable}=="1"
SYSFS{size}=="0"
SYSFS{stat}==" 295 17695 18704 9752 1 0 1 120 0 4420 9872"
follow the "device"-link to the physical device:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2/target2:0:0/2:0:0:3':
BUS=="scsi"
ID=="2:0:0:3"
DRIVER=="sd"
SYSFS{device_blocked}=="0"
SYSFS{iocounterbits}=="32"
SYSFS{iodone_cnt}=="0x84d"
SYSFS{ioerr_cnt}=="0x512"
SYSFS{iorequest_cnt}=="0x84d"
SYSFS{max_sectors}=="240"
SYSFS{model}=="STORAGE DEVICE "
SYSFS{queue_depth}=="1"
SYSFS{queue_type}=="none"
SYSFS{rev}=="0001"
SYSFS{scsi_level}=="3"
SYSFS{state}=="running"
SYSFS{timeout}=="30"
SYSFS{type}=="0"
SYSFS{vendor}=="Generic "
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2/target2:0:0':
BUS==""
ID=="target2:0:0"
DRIVER=="unknown"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host2':
BUS==""
ID=="host2"
DRIVER=="unknown"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0':
BUS=="usb"
ID=="1-1:1.0"
DRIVER=="usb-storage"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceClass}=="08"
SYSFS{bInterfaceNumber}=="00"
SYSFS{bInterfaceProtocol}=="50"
SYSFS{bInterfaceSubClass}=="06"
SYSFS{bNumEndpoints}=="02"
SYSFS{modalias}=="usb:v0781p8989d0001dc00dsc00dp00ic08isc06ip50"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1':
BUS=="usb"
ID=="1-1"
DRIVER=="usb"
SYSFS{bConfigurationValue}=="1"
SYSFS{bDeviceClass}=="00"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bMaxPower}=="500mA"
SYSFS{bNumConfigurations}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bcdDevice}=="0001"
SYSFS{bmAttributes}=="80"
SYSFS{configuration}==""
SYSFS{devnum}=="2"
SYSFS{idProduct}=="8989"
SYSFS{idVendor}=="0781"
SYSFS{manufacturer}=="SanDisk "
SYSFS{maxchild}=="0"
SYSFS{product}=="ImageMate 12 in 1 Reader/Writer "
SYSFS{serial}=="0300092566"
SYSFS{speed}=="480"
SYSFS{version}==" 2.00"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1':
BUS=="usb"
ID=="usb1"
DRIVER=="usb"
SYSFS{bConfigurationValue}=="1"
SYSFS{bDeviceClass}=="09"
SYSFS{bDeviceProtocol}=="01"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bMaxPacketSize0}=="8"
SYSFS{bMaxPower}==" 0mA"
SYSFS{bNumConfigurations}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{bcdDevice}=="0206"
SYSFS{bmAttributes}=="e0"
SYSFS{configuration}==""
SYSFS{devnum}=="1"
SYSFS{idProduct}=="0000"
SYSFS{idVendor}=="0000"
SYSFS{manufacturer}=="Linux 2.6.14-gentoo-r5 ehci_hcd"
SYSFS{maxchild}=="8"
SYSFS{product}=="EHCI Host Controller"
SYSFS{serial}=="0000:00:1d.7"
SYSFS{speed}=="480"
SYSFS{version}==" 2.00"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7':
BUS=="pci"
ID=="0000:00:1d.7"
DRIVER=="ehci_hcd"
SYSFS{class}=="0x0c0320"
SYSFS{device}=="0x24dd"
SYSFS{irq}=="17"
SYSFS{local_cpus}=="ff"
SYSFS{modalias}=="pci:v00008086d000024DDsv0000147Bsd00001021bc0Csc03i20"
SYSFS{subsystem_device}=="0x1021"
SYSFS{subsystem_vendor}=="0x147b"
SYSFS{vendor}=="0x8086"
looking at the device chain at '/sys/devices/pci0000:00':
BUS==""
ID=="pci0000:00"
DRIVER=="unknown"
Thanks!!
George