On Thu, 24 Jun 2004, Todd Fischer wrote:
> Hi,
>
> I am trying to figure out how to use the USB file backed storage driver with
> storage media that can be installed or removed at any time (but hopefully,
> only when the system isn't using the media).
>
> We currently get a hardware interrupt when the media is inserted and
> removed, which is monitored by a driver. We have an application blocked on
> an ioctl() call to the driver waiting for a media change event. We the
> event occurs, the application takes care of unmount / mount issues. We
> would also like this application to add or remove the media from the list of
> media the USB file backed storage driver is exposing.
>
> Does the USB file backed storage driver support this use model, or do I need
> to extend the driver? If the driver needs to be extended, any suggestions
> on how it is done?
>
> Todd Fischer
The Linux-2.4 version of the g_file_storage driver does not support media
changes.
The Linux-2.6 version does, through sysfs. It's described (rather
tersely) in the comments at the beginning of the source file,
drivers/usb/gadget/file_storage.c.
Here's how it works. If you have a sysfs filesystem mounted, you can look
in the device directory corresponding to the g_file_storage gadget.
There you will find directories with names like *-lun0, *-lun1, and so on
corresponding to the different Logical UNits you have created (normally
there's only one of them). Inside each of those directories is a file
named "file", and it contains the name of the backing file being used for
the LUN. To "unload the medium", just write a blank line to that file.
For example,
echo >/sys/devices/.../gadget-lun0/file
To use a different backing file as the medium, just write the name of the
new backing file:
echo new_backing_filename >/sys/devices/.../gadget-lun0/file
Note that you have to have superuser privileges for the writes to succeed.
Alan Stern
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel