Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Udev rules problem

0 views
Skip to first unread message

Pranav

unread,
Jul 4, 2009, 6:57:31 AM7/4/09
to
These are my udev rules for getting USB and SD cards in different
folders in /dev , But I am getting links created to sdc,sdd,sdf..,
All are considered as USB and SD card!!

KERNELS=="usb*", SUBSYSTEMS=="usb", DRIVERS=="usb",
SYMLINK="usbdevices/%k"
SUBSYSTEMS=="scsi", DRIVERS=="sd", SYMLINK="carddevices/%k"


Jan Kandziora

unread,
Jul 4, 2009, 4:48:21 PM7/4/09
to
Pranav schrieb:
If you want to sort out a specific USB cardreader from USB harddisks
or USB flash sticks, you have to use a selector to make sure the rule
will not match the USB harddisks or flash sticks.

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

Pranav

unread,
Jul 6, 2009, 10:30:35 AM7/6/09
to

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.

Jan Kandziora

unread,
Jul 7, 2009, 3:42:59 PM7/7/09
to
Pranav schrieb:

>
> *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.
>
Uh, in your previous post you talked about USB. Which kind of setup do you
really have?

Kind regards

Jan

Pranav

unread,
Jul 8, 2009, 2:32:54 AM7/8/09
to

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.

Pranav

unread,
Jul 8, 2009, 6:11:24 AM7/8/09
to

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.

0 new messages