Finding device node from USB vendor and product IDs

Hello,

I'm trying to figure out a way to determine the device node for mounting a USB device. I have a list of potential vendor and product IDs to work from. I can find a device that matches using usbconfig, and I can find device nodes with camcontrol devlist, or even sysctl kern.disks, but I can't find a way to get from one to the other. I'm modifying an existing application that's written mostly in Python, but some C code would be ok.

Thanks,

Denver
 
It's a little complicated, but try these commands:

# usbconfig -d ugen3.4 show_ifdrv
# camcontrol devlist -v

In the first command, replace ugen3.4 with the device you want. Its output will show you the umass driver instance that's attached to it. The second command will show you which scbus instance is attached to the umass driver.

Similar could be done in reverse.
 
Thanks for the help aragon. I did figure out a sequence for my application that seems to work, and you're right, it is a bit complicated. What I'm doing is:

1. Use sysctl kern.disks to get a list of possible devices.
2. For each of those device names that's also in camcontrol devlist get its serial number using camcontrol inquiry [device name] -S
3. Match that S/N with the results of usbconfig -d [device name] dump_device_desc.

I have Vendor ID, Product ID, S/N, and a couple other pieces of information going in - basically everything that's in usbconfig dump_device_desc. Your method might be a bit shorter, but I found it easier to start with the list of devices from sysctl, and I wasn't sure if the umass-sim# from camcontrol would always match the umass# from usbconfig. I may end up trying that method though, if I find out that not all devices report a S/N.

Thanks again,

Denver
 
Back
Top