Development

Query vendor with the PCI device vendor ID

Posted by jianshenliu

In Linux, each PCI device is associated with a 2-byte vendor ID. Here is an example:

$ cat /sys/bus/pci/devices/0000:00:00.0/vendor
0x1022

To decode the ID to be the name of the vendor, we need mapping information between the ID and the name. lspci uses the PCI ID repository that can be downloaded/browered from http://pci-ids.ucw.cz/. We can use strace to evidence that lspci actually looks at a file called pci.ids when executing this command:

$ (strace lspci >/dev/null) 2>&1 | grep pci.ids
openat(AT_FDCWD, "/usr/share/misc/pci.ids.gz", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/misc/pci.ids", O_RDONLY) = 4

Related Post

Leave a Reply

%d bloggers like this: