mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 22:40:51 +07:00
7b76bfc867
I've rewritten the extract-ikconfig script to extract the kernel configuration from a kernel compiled with CONFIG_IKCONFIG. The main motivation for the rewrite was to remove the dependency on the external C program binoffset.c, which is compiled on the initial run. The binoffset executable is invoked with a relative path, which means that the old script can only be run from the top of the kernel tree, and only when you have write permission in the scripts directory. The new script uses tr/grep/tail/zcat only, and can be invoked from anywhere. The binoffset.c program has been removed. This script requires GNU grep 2.5 (released 2002-03-13) or higher, because the -o option was introduced in that version. Signed-off-by: Dick Streefland <dick@streefland.net> LKML-Reference: <20091006203540.GA14634@streefland.net> Tested-by: Steven Rostedt <rostedt@goodmis.org> Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
54 lines
1.3 KiB
Bash
Executable File
54 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# ----------------------------------------------------------------------
|
|
# extract-ikconfig - Extract the .config file from a kernel image
|
|
#
|
|
# This will only work when the kernel was compiled with CONFIG_IKCONFIG.
|
|
#
|
|
# The obscure use of the "tr" filter is to work around older versions of
|
|
# "grep" that report the byte offset of the line instead of the pattern.
|
|
#
|
|
# (c) 2009, Dick Streefland <dick@streefland.net>
|
|
# Licensed under the terms of the GNU General Public License.
|
|
# ----------------------------------------------------------------------
|
|
|
|
gz1='\037\213\010'
|
|
gz2='01'
|
|
cf1='IKCFG_ST\037\213\010'
|
|
cf2='0123456789'
|
|
|
|
dump_config()
|
|
{
|
|
if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
|
|
then
|
|
pos=${pos%%:*}
|
|
tail -c+$(($pos+8)) "$1" | zcat -q
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
# Check invocation:
|
|
me=${0##*/}
|
|
img=$1
|
|
if [ $# -ne 1 -o ! -s "$img" ]
|
|
then
|
|
echo "Usage: $me <kernel-image>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
# Initial attempt for uncompressed images or objects:
|
|
dump_config "$img"
|
|
|
|
# That didn't work, so decompress and try again:
|
|
tmp=/tmp/ikconfig$$
|
|
trap "rm -f $tmp" 0
|
|
for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"`
|
|
do
|
|
pos=${pos%%:*}
|
|
tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
|
|
dump_config $tmp
|
|
done
|
|
|
|
# Bail out:
|
|
echo "$me: Cannot find kernel config." >&2
|
|
exit 1
|