Root/
1 | #!/bin/sh |
2 | # ---------------------------------------------------------------------- |
3 | # extract-ikconfig - Extract the .config file from a kernel image |
4 | # |
5 | # This will only work when the kernel was compiled with CONFIG_IKCONFIG. |
6 | # |
7 | # The obscure use of the "tr" filter is to work around older versions of |
8 | # "grep" that report the byte offset of the line instead of the pattern. |
9 | # |
10 | # (c) 2009, Dick Streefland <dick@streefland.net> |
11 | # Licensed under the terms of the GNU General Public License. |
12 | # ---------------------------------------------------------------------- |
13 | |
14 | gz1='\037\213\010' |
15 | gz2='01' |
16 | cf1='IKCFG_ST\037\213\010' |
17 | cf2='0123456789' |
18 | |
19 | dump_config() |
20 | { |
21 | if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"` |
22 | then |
23 | pos=${pos%%:*} |
24 | tail -c+$(($pos+8)) "$1" | zcat -q |
25 | exit 0 |
26 | fi |
27 | } |
28 | |
29 | # Check invocation: |
30 | me=${0##*/} |
31 | img=$1 |
32 | if [ $# -ne 1 -o ! -s "$img" ] |
33 | then |
34 | echo "Usage: $me <kernel-image>" >&2 |
35 | exit 2 |
36 | fi |
37 | |
38 | # Initial attempt for uncompressed images or objects: |
39 | dump_config "$img" |
40 | |
41 | # That didn't work, so decompress and try again: |
42 | tmp=/tmp/ikconfig$$ |
43 | trap "rm -f $tmp" 0 |
44 | for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"` |
45 | do |
46 | pos=${pos%%:*} |
47 | tail -c+$pos "$img" | zcat 2> /dev/null > $tmp |
48 | dump_config $tmp |
49 | done |
50 | |
51 | # Bail out: |
52 | echo "$me: Cannot find kernel config." >&2 |
53 | exit 1 |
54 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9