1
0

pci 752 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/rc
  2. fn verbose { awk '
  3. function lower(s) {
  4. gsub(/A/, "a", s)
  5. gsub(/B/, "b", s)
  6. gsub(/C/, "c", s)
  7. gsub(/D/, "d", s)
  8. gsub(/E/, "e", s)
  9. gsub(/F/, "f", s)
  10. return s
  11. }
  12. BEGIN{
  13. file="/lib/pci"
  14. FS="\t"
  15. while(getline <file){
  16. if(/^;/) continue
  17. if(/^[0-9A-F]/){
  18. vid=lower($1)
  19. vendor[vid] = $2
  20. }
  21. if(/^ [0-9]/){
  22. did=lower($2)
  23. id[vid "/" did] = $3
  24. }
  25. }
  26. FS = " "
  27. }
  28. {
  29. print $0
  30. vid = $4
  31. sub(/\/.*/, "", vid)
  32. if(vid in vendor){
  33. s = vendor[vid]
  34. if($4 in id)
  35. s = s " " id[$4]
  36. print "\t" s
  37. }
  38. }
  39. '
  40. }
  41. filter=cat
  42. if(~ $1 -v){
  43. filter=verbose
  44. }
  45. cd '#$/pci' && grep . *ctl | sed '
  46. s/ctl:/: /
  47. s/: 01/: disk 01/
  48. s/: 02/: net 02/
  49. s/: 03/: vid 03/
  50. s/: ([0-9])/: --- \1/
  51. ' | $filter