lspci源码

lspci

显示Linux系统的pci设备最简单的方法就是使用lspci命令,前提是要安装pciutils包(centos在最小化安装时不会自带该包,需要自己下载安装)

pciutils包的源码github地址为: https://github.com/pciutils/pciutils

从该项目的README文件可以知道,其主要提供三个命令:lspci、setpci和update-pciids。

  • lspci: displays detailed information about all PCI buses and devices.

  • setpci: allows to read from and write to PCI device configuration

registers. For example, you can adjust the latency timers with it.

CAUTION: There is a couple of dangerous points and caveats, please read

the manual page first!

  • update-pciids: download the current version of the pci.ids file.

update-pciids命令会从网上更新pci.ids文件,该文件包含着pci设备的vendor id和device id 与厂商名称、型号名称的对应关系,一旦更改该文件那么lspcishow出来的东西就会发生变化。

不同Linux发行版本的pci.ids文件的位置有所不同,比如centos一般在/usr/share/hwdata/pci.ids,而Debian一般在/usr/share/misc/pci.ids,lspci命令的路径一般在centos下的/usr/sbin/lspci,而在Debian下一般为/use/bin/lspci,update-pciids一般在/usr/sbin/update-pciids,这些路径如果是手动编译安装pciutils则可以自行定制,关于如何编译安装可参考pciutils-3.6.2。

同样,不同发行版本的pciutils也有差异,比如centos的update-pciids和Debian的 update-pciids是有区别的,最重要的区别在于其pci.ids更新的源不同

在Debian中:

#!/bin/sh

#URL="http://pci-ids.ucw.cz/pci.ids"

URL="http://pciids.sourceforge.net/v2.2/pci.ids"

FILE=/usr/share/misc/pci.ids

在centos中:

#!/bin/sh

"$1" = "-q" \] \&\& quiet=true \|\| quiet=false set -e SRC="http://pci-ids.ucw.cz/v2.2/pci.ids" DEST=/usr/share/hwdata/pci.ids

同样在qemu中也存在这么一个头文件,里面也是定义了各个pci设备vendor_id和device_id.

相关推荐
地衣君3 小时前
RISC-V 开发板 + Ubuntu 23.04 部署 open_vins 过程
linux·ubuntu·risc-v
5:003 小时前
云备份项目
linux·开发语言·c++
码农101号4 小时前
Linux中shell编程表达式和数组讲解
linux·运维·服务器
云道轩4 小时前
升级centos 7.9内核到 5.4.x
linux·运维·centos
是小满满满满吗4 小时前
传输层:udp与tcp协议
linux·服务器·网络
爱学习的小道长4 小时前
Ubuntu Cursor升级成v1.0
linux·运维·ubuntu
EelBarb4 小时前
seafile:ubuntu搭建社区版seafile12.0
linux·运维·ubuntu
Xam_d_LM4 小时前
【Latex】Windows/Ubuntu 绘制 eps 矢量图通用方法(drawio),支持插入 Latex 数学公式
linux·ubuntu·科研·矢量图·drawio
Mintimate5 小时前
云服务器 Linux 手动 DD 安装第三方 Linux 发行版:原理与实战
linux·运维·服务器
RussellFans5 小时前
Linux 环境配置
linux·运维·服务器