Linking a USBDevice to its Host/Device Number

I am working with the usbd_* functions to iterate over the USB Host Controller and their Devices.

After identifying the specific USB Stick I am looking for with its Device Descriptor i need to know, where i can access it in the file system.

How can link the Device X From USB Hostcontroller Y to its entry in /dev/?
The other way would also work: How can i get the Host Controller X, Device Y for a USB Device in /dev?

Otin,

I don’t understand your question based on the first line above. The USB stick won’t appear in the ‘file system’.

I’m guessing what’s happening is the following:

  1. You plug in a USB thumbdrive.
  2. The thumbdrive gets mapped as a QNX drive
  3. You want to know which QNX drive = the thumbdrive just plugged in.

You can’t do it from usbd_ commands.

The USB driver (devb-umass) is what assigns the QNX drive from the USB thumbdrive. It’s already waiting for the thumbdrive to be plugged in and it assigns the drive mapping. There are command line options to devb-umass that allow specifying vendor id / device id. You might (can’t recall 100% for sure) be able to manually assign a specific vendor/device id to a specific drive mapping and therefore be able to know exactly the drive name assigned to the USB device. But that would limit you to exactly 1 type of device.

The other way is for your application to store all the dev entries internally. Then when you detect any USB plug in, re-read the dev entries and update your internal data. If it happens to also be the USB drive you are looking for when the new dev entry will be the drive that was just plugged in. Not the cleanest way to do it but it might be all you can do.

Tim

Ok let’s try it again:

A USB Stick has serveral Descriptors, that are located on the ROM of the Stick.
With the Device- and Stringdescriptor I am able to indetify a unique USB Device.

A Linux System can have serveral USB Hostcontroller and each Hostcontroller can have up to 127 USB Devices.
The Device Number is asigned depending on the number of usb devices already connected to the Hostcontroller.

I am writing a cpp programm, where i need to access the descriptors an the files of the same USB Stick.
The usbd_() functions allow me to get the descriptors of a USB Device.
To adress a USB Device in the usbd_
() functions you cannot use the name of a device (that is has in /dev/) but the USB Hostcontroller Number and Device Number.
After iterating over all the USB Hostcontroller and their USB Devices i finally identified the unique USB Stick with its descriptors (in case it is plugged in).

Now i need to to know, where i can access this USB Device (on Hostcontroller X with Device Number Y) in the filesystem.

How do I connect the Host-/DeviceNumber of a USB Device to its entry in /dev/?

If I knew, i could conclude to its mounting point in /fs/.