Subject: Re: Allow config extract embedded configuration files
To: Frederick Bruckman <>
From: Greywolf <>
List: tech-userlevel
Date: 04/14/2003 10:46:41
Thus spake Frederick Bruckman ("FB> ") and Ross Patterson ("RP> ")
sometime Today...

FB> Clearly, we need something like (config -x). Otherwise, what's the point
FB> of embedding the file? I'd find it more useful if it could recover the
FB> original file, to update it for newer sources or to tweak it, than to
FB> configure with the live kernel directly, though.

RP> ... somebody has a string starting "_CFG_" that isn't config data, etc.),

Now that's just asking for trouble in the first place.

RP> .... although it doesn't help in the not-running case.
RP> I know Linux examples often aren't well-regarded, but in this case it
RP> looks like they've got a good one to offer.  Perhaps NetBSD should have
RP> a /kern/config that can just be read to get the current configuration?

FB> "/kern" isn't well-regarded either, so it would probably be OK. ;-)

Or you can do what I did and just write a SLSS to handle it as described
in the man page...
[note: I probably spent too much time writing this, but if anyone else
finds it useful, have at.]

#! /bin/sh -
# xkconf - extract kernel config.
# usage: kxconf [ kernel [ outfile ] ]

kver=`uname -v | awk -F/ '{print $NF}'`;


test -f $kernel || {
    echo "FATAL: Cannot open $kernel; exiting." >&2;
    exit 1;

:>$output 2>/dev/null || {
    echo "WARNING:  Cannot write $output; using temporary file" >&2;
    tmp=`mktemp -t ${kver}` || {
        echo "FATAL:  Cannot create temporary file; exiting." >&2;
	exit 2;

test -f ${kernel} && {
	strings ${kernel} | sed -n 's/^_CFG_//p' | unvis > ${output} &&
	echo "Output is in ${output}";
} || {
    echo "FATAL: No output written to ${output}" >&2;
    exit 1;


Instead of asking why a piece of software is using "1970s technology",
start asking why software is ignoring 30 years of accumulated wisdom.