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.

相关推荐
DO_Community3 分钟前
裸金属 vs. 虚拟化 GPU 服务器:AI 训练与推理应该怎么选
运维·服务器·人工智能·llm·大语言模型
徐子元竟然被占了!!4 分钟前
Linux的df和du
linux·运维·服务器
集大周杰伦5 分钟前
Linux网络编程核心实践:TCP/UDP socket与epoll高并发服务器构建
linux·tcp/ip·网络编程·socket·字节序·套接字·i/o多路复用
科技峰行者6 分钟前
华为发布Atlas 900 DeepGreen AI服务器:单机柜100PF算力重构AI训练基础设施
服务器·人工智能·华为·aigc·gpu算力
Mr. Cao code8 分钟前
实战:Docker构建Haproxy负载均衡镜像
linux·运维·ubuntu·docker·容器·负载均衡
9ilk8 分钟前
【基于one-loop-per-thread的高并发服务器】--- 项目介绍&&模块划分
运维·服务器·c++·后端·中间件
大聪明-PLUS11 分钟前
3 个诊断 Linux 服务器的脚本
linux·嵌入式·arm·smarc
@木辛梓16 分钟前
Linux 线程
linux·开发语言·c++
门前灯23 分钟前
Linux系统之pkg-config 命令详解
linux·运维·服务器·pkg-config
fpcc1 小时前
C++编程实践——eventFD
linux·c++