On Tue, 26 Sep 2017 16:30:48 +0200, Tomasz CEDRO wrote:
> The question is how to gracefully self-umount from a device point of
> view in a way not to confuse automounter and/or usb / mass storage
> drivers? Is there any way of doing that in SCSI+USB? Something like
> CD-ROM eject, then device removal..
This is a _very_ good question of high relevance which hasn't been
solved across many operating systems. :-)
Basically, a normal (clean) unmount can only be initiated by the OS.
You can program the controller (on the USB device) to disconnect on
its own, but that doesn't cause the OS to call unmount(), it just
makes the device disappear.
One thing I could imagine is the use of SCSI status messages and
a modified (!) storage access driver in the OS which could act upon
a specific status code with a call to unmount(), but that is, as far
as I know, not implemented yet anywhere.
The primary problem with disconnecting is that it happens _before_
the unmount() call, and keep in mind that unmounting also requires
some time. The OS can issue a certain direct access action, but it's
up to the device to perform that action. Until it has successfully
been performed, the device may not be deconnected.
Timing is hard. :-)
For CD-ROM, or optical media in general, it's not a problem because
it's read-only. The CAM EJECT command - again issued by the OS, not
by the device -, when performed _before_ unmount, leaves the OS in
a problematic state: Something is still mounted, but it doesn't
exist anymore. Okay, umount -f, no damage done. But with read-write
media such as USB direct access storage... well... that looks much
That's why you alway unmount first, then wait, then disconnect.
Sorry I couldn't provide more helpful suggestions... ;-)
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
firstname.lastname@example.org mailing list
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"