ia64/linux-2.6.18-xen.hg

diff scripts/extract-ikconfig @ 0:831230e53067

Import 2.6.18 from kernel.org tarball.
author Ian Campbell <ian.campbell@xensource.com>
date Wed Apr 11 14:15:44 2007 +0100 (2007-04-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/extract-ikconfig	Wed Apr 11 14:15:44 2007 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +#!/bin/sh
     1.5 +# extracts .config info from a [b]zImage file
     1.6 +# uses: binoffset (new), dd, zcat, strings, grep
     1.7 +# $arg1 is [b]zImage filename
     1.8 +
     1.9 +binoffset="./scripts/binoffset"
    1.10 +test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
    1.11 +
    1.12 +IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
    1.13 +IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
    1.14 +function dump_config {
    1.15 +    typeset file="$1"
    1.16 +
    1.17 +    start=`$binoffset $file $IKCFG_ST 2>/dev/null`
    1.18 +    [ "$?" != "0" ] && start="-1"
    1.19 +    if [ "$start" -eq "-1" ]; then
    1.20 +	return
    1.21 +    fi
    1.22 +    end=`$binoffset $file $IKCFG_ED 2>/dev/null`
    1.23 +
    1.24 +    let start="$start + 8"
    1.25 +    let size="$end - $start"
    1.26 +
    1.27 +    dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
    1.28 +
    1.29 +    clean_up
    1.30 +    exit 0
    1.31 +}
    1.32 +
    1.33 +
    1.34 +usage()
    1.35 +{
    1.36 +	echo "  usage: extract-ikconfig [b]zImage_filename"
    1.37 +}
    1.38 +
    1.39 +clean_up()
    1.40 +{
    1.41 +	if [ "$TMPFILE" != "" ]; then
    1.42 +		rm -f $TMPFILE
    1.43 +	fi
    1.44 +}
    1.45 +
    1.46 +if [ $# -lt 1 ]
    1.47 +then
    1.48 +	usage
    1.49 +	exit 1
    1.50 +fi
    1.51 +
    1.52 +TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1
    1.53 +image="$1"
    1.54 +
    1.55 +# vmlinux: Attempt to dump the configuration from the file directly
    1.56 +dump_config "$image"
    1.57 +
    1.58 +GZHDR1="0x1f 0x8b 0x08 0x00"
    1.59 +GZHDR2="0x1f 0x8b 0x08 0x08"
    1.60 +
    1.61 +# vmlinux.gz: Check for a compressed images
    1.62 +off=`$binoffset "$image" $GZHDR1 2>/dev/null`
    1.63 +[ "$?" != "0" ] && off="-1"
    1.64 +if [ "$off" -eq "-1" ]; then
    1.65 +	off=`$binoffset "$image" $GZHDR2 2>/dev/null`
    1.66 +	[ "$?" != "0" ] && off="-1"
    1.67 +fi
    1.68 +if [ "$off" -eq "0" ]; then
    1.69 +	zcat <"$image" >"$TMPFILE"
    1.70 +	dump_config "$TMPFILE"
    1.71 +elif [ "$off" -ne "-1" ]; then
    1.72 +	(dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
    1.73 +		zcat >"$TMPFILE"
    1.74 +	dump_config "$TMPFILE"
    1.75 +fi
    1.76 +
    1.77 +echo "ERROR: Unable to extract kernel configuration information."
    1.78 +echo "       This kernel image may not have the config info."
    1.79 +
    1.80 +clean_up
    1.81 +exit 1