0

I have a flash drive where I know its vendor ID and product ID.

By scanning through /sys/bus/usb/devices, I can reliably find the enumeration point for the root device (e.g. /sys/bus/usb/devices/3-1) and the enumeration point for the mass storage device (e.g. /sys/bus/usb/devices/3-1:1.0).

Once I know the two enumeration points, how do I use these to lookup the mountpoint (e.g. /mnt/usb0/part0 or /mnt/UsbStorageA)?

--

Alternatively, is there a direct way to get the mountpoint from the vendor ID and product ID?

--

EDIT 1 (more details on my progress):

Ok so (working backward from the mountpoint):

mountpoint: /storage/usb0/part0 (according to /proc/mount)

device node: /dev/block/vold/8:1 (according to /proc/mount)

partition name sda1 (according to /proc/partitions)

But I can't seem to correlate into /sys/block, because there is no sda1 entry in /sys/block, and neither is there any 8:1 entry in /sys/dev/block. Instead, bizarrely, the USB device is in /sys/dev/char, as 189:261. Why the heck would it appear as a char device but not a block device? :-(

AlcubierreDrive
  • 3,654
  • 2
  • 29
  • 45
  • If this was normal linux, you could run `/bin/mount` to see what's currently mounted. I'm not sure that's the best way under Android... – Charles Jan 21 '13 at 22:43
  • You can get the same effect by reading `/proc/mount` (exact same info to the character), but that still doesn't mention vendor ID, product ID, or enumeration point - how do I tell which mounted device is the right one? – AlcubierreDrive Jan 21 '13 at 22:45
  • Hmm. Read the mounts, map that to the list of stuff in `/sys/block`, which includes device IDs? The things in `/sys/bus/devices` point to the same place as those in `/sys/block`... – Charles Jan 21 '13 at 23:27
  • Typed a big comment in response but instead I've posted it as EDIT 1, so please see that. Thanks for your help. – AlcubierreDrive Jan 22 '13 at 00:06
  • Quote "There are two directories, 'block' and 'char', beneath /sys/dev containing symbolic links with names of the form ":". These links point to the corresponding sysfs path for the given device." – clover Jan 22 '13 at 03:06
  • Yes, this is correct. I can follow "forward" from the vid and pid to /sys/dev. Or I can follow "backward" from mountpoint to /dev. But I can't "jump the gap" between /sys/dev and /dev no matter what I try. – AlcubierreDrive Jan 22 '13 at 03:52

0 Answers0