Subject: Re: proposed mods to config(8) and the kernel build process
To: Luke Mewburn <lukem@wasabisystems.com>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 12/12/2000 03:15:29
>b) Store a copy of the kernel's config file in the kernel itself,
> in a manner that's easily extractable by a user.
>
> My initial experiments were to add something like the following to
> vers.c (with `"' and `\' appropriately \-quoted):
>
> #ifdef STORE_CONFIG
> const char kernel_config[] = "
> # $NetBSD: GENERIC,v 1.381 2000/11/28 19:44:07 augustss Exp $
> #
> # GENERIC -- everything that's currently supported
> #
> [...]
> # mouse & keyboard multiplexor pseudo-devices
> pseudo-device wsmux 2
> ";
> #endif /* STORE_CONFIG */
>
> That way you'd only get the config file compiled in if you asked for it,
> which possibly could be the default. It's ~ 25K extra on a 3000K i386
> GENERIC kernel.
>
> I'm not 100% sure of the easiest way to extract this info though;
> using gdb and 'print kernel_config' displays the LFs as the literal
> \n.
freebsd has done this for as long as i can remember...not that i
remember *that* far back. :)
their method is like this:
* add 'options INCLUDE_CONFIG_FILE' to your kernel config
* config makes two files for this: config.c and opt_config.h
* opt_config.h #defines INCLUDE_CONFIG_FILE
* config.c looks like this:
#include "opt_config.h"
#ifdef INCLUDE_CONFIG_FILE
static const char config[] = "\
START CONFIG FILE <config name>\n\
___#\n\
...(thus continues the config file, with each line indented with ___)
___\n\
END CONFIG FILE <config name>\n\
";
#endif /* INCLUDE_CONFIG_FILE */
the symbol is a static, so you can't "print" it (easily) via gdb or
ddb, but you can easily do this:
# strings /kernel | sed -n s/^___//p > configfile
to extract a copy. a sysctl to extract it should also be easy.
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."