LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-26-2005, 02:19 PM   #1
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Rep: Reputation: 30
udev rules for sandisk 8 in 1 card reader, can't distinguish


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
 
Old 12-26-2005, 02:20 PM   #2
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Original Poster
Rep: Reputation: 30
also, i've noticed the different ports have different LUN's, maybe I can distinguish ports by that?

Code:
monster hedpe # dmesg | grep sdc
Attached scsi removable disk sdc at scsi2, channel 0, id 0, lun 0
monster hedpe # dmesg | grep sdd
Attached scsi removable disk sdd at scsi2, channel 0, id 0, lun 1
monster hedpe # dmesg | grep sde
Attached scsi removable disk sde at scsi2, channel 0, id 0, lun 2
monster hedpe # dmesg | grep sdf
Attached scsi removable disk sdf at scsi2, channel 0, id 0, lun 3
 
Old 12-28-2005, 01:26 PM   #3
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Original Poster
Rep: Reputation: 30
bump please
 
Old 12-28-2005, 06:18 PM   #4
ttrainor
LQ Newbie
 
Registered: Dec 2005
Distribution: FC4 2.6.14
Posts: 3

Rep: Reputation: 0
In your udev rules, use the %e substitution to get a unique number for your SYMLINK:

BUS="usb", SYSFS{serial}="0300092566", NAME="%k", SYMLINK="sd_card%e"

I think that might be what you're looking for.
 
Old 12-30-2005, 03:38 AM   #5
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Original Poster
Rep: Reputation: 30
will that %e always be the same for the different ports?

I will try this and get back to you, thank you!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors with FC3 & SanDisk Model SDDR-103 Mobile Card Reader / Writer sgl Linux - Hardware 0 06-17-2005 07:46 AM
Sandisk USB card Reader not linking /dev/sg0 to /dev/sda acidraven Linux - Hardware 1 06-19-2004 03:56 PM
sandisk compact flash card reader and filesystem type esteeven Linux - Hardware 6 05-13-2004 02:51 PM
can't mount my sandisk card reader kamstrup Linux - Hardware 17 08-20-2003 02:39 PM
USB Sandisk card reader griv Linux - General 1 06-04-2002 02:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration