Seemingly it looked quite different from lspci.

strace lsusb 2> /tmp/lsusb.out

and

grep open /tmp/lsusb.out

and zooming down into the following part:

pen("i686/libc.so.6", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("sse2/cmov/libc.so.6", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("sse2/libc.so.6", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("cmov/libc.so.6", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("libc.so.6", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
open("/dev/urandom", O_RDONLY)          = 3
open("./usb.ids", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("./usb.ids.gz", O_RDONLY)          = -1 ENOENT (No such file or directory)
open("/var/lib/misc/usb.ids", O_RDONLY) = 3
open("/dev/bus/usb", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/002", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/002/001", O_RDWR)    = 4
open("/dev/bus/usb/002/001", O_RDWR)    = 3
open("/dev/bus/usb/006", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/006/001", O_RDWR)    = 4
open("/dev/bus/usb/006/001", O_RDWR)    = 3
open("/dev/bus/usb/005", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/005/001", O_RDWR)    = 4
open("/dev/bus/usb/005/001", O_RDWR)    = 3
open("/dev/bus/usb/007", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/007/001", O_RDWR)    = 4
open("/dev/bus/usb/007/001", O_RDWR)    = 3
open("/dev/bus/usb/001", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/001/001", O_RDWR)    = 4
open("/dev/bus/usb/001/001", O_RDWR)    = 3
open("/dev/bus/usb/004", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/004/001", O_RDWR)    = 4
open("/dev/bus/usb/004/001", O_RDWR)    = 3
open("/dev/bus/usb/003", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/dev/bus/usb/003/001", O_RDWR)    = 4
open("/dev/bus/usb/003/001", O_RDWR)    = 3


We can see that it enumerate all the usb devices via searching through the /dev/bus/usb device tree.


And then mapping the output of lsusb with the binary data in the special character output:

/dev/bus/usb/007>cat 001 | xxd
0000000: 1201 1001 0900 0040 6b1d 0100 0602 0302  .......@k.......
0000010: 0101 0902 1900 0101 00e0 0009 0400 0001  ................
0000020: 0900 0000 0705 8103 0200 ff              ...........

/dev/bus/usb/007>lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Now the question is the binary format of the special character file....where is it defined in memory?




Reply via email to