Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/pci-devs/pci.backup

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

fn verbose { awk '

	function lower(s) {
		gsub(/A/, "a", s)
		gsub(/B/, "b", s)
		gsub(/C/, "c", s)
		gsub(/D/, "d", s)
		gsub(/E/, "e", s)
		gsub(/F/, "f", s)
		return s
	}
	BEGIN{
		file="/lib/pci"
		FS="\t"
		while(getline <file){
			if(/^;/) continue
			if(/^[0-9A-F]/){
				vid=lower($1)
				vendor[vid] = $2
			}
			if(/^	[0-9]/){
				did=lower($2)
				id[vid "/" did] = $3
			}
		}
		FS = " "
	}

	{
		print $0
		vid = $4
		sub(/\/.*/, "", vid)
		if(vid in vendor){
			s = vendor[vid]
			if($4 in id)
				s = s " " id[$4]
			print "\t" s
		}
	}
'
}

filter=cat
if(~ $1 -v){
	filter=verbose
}
cd '#$/pci' && grep . *ctl | sed '
	s/ctl:/:	/
	s/:	01/:	disk 01/
	s/:	02/:	net  02/
	s/:	03/:	vid  03/
	s/:	([0-9])/:	---  \1/
' | $filter


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.