On Fri, 1 Apr 2005, Andrew Marshall wrote: > Hi all, > > I would very much appreciate any assistance anyone can offer on the > following: > > I am currently running version 2.4.22 of the Kernel and am writing an > application that needs to cope with the removal of card media form a USB > flash card reader.
That's a pretty old version of the kernel to be using for new development. Why don't you move up to 2.6? > Hotplug informs me when the card reader itself is added with my intention > being to scan for partition entries at the newly created dev/scsi entry > > e.g /dev/scsi/host0/bus0/target0/lun0/part1 > > and mount any partitions detected. > > This works fine -- but I also need to detect when a memory card has been > removed. > > I have found that the block device file (part1) corresponding to my flash > card's partition is appropriately updated (i.e removed from > /dev/scsi/host0/bus0/target0/lun0/ when the test card is removed) -- but > only if the partition is *not* currently mounted! Of course. The partition _can't_ be removed if it's actively in use, as a result of being mounted. > I found that once I have mounted the partition, the devfs 'part1' block > device perpetually remains -- even when the card is removed, thus making > removal detection a tad tricky. It's not clear why the block device file is deleted when the card is removed and the partition isn't mounted. The kernel itself doesn't know when cards are removed from readers; it would be necessary to poll the device looking for removals and the kernel doesn't do that. > OK, it seems to be possible to unmount the partition, poll the > /dev/scsi/host0/bus0/target0/lun0 entry and then remount once the poller has > determined that the partition is still present -- but this takes time... And > also seems a little extreme (if not ridiculous)... > > Does anyone have any ideas on a fix or alternative way to determine removal > of a flash card from a connected flash card reader. > > Any suggestions on this problem would be greatly appreciated. Many thanks! Using the sg (scsi-generic) interface to send a periodic TEST UNIT READY command to the lun corresponding to the memory card. Alan Stern ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
