Re: Reattach/redetect allways connected umass device - is it possible ?

From: Bernd Walter <ticso_at_cicely12.cicely.de>
Date: Mon, 28 Mar 2005 16:41:35 +0200
On Mon, Mar 28, 2005 at 04:38:02PM +0200, Bernd Walter wrote:
> On Mon, Mar 28, 2005 at 04:24:30PM +0200, Poul-Henning Kamp wrote:
> > In message <20050328134856.GF14532_at_cicely12.cicely.de>, Bernd Walter writes:
> > 
> > >> Driver support for this is not really meaterialized and therefore
> > >> the model now is that when the media is ejected the geom device
> > >> is removed and a new one created right away, even if a new media
> > >> is not inserted right away.
> > >
> > >Do you get eject notifications from any device type?
> > 
> > Right now I belive floppy disks DTRT.
> 
> Interesting.
> 
> > >One of my problems is that it is possible with SCSI MO drives to
> > >eject the media, reinsert a new one and errously continue to work
> > >with the old GEOM layout.
> > >I already trashed the data on one media by forgetting to trigger
> > >a reprobe - since then I use a mount script.
> > 
> > Well, I have no idea how to pull the information out of the CAM/SCSI
> > code, but I'm sure there is _some_ way it can be done.
> 
> There is the test unit ready command.
> Either it returns OK, or you may get usefull sense data.
> Here is an example:

This even works for my USB flash drives:
[67]cicely13# camcontrol tur -n da -u 1 -v
Unit is not ready
(pass1:umass-sim0:0:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0 
(pass1:umass-sim0:0:0:0): CAM Status: SCSI Status Error
(pass1:umass-sim0:0:0:0): SCSI Status: Check Condition
(pass1:umass-sim0:0:0:0): NOT READY asc:3a,0
(pass1:umass-sim0:0:0:0): Medium not present
Exit 1
[68]cicely13# camcontrol tur -n da -u 1 -v
Unit is not ready
(pass1:umass-sim0:0:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0 
(pass1:umass-sim0:0:0:0): CAM Status: SCSI Status Error
(pass1:umass-sim0:0:0:0): SCSI Status: Check Condition
(pass1:umass-sim0:0:0:0): UNIT ATTENTION asc:28,0
(pass1:umass-sim0:0:0:0): Not ready to ready change, medium may have changed
Exit 1
[69]cicely13# camcontrol tur -n da -u 1 -v
Unit is ready

[71]cicely13# camcontrol tur -n da -u 4 -v
Unit is not ready
(pass4:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0 
(pass4:umass-sim1:1:0:0): CAM Status: SCSI Status Error
(pass4:umass-sim1:1:0:0): SCSI Status: Check Condition
(pass4:umass-sim1:1:0:0): UNIT ATTENTION asc:28,0
(pass4:umass-sim1:1:0:0): Not ready to ready change, medium may have changed
Exit 1
[72]cicely13# camcontrol tur -n da -u 4 -v
Unit is ready

Those are both more or less random flash card readers, so it seems that
even cheap devices work.

-- 
B.Walter                   BWCT                http://www.bwct.de
bernd_at_bwct.de                                  info_at_bwct.de
Received on Mon Mar 28 2005 - 12:42:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:30 UTC