On Fri, 27 Oct 2006, Hughes, James wrote:

> Hello all,
> 
> Apologies if this is the wrong mailing list, not sure if it's a dev or
> user issue.
> 
> I am using the gadget file storage to share a backing file to a host PC
> (using a PXA270 board). It seems to work fine.
> 
> However, I have so far been unable to figure out/find out how I can
> detect in my user space application that the client has been connected
> to a host. The constantly running app on the client needs to ensure it
> does not write to the backing store whilst the host is connected
> (according to docs), so needs to know when it is connected! And also
> need to know when disconnected so app can then start writing to backing
> file again.
> 
> Is there some sort of kernel event/mechanism for determining this
> information?

There isn't.  In fact, g_file_storage itself doesn't really know whether
it is connected to a host.  All it does is respond to commands one at a
time as they come in.

The best way to determine whether a gadget is connected to a host is to
check if power is available over the USB connection.  That information is
not available to g_file_storage, although the lower-level USB interface
driver (pxa2xx_udc) should be aware of it.  I suppose a notification could
be added there but it wouldn't solve all your problems...

> There are obviously issues with timing - for example, how is the
> situation where the app is writing something to the backing file when
> the host is connected handled?

Correct.  Basically there is no way to manage such cases.  The only safe 
approach is to avoid writing to the backing file whenever the USB cable is 
plugged into a host, or is about to be plugged into a host (which means 
your user program would need to be able to see a short distance into the 
future!).

>  I am assuming all these issue are handled
> somehow, as many devices appear to be able to do this (I could be wrong
> - is there a better way?) 

What you mean isn't entirely clear -- but I suspect you _are_ wrong.

If you really need to _share_ the backing file between the host and the 
user program, your best bet is not to use USB Mass Storage at all but 
instead use a genuine file-sharing protocol.  For instance, you might set 
up a network connection between the gadget and the host and use Samba or 
NFS.

Alan Stern


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to