Commit c38aabf4 authored by Ryan Jackson's avatar Ryan Jackson

Remove extract_kernel_version.

parent deee6ffd
#!/bin/sh
# extracts .config info from a [b]zImage file
# uses: binoffset (new), dd, zcat, strings, grep
# $arg1 is [b]zImage filename
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
BOOTDIR=/var/emulab/boot
ETCDIR=/etc/emulab
fi
binoffset="$BINDIR/binoffset"
test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
clean_up()
{
if [ "$TMPFILE" != "" ]; then
rm -f $TMPFILE
fi
}
check_ide_disk() {
local file="$1"
grep 'ide[-_]disk' "$file" > /dev/null
if [ $? -eq 0 ]; then
echo "ide-disk: yes"
else
echo "ide-disk: no"
fi
}
dump_version() {
local file="$1"
local version=`sed -n -r '/Linux version/p' "$file" | \
tr -d -c ' -~' | cut -d' ' -f3`
echo "version: $version"
}
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
dump_config() {
local file="$1"
start=`$binoffset $file $IKCFG_ST 2>/dev/null`
[ "$?" != "0" ] && start="-1"
if [ "$start" -eq "-1" ]; then
return
fi
end=`$binoffset $file $IKCFG_ED 2>/dev/null`
let start="$start + 8"
let size="$end - $start"
dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
clean_up
exit 0
}
usage()
{
echo " usage: extract-ikconfig [b]zImage_filename"
}
if [ $# -lt 1 ]
then
usage
exit 1
fi
TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1
image="$1"
# vmlinux: Attempt to dump the configuration from the file directly
dump_config "$image"
GZHDR1="0x1f 0x8b 0x08 0x00"
GZHDR2="0x1f 0x8b 0x08 0x08"
# vmlinux.gz: Check for a compressed images
off=`$binoffset "$image" $GZHDR1 2>/dev/null`
[ "$?" != "0" ] && off="-1"
if [ "$off" -eq "-1" ]; then
off=`$binoffset "$image" $GZHDR2 2>/dev/null`
[ "$?" != "0" ] && off="-1"
fi
if [ "$off" -eq "0" ]; then
zcat <"$image" >"$TMPFILE"
#dump_config "$TMPFILE"
dump_version "$TMPFILE"
check_ide_disk "$TMPFILE"
clean_up
exit 0
elif [ "$off" -ne "-1" ]; then
(dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
zcat >"$TMPFILE"
#dump_config "$TMPFILE"
dump_version "$TMPFILE"
check_ide_disk "$TMPFILE"
clean_up
exit 0
fi
echo "ERROR: Unable to extract kernel configuration information."
echo " This kernel image may not have the config info."
clean_up
exit 1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment