Magellan Linux

Annotation of /alx-src/tags/kernel26-2.6.12-alx-r9/scripts/extract-ikconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 630 - (hide annotations) (download)
Wed Mar 4 11:03:09 2009 UTC (15 years, 3 months ago) by niro
File size: 1613 byte(s)
Tag kernel26-2.6.12-alx-r9
1 niro 628 #!/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
5    
6     binoffset="./scripts/binoffset"
7    
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"
12    
13     start=`$binoffset $file $IKCFG_ST 2>/dev/null`
14     [ "$?" != "0" ] && start="-1"
15     if [ "$start" -eq "-1" ]; then
16     return
17     fi
18     end=`$binoffset $file $IKCFG_ED 2>/dev/null`
19    
20     let start="$start + 8"
21     let size="$end - $start"
22    
23     head --bytes="$end" "$file" | tail --bytes="$size" | zcat
24    
25     clean_up
26     exit 0
27     }
28    
29    
30     usage()
31     {
32     echo " usage: extract-ikconfig [b]zImage_filename"
33     }
34    
35     clean_up()
36     {
37     if [ "$TMPFILE" != "" ]; then
38     rm -f $TMPFILE
39     fi
40     }
41    
42     if [ $# -lt 1 ]
43     then
44     usage
45     exit 1
46     fi
47    
48     TMPFILE="/tmp/ikconfig-$$"
49     image="$1"
50    
51     # vmlinux: Attempt to dump the configuration from the file directly
52     dump_config "$image"
53    
54     GZHDR1="0x1f 0x8b 0x08 0x00"
55     GZHDR2="0x1f 0x8b 0x08 0x08"
56    
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"
63     fi
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"
71     fi
72    
73     echo "ERROR: Unable to extract kernel configuration information."
74     echo " This kernel image may not have the config info."
75    
76     clean_up
77     exit 1

Properties

Name Value
svn:executable *