0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 cf1='IKCFG_ST\037\213\010'
0015 cf2='0123456789'
0016
0017 dump_config()
0018 {
0019 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
0020 then
0021 pos=${pos%%:*}
0022 tail -c+$(($pos+8)) "$1" | zcat > $tmp1 2> /dev/null
0023 if [ $? != 1 ]
0024 then
0025 cat $tmp1
0026 exit 0
0027 fi
0028 fi
0029 }
0030
0031 try_decompress()
0032 {
0033 for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
0034 do
0035 pos=${pos%%:*}
0036 tail -c+$pos "$img" | $3 > $tmp2 2> /dev/null
0037 dump_config $tmp2
0038 done
0039 }
0040
0041
0042 me=${0
0043 img=$1
0044 if [ $
0045 then
0046 echo "Usage: $me <kernel-image>" >&2
0047 exit 2
0048 fi
0049
0050
0051 tmp1=/tmp/ikconfig$$.1
0052 tmp2=/tmp/ikconfig$$.2
0053 trap "rm -f $tmp1 $tmp2" 0
0054
0055
0056 dump_config "$img"
0057
0058
0059 try_decompress '\037\213\010' xy gunzip
0060 try_decompress '\3757zXZ\000' abcde unxz
0061 try_decompress 'BZh' xy bunzip2
0062 try_decompress '\135\0\0\0' xxx unlzma
0063 try_decompress '\211\114\132' xy 'lzop -d'
0064 try_decompress '\002\041\114\030' xyy 'lz4 -d -l'
0065 try_decompress '\050\265\057\375' xxx unzstd
0066
0067
0068 echo "$me: Cannot find kernel config." >&2
0069 exit 1