3

I want to the file from which the command

lsusb -t

retrieves the data. I am curious to see where this is stored.

this is the snap

and can anyone also tell that what can do with device id that displays in fdisk -l?

  • I have answered the lsusb related question..please ask a different question for fdisk – heemayl Jan 26 '16 at 15:34
4

lsusb reads its data from the kernel provided virtual sys Filesystem mounted in /sys; specifically from the location of relevant directories for USB devices. These devices are connected to different PCI buses and are (mostly) detected by udevd.

For example, in my computer here is one example of the localtion of a USB device connected to a particular PCI bus:

/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/

The contents of the directory:

% print -l *
4-1:1.0
authorized
avoid_reset_quirk
bcdDevice
bConfigurationValue
bDeviceClass
bDeviceProtocol
bDeviceSubClass
bmAttributes
bMaxPacketSize0
bMaxPower
bNumConfigurations
bNumInterfaces
busnum
configuration
descriptors
dev
devnum
devpath
driver
ep_00
idProduct
idVendor
ltm_capable
maxchild
port
power
quirks
removable
remove
speed
subsystem
uevent
urbnum
version

lsusb just reads from relevant file(s) of this directory.

| improve this answer | |
2

lsusb uses libudev to fetch the list of devices you see. Libudev, in turn, uses a combination of the udev database and searching through the /sys filesystem to find hardware info.

Relevant code repositories:

https://github.com/gregkh/lsusb

http://cgit.freedesktop.org/systemd/systemd/tree/src/libudev

| improve this answer | |
0

Kernel has drivers for the devices and kernel adds them. Devices report their capabilties to the driver or to the BIOS. Some of them are reported by BIOS. I know that because I had a BIOS with bug and it was reporting fans, which were not present. When processor got hot, the kernel driver tried to switch on inexistent fans. Finally I solved the problem by compiling the kernel without support for fans.

Take a look at /sys/devices. You will find your devices there. You can find lots of information about the devices in directories and files. Kernel creates them dynamically when devices are dis/connected.

| improve this answer | |
0

Excuse me, I won't help you! If you want some fun:

ldd `which lsusb`
strace lsusb -t
ltrace -l "libudev*" lsusb -t

Well, I would suggest to read at least the long description (if not the whole manual) of each command using man or info.

| improve this answer | |
0

After a quick strace, I found that lsusb keeps a list of VID/PIDs that relate to product names in /var/lib/usbutils/usb.ids

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.