usb card reader. Which event is generated when medium is inserted?

From: Andy (andy_at_mrbumpy.co.uk)
Date: 10/31/05


Date: Mon, 31 Oct 2005 13:17:35 +0000

Hi folks. I have been set a task which I can complete but I'd like to
know if there is a more elegant way.

I have been asked to provide a simple camera card viewer for a
photography shop.
The aim is for the customer to plug in the card into a usb lots-in-1
card reader and this launches a window showing thumbnails of any images
on their card.

I need to know if there is any event generated when a card is inserted.

Easy with a pen drive, dmesg tells me when a usb pendrive has been
plugged in and tells me the device name to use (e.g. /dev/sde1 )

Unfortunately nothing seems to show when a card is put into the reader.
I usually try a series of mount commands until one doesn't give a "no
medium found" error.
Even /proc/partitions seems no use because it knows nothing until after
I have checked for the medium myself anyway.

autofs doesn't seem to do what I'm after. It mounts a device only when
you go looking for it.

udev is more about detecting your different pendrives and mounting them
differently depending on which device you have plugged in.

At the moment I'm thinking of writing a script which continually
attempts to mount a series of /dev/sd? until one succeeds and then
search for images etc..
Alternatively I could use autofs and keep trying to view the directories
until eventually one is not empty.. and succeeds.

In short....... is there a more elegant solution?
I'm running VectorLinux with kernel 2.6.14
thanks

-- 
Andy Richardson
Never criticize a man 'til you've walked a mile in his shoes.
After that, you can say what you like..
'cos you're a mile away and you've got his shoes.


Relevant Pages

  • usb card reader. Which event is generated when medium is inserted?
    ... know if there is a more elegant way. ... The aim is for the customer to plug in the card into a usb lots-in-1 ... I usually try a series of mount commands until one doesn't give a "no ... Never criticize a man 'til you've walked a mile in his shoes. ...
    (comp.os.linux.hardware)
  • Re: Focus on Design: Card Tricks Sep 07
    ... is the elegant and simple Card Tricks Block. ... Several quilters here have commented that it is a simple block to make ... great Card Tricks block so they can only make blah blocks at best, ...
    (rec.crafts.textiles.quilting)
  • bash script strange behaviour on card-reader mounting
    ... If I insert the card before running the script, ... Any ideas why the mount command doesn't work once it has failed once ... Never criticize a man 'til you've walked a mile in his shoes. ...
    (comp.os.linux.misc)
  • Re: 2.6.0-test9 VFAT problem
    ... and report whatever goes wrong in that case. ... I start the system insert my 64mb Olympus SM into my Belkin SM reader ... mount my 16mb Olympus SM card in my Belkin reader. ... If I try to mount my 64mb card I get 'no media found'. ...
    (Linux-Kernel)
  • Re: Force mount a HD in OS X?
    ... I have a PCI SCI card and an external Hard Drive that will ... SCSI Probe are only available for OS 9 and below. ... Or use the File menu and select 'Mount'. ... CD-RW drive and a few hard drives that work that I have taken ...
    (comp.sys.mac.misc)