KERNELS=="usb*", SUBSYSTEMS=="usb", DRIVERS=="usb",
SYMLINK="usbdevices/%k"
SUBSYSTEMS=="scsi", DRIVERS=="sd", SYMLINK="carddevices/%k"
I have two cardreaders, the first one is internally 4 distinct
cardreaders, so the solts can be identified. The "model" attribute can
be queried to find out the slot. The following rules automagically
create symlinks from /dev/cardreader/cf, /dev/cardreader/cf1 etc. to
the slot devices and the partitions on the card. Slots without a card
and slots with partitionless cards can't be distinguished, though.
# SD slot and card
KERNEL=="sd*", ATTRS{model}=="*[Ss][Dd]*[Rr]eader*", SYMLINK+="cardreader/sd%n"
# CF slot and card
KERNEL=="sd*", ATTRS{model}=="*[Cc][Ff]*[Rr]eader*", SYMLINK+="cardreader/cf%n"
# SM slot and card
KERNEL=="sd*", ATTRS{model}=="*[Ss][Mm]*[Rr]eader*", SYMLINK+="cardreader/sm%n"
# MS slot and card
KERNEL=="sd*", ATTRS{model}=="*[Mm][Ss]*[Rr]eader*", SYMLINK+="cardreader/ms%n"
The second cardreader I own has multiple slots, too, but only the
"active" slot is exposed via USB. The rule is as follows:
# Generic card reader
KERNEL=="sd*", ATTRS{model}=="*[Cc][Aa][Rr][Dd]*", SYMLINK+="cardreader/generic%n"
To find out suitable attributes for your cardreader, pull it from the PC, then
do
# udevadm monitor
and plug it in. You get a list of lines like the following:
UEVENT[1246740195.353068] add /devices/pci0000:00/0000:00:0a.2/usb2/2-1/2-1.4/2-1.4:1.0/host5/target5:0:0/5:0:0:0/block/sdc
The more specific lines belong to your cardreader. Now do
# udevinfo --query=name --attribute-walk --path /devices/pci0000:00/0000:00:0a.2/usb2/2-1/2-1.4/2-1.4:1.0/host5/target5:0:0/5:0:0:0/block/sdc
and look for "model" or other attributes where your cardreader gives some specific
string which identifies it.
Kind regards
Jan
Hi Jan,
Thank you for the explanation. I will surely try the rules. I have
one more query, My SD card is not getting unmounted, I tried following
rules but it didn't work,
# mount.sh does the mounting and un-mounting
SUBSYSTEM=="scsi", ACTION=="remove" RUN+="/etc/udev/scripts/
mount.sh"
SUBSYSTEM=="scsi block", ACTION=="remove" RUN+="/etc/udev/scripts/
mount.sh"
SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/
mount.sh"
*mount.sh does the work of mounting and un-mounting devices.
The thing is I have a on board card slot. There is no card reader. But
I think writing rules for card reader will be beneficial.
Kind regards
Jan
Actually my SD card is getting recognised as USB!! The reason is it
is connected to USB hub internally, Now I am trying to use DEVPATH to
resolve the BUG, but still I am getting only "change" signal, I am not
getting "remove" signal at all. Even when I remove the device, the /
dev entry remains there only.
Hey I resolved issue by using DEVPATH, If I recieve events on DEVPATH
then I act, On more thing I want ask is it possible to use the
variables that appear in the udevmonitor list in our mount and unmount
scripts? I want use DEVPATH variable and act.