#!/bin/bash
#
# given linux/drivers/pci/pci.c from a 2.x kernel, strips out the 
# struct containing PCI vendor and device ids
#
#
# uses exclude.lst good-video.lst, good-eth.lst and good-scsi.lst
#

#
# expects a list of entries to ignore in file specified as $1
#
#if [ ! -e "$1" ]; then
#    echo "Must specify file containing exclusion list as arg 1"
#    exit 1
#fi

#
# old list of acceptable entries is $2
#
#if [ ! -e "$2" ]; then
#    echo "Must specify file containing old good entries as arg 2"
#    exit 1
#fi

#
# store list in a temporary file
#
tmpfile=/tmp/pcilist$$
trap 'rm -f $tmpfile; exit' INT TERM

awk '

BEGIN { foundit = 0 }

# now read in lines till we hit the last line
{
if (foundit && $0 ~ /\;/) exit

if (foundit) print $0

if ($0 ~ /struct pci_dev_info dev_info/) foundit = 1
}

END { }

' > $tmpfile

#
# tmpfile now holds the new 'all.lst'. Merge with the existing good and exclude
# lists
#
cat exclude.lst good-scsi.lst good-video.lst good-eth.lst $tmpfile | sort -bdf +1 | sed "s/,$//" | uniq --unique

#rm -f $tmpfile
exit