修改lspci显示内容,说白了就是pcie设备在系统有一个配置文件,然后去修改配置文件。
cenOS该文件为/usr/share/hwdata/pci.ids ,
Ubuntu为 /usr/share/misc/pci.ids
make install
#Makefile
SRC_DIR=$(shell pwd)
install:
@$(SRC_DIR)pci.update $(SRC_DIR)/pci.ids
pci.ids
#这里厂商号自己随便写的,如果雷同,请见谅 1fff
1fff MY_COMPANY
0001 first dev
0002 second dev
0003 third dev
pci.update
#! /bin/bash
# Copyright (C) 2017 Inter Corporation
# For licensing information, see the file 'LICENSE' in the root folder
# $1 = system pci.ids file to update
# $2 = system pcitable file to update
# $3 = file with new entries in pci.ids file format
# $4 = pci.ids output file
# $5 = pcitable output file
# $6 = driver name for use in pcitable file
if [ -e "/etc/yum" ];then
pci_ids_path=/usr/share/hwdata/pci.ids
pci_ids_path_tmp=/usr/share/hwdata/pci.ids.tmp
else
pci_ids_path=/usr/share/misc/pci.ids
pci_ids_path_tmp=/usr/share/misc/pci.ids.tmp
fi
exec 3<$pci_ids_path
exec 4<$1
exec 5>$pci_ids_path_tmp
driver="hello_world"
# pattern matching strings
ID="[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]"
VEN="${ID}*"
line=
vendor=
scr_vendor=
arry=()
cnt=0
count=0
notes=
write_flag=1
while true
do
#pci.update
exec 0<&4
while read -r line
do
if [[ $line == $VEN ]]
then
src_vendor=0x${line:0:4}
#echo $src_vendor
fi
arry[$count]=$line
#echo "${arry[$count]}"
count=$(( $count + 1 ))
done
exec 0<&3
exec 1>&5
while read -r line
do
if [[ '#' == ${line:0:1} ]]
then
notes=$line
read -r line
else
notes=''
fi
if [[ $line == $VEN ]]
then
write_flag=1
#add pci.update
vendor=0x${line:0:4}
if [[ $src_vendor == $vendor ]]
then
write_flag=0
fi
if [[ $src_vendor -lt $vendor ]]
then
while [[ "$cnt" -ne "$count" ]]
do
echo "${arry[$cnt]}"
cnt=$(( $cnt + 1 ))
done
fi
fi
if [[ '#' == ${notes:0:1} ]]
then
echo "$notes"
fi
if [[ '1' == $write_flag ]]
then
echo $line
fi
done
break
done
exec 3<&-
exec 4<&-
exec 5>&-
mv $pci_ids_path_tmp $pci_ids_path