-1

I need the information provides lsusb about Manufacturer company in usb pendrives, but I don't know how to link it with the block device.

I'm using dbus and python for getting all information about pendrives connected in the system, but DriveVendor and DriveModel don't correspond with Manufacturer company showed with lsusb.

udevadm info gives a lot of information but it haven't the Manufacturer company either.

Perhaps the question is poorly worded and would be better like this: how to get the manufacturer of a pendrive knowing its /dev/ name...or something like that.

Gea Planet
  • 187
  • 1
  • 5

1 Answers1

0

Go to /sys/block/<name>, that will be a symbolic link to something like:

/sys/block/sdf -> ../devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.4/3-1.4:1.0/host9/target9:0:0/9:0:0:0/block/sdf

Then go to the that directory, and in the sucessive parents, you will find a lot of files with interesting information.

The data you are asking for, in my particular example, would be at the directory:

/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.4

There you can find files manufacturer, product, idVendor and idProduct.

rodrigo
  • 94,151
  • 12
  • 143
  • 190
  • And is that directory the same for all pendrives? – Gea Planet Jun 06 '15 at 21:22
  • @GeaPlanet: Not exactly, this is my pendrive. The method will work with any device, but the exact number of directories you will have to go up from `block` one, and the directories remaining until `/sys`, may vary. Particularly if you put USB hubs in the middle. And the numbers (the 3-1.4) will also vary, of course. – rodrigo Jun 06 '15 at 21:24
  • then, is there any way to do this automatically? – Gea Planet Jun 06 '15 at 21:30
  • @GeaPlanet: You are using Python, just go one directory up at a time until you find a directory with a file `idVendor` in it, and you are done. – rodrigo Jun 06 '15 at 21:39