[NETFILTER]: Use correct type for "ports" module parameter
[linux/fpc-iii.git] / scripts / extract-ikconfig
blobd9f9f34b22abb1eb8dd6995e06ffe25ac230a4a2
1 #!/bin/sh
2 # extracts .config info from a [b]zImage file
3 # uses: binoffset (new), dd, zcat, strings, grep
4 # $arg1 is [b]zImage filename
6 binoffset="./scripts/binoffset"
8 IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
9 IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
10 function dump_config {
11 typeset file="$1"
13 start=`$binoffset $file $IKCFG_ST 2>/dev/null`
14 [ "$?" != "0" ] && start="-1"
15 if [ "$start" -eq "-1" ]; then
16 return
18 end=`$binoffset $file $IKCFG_ED 2>/dev/null`
20 let start="$start + 8"
21 let size="$end - $start"
23 head --bytes="$end" "$file" | tail --bytes="$size" | zcat
25 clean_up
26 exit 0
30 usage()
32 echo " usage: extract-ikconfig [b]zImage_filename"
35 clean_up()
37 if [ "$TMPFILE" != "" ]; then
38 rm -f $TMPFILE
42 if [ $# -lt 1 ]
43 then
44 usage
45 exit 1
48 TMPFILE="/tmp/ikconfig-$$"
49 image="$1"
51 # vmlinux: Attempt to dump the configuration from the file directly
52 dump_config "$image"
54 GZHDR1="0x1f 0x8b 0x08 0x00"
55 GZHDR2="0x1f 0x8b 0x08 0x08"
57 # vmlinux.gz: Check for a compressed images
58 off=`$binoffset "$image" $GZHDR1 2>/dev/null`
59 [ "$?" != "0" ] && off="-1"
60 if [ "$off" -eq "-1" ]; then
61 off=`$binoffset "$image" $GZHDR2 2>/dev/null`
62 [ "$?" != "0" ] && off="-1"
64 if [ "$off" -eq "0" ]; then
65 zcat <"$image" >"$TMPFILE"
66 dump_config "$TMPFILE"
67 elif [ "$off" -ne "-1" ]; then
68 (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
69 zcat >"$TMPFILE"
70 dump_config "$TMPFILE"
73 echo "ERROR: Unable to extract kernel configuration information."
74 echo " This kernel image may not have the config info."
76 clean_up
77 exit 1