lkml.org 
[lkml]   [2017]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: gadgetfs: how to wait for USB device initialization?
On Tue, Jun 13, 2017 at 3:21 PM, Andrey Konovalov <andreyknvl@google.com> wrote:
> Hi!
>
> I'm trying to use gadgetfs to fuzz USB device drivers by simply
> connecting random devices for now.
>
> What I want to achieve right now is the following:
>
> 1. mount gadgetfs
> 2. emulate connection of a new USB device
> 3. wait for the device to finish initializing
> 4. unmount gadgetfs
> 5. goto 1
>
> The question is how do I wait for the device to finish initializing
> (the corresponding USB driver to finish probing?) before unmounting
> gadgetfs? As I understand, when I write device description to
> "/dev/gadget/dummy_udc" the initialization happens asynchronously
> after writing is done.
>

You can use inotify on the state file inside a udc's sysfs directory.
It's awesome like that.
Here's a sample code that doesn't do any cleanups because I'm lazy:
https://gist.github.com/talshorer/61be1bc3472cc2a7b4866b9bd5a239ca

\
 
 \ /
  Last update: 2017-06-13 18:02    [W:0.067 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site