* USB card reader media detection
@ 2005-04-01 11:40 Andrew Marshall
2005-04-01 14:40 ` Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrew Marshall @ 2005-04-01 11:40 UTC (permalink / raw)
To: linux-hotplug
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.
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!
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.
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!
Andrew Marshall
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: USB card reader media detection
2005-04-01 11:40 USB card reader media detection Andrew Marshall
@ 2005-04-01 14:40 ` Kay Sievers
2005-04-05 17:51 ` Greg KH
2005-04-06 11:06 ` Andrew Marshall
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2005-04-01 14:40 UTC (permalink / raw)
To: linux-hotplug
On Fri, 2005-04-01 at 12:40 +0100, Andrew Marshall wrote:
> 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.
> 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!
I don't remember the old 2.4 kernels, but I can't imagine how the kernel
could detect this.
> 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.
>
> 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)...
Just poll continuously the main block device, which causes a re-read of
the partition table with every open(). There is no other way to do that.
Card-readers don't tell the kernel, if a media change happened.
Kay
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: USB card reader media detection
2005-04-01 11:40 USB card reader media detection Andrew Marshall
2005-04-01 14:40 ` Kay Sievers
@ 2005-04-05 17:51 ` Greg KH
2005-04-06 11:06 ` Andrew Marshall
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2005-04-05 17:51 UTC (permalink / raw)
To: linux-hotplug
On Fri, Apr 01, 2005 at 12:40:34PM +0100, 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.
>
> 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.
Sorry, will not work properly, as not all devices report when a card has
been added or removed. You need to poll the device :(
Good luck,
greg k-h
-------------------------------------------------------
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_ide95&alloc_id\x14396&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: USB card reader media detection
2005-04-01 11:40 USB card reader media detection Andrew Marshall
2005-04-01 14:40 ` Kay Sievers
2005-04-05 17:51 ` Greg KH
@ 2005-04-06 11:06 ` Andrew Marshall
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Marshall @ 2005-04-06 11:06 UTC (permalink / raw)
To: linux-hotplug
Hi Greg,
Many thanks.
> You need to poll the device :(
Yes, I am now using the TEST UNIT READY command which seems to be working.
Thanks for the input!
Kind Regards,
Andrew Marshall
-----Original Message-----
From: Greg KH [mailto:greg@kroah.com]
Sent: 05 April 2005 18:52
To: Andrew Marshall
Cc: linux-hotplug-devel@lists.sourceforge.net
Subject: Re: USB card reader media detection
On Fri, Apr 01, 2005 at 12:40:34PM +0100, 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.
>
> 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.
Sorry, will not work properly, as not all devices report when a card has
been added or removed. You need to poll the device :(
Good luck,
greg k-h
-------------------------------------------------------
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_ide95&alloc_id\x14396&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-06 11:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-01 11:40 USB card reader media detection Andrew Marshall
2005-04-01 14:40 ` Kay Sievers
2005-04-05 17:51 ` Greg KH
2005-04-06 11:06 ` Andrew Marshall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).