summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2004-06-26 21:53:53 +0100
committerAnton Altaparmakov <aia21@cantab.net>2004-06-26 21:53:53 +0100
commit320ed1994ecf7ccadaaa95196467565b34d8d686 (patch)
treeb36f16a87596469091c97d35002faa1b5c0360ab /scripts
parent702fdfcae9a47ec4976d82d3d0b4b4a41bd72a52 (diff)
parentf6a7507c1714f5cb4faaebc76a1d02260830be01 (diff)
Merge cantab.net:/home/src/bklinux-2.6
into cantab.net:/home/src/ntfs-2.6
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/extract-ikconfig87
-rwxr-xr-xscripts/mkconfigs22
2 files changed, 60 insertions, 49 deletions
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 8e526d370966..d9f9f34b22ab 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -1,9 +1,31 @@
-#! /bin/bash
+#!/bin/sh
# extracts .config info from a [b]zImage file
# uses: binoffset (new), dd, zcat, strings, grep
# $arg1 is [b]zImage filename
-TMPFILE=""
+binoffset="./scripts/binoffset"
+
+IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
+IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
+function dump_config {
+ typeset 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"
+
+ head --bytes="$end" "$file" | tail --bytes="$size" | zcat
+
+ clean_up
+ exit 0
+}
+
usage()
{
@@ -12,8 +34,7 @@ usage()
clean_up()
{
- if [ -z $ISCOMP ]
- then
+ if [ "$TMPFILE" != "" ]; then
rm -f $TMPFILE
fi
}
@@ -21,46 +42,36 @@ clean_up()
if [ $# -lt 1 ]
then
usage
- exit
+ exit 1
fi
-image=$1
+TMPFILE="/tmp/ikconfig-$$"
+image="$1"
-# There are two gzip headers, as well as arches which don't compress their
-# kernel.
-GZHDR="0x1f 0x8b 0x08 0x00"
-if [ `binoffset $image $GZHDR >/dev/null 2>&1 ; echo $?` -ne 0 ]
-then
- GZHDR="0x1f 0x8b 0x08 0x08"
- if [ `binoffset $image $GZHDR >/dev/null 2>&1 ; echo $?` -ne 0 ]
- then
- ISCOMP=0
- fi
-fi
+# vmlinux: Attempt to dump the configuration from the file directly
+dump_config "$image"
-PID=$$
+GZHDR1="0x1f 0x8b 0x08 0x00"
+GZHDR2="0x1f 0x8b 0x08 0x08"
-# Extract and uncompress the kernel image if necessary
-if [ -z $ISCOMP ]
-then
- TMPFILE="/tmp/`basename $image`.vmlin.$PID"
- dd if=$image bs=1 skip=`binoffset $image $GZHDR` 2> /dev/null | zcat > $TMPFILE
-else
- TMPFILE=$image
+# 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
-
-# Look for strings.
-strings $TMPFILE | grep "CONFIG_BEGIN=n" > /dev/null
-if [ $? -eq 0 ]
-then
- strings $TMPFILE | awk "/CONFIG_BEGIN=n/,/CONFIG_END=n/" > $image.oldconfig.$PID
-else
- echo "ERROR: Unable to extract kernel configuration information."
- echo " This kernel image may not have the config info."
- clean_up
- exit 1
+if [ "$off" -eq "0" ]; then
+ zcat <"$image" >"$TMPFILE"
+ dump_config "$TMPFILE"
+elif [ "$off" -ne "-1" ]; then
+ (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
+ zcat >"$TMPFILE"
+ dump_config "$TMPFILE"
fi
-echo "Kernel configuration written to $image.oldconfig.$PID"
+echo "ERROR: Unable to extract kernel configuration information."
+echo " This kernel image may not have the config info."
+
clean_up
-exit 0
+exit 1
diff --git a/scripts/mkconfigs b/scripts/mkconfigs
index a3166274ebc3..abf711d367ae 100755
--- a/scripts/mkconfigs
+++ b/scripts/mkconfigs
@@ -34,10 +34,10 @@ fi
config=$1
makefile=$2
-echo "#ifndef _IKCONFIG_H"
-echo "#define _IKCONFIG_H"
-echo \
-"/*
+cat << EOF
+#ifndef _IKCONFIG_H
+#define _IKCONFIG_H
+/*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -58,10 +58,10 @@ echo \
*
* This file is generated automatically by scripts/mkconfigs. Do not edit.
*
- */"
-
-echo "static char const ikconfig_config[] __attribute__((unused)) = "
-echo "\"CONFIG_BEGIN=n\\n\\"
-echo "`cat $config | sed 's/\"/\\\\\"/g' | grep "^#\? \?CONFIG_" | awk '{ print $0 "\\\\n\\\\" }' `"
-echo "CONFIG_END=n\\n\";"
-echo "#endif /* _IKCONFIG_H */"
+ */
+static char const ikconfig_config[] __attribute__((unused)) =
+"CONFIG_BEGIN=n\\n\\
+$(sed < $config -n 's/"/\\"/g;/^#\? \?CONFIG_/s/.*/&\\n\\/p')
+CONFIG_END=n\\n";
+#endif /* _IKCONFIG_H */
+EOF