1#!/bin/sh
2#
3# kernelcruft.sh
4#
5# Try to find *.c files in /sys which are orphaned
6#
7
8cd /sys/conf
9cat files* | sed '
10/^[ 	]*#/d
11s/[ 	].*//
12/^$/d
13' | sort -u > /tmp/_0
14
15cd /sys
16find * -name '*.c' -print | sed '
17/\/compile\//d
18/^boot/d
19' | sort -u > /tmp/_1
20
21find * -name '*.[ch]' -print | xargs grep 'include.*c[>"]' > /tmp/_2
22
23find * -name 'Makefile*' -print | xargs cat | sed '
24/^	/d
25s/:.*//
26/^[ 	]*$/d
27' > /tmp/_3
28
29comm -13 /tmp/_0 /tmp/_1 | while read f
30do
31	b=`basename $f`
32	if grep $b /tmp/_2 > /dev/null ; then
33		# echo "2 $f"
34		continue
35	fi
36	if grep $b /tmp/_3 > /dev/null ; then
37		# echo "3 $f"
38		continue
39	fi
40	echo $f
41done
42
43