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.

相关推荐
野犬寒鸦1 分钟前
从零起步学习JVM|| 第二章:JVM基本组成及JVM内存区域详解
服务器·开发语言·后端·学习·面试·职场和发展
vx-bot5556665 分钟前
企业微信ipad协议的防封号技术体系与策略实践
服务器·企业微信·ipad
菩提树下的凡夫13 分钟前
基于C++语言的Onnx CUDA加速部署推理
linux·运维·人工智能
渔民小镇15 分钟前
告别 Redis/MQ —— ionet 分布式事件总线实战
java·服务器·分布式
Lyre丶15 分钟前
GAMIT netsel模块子网划分与解算
linux·gamit
Predestination王瀞潞20 分钟前
4.3.2 存储->微软文件系统标准(微软,自有技术标准):NTFS(New Technology File System)新技术文件系统
linux·microsoft·ntfs
___波子 Pro Max.22 分钟前
Linux rsync使用教程
linux
竹之却23 分钟前
Ubuntu 系统安装 Ollama 教程
linux·运维·ubuntu·ollama
赵民勇24 分钟前
gtkmm库之动作系统详解
linux·c++
珠海西格24 分钟前
4 月 1 日起执行分布式光伏监控新规,直接影响从业者与项目收益
大数据·运维·服务器·分布式·能源