Added new kernel source file 'config.c'. This file is generated by config(8),
authorPoul-Henning Kamp <phk@FreeBSD.org>
Wed, 1 Jun 1994 09:50:09 +0000 (09:50 +0000)
committerPoul-Henning Kamp <phk@FreeBSD.org>
Wed, 1 Jun 1994 09:50:09 +0000 (09:50 +0000)
and contains the text of the file input to config(8).  This allows you to
retreive from a binary kernel, using strings(1), the name of the file used,
and the contents of it.  The delta in kernel size is in the order of 2k.  This
file is put right after locore, so that we don't get too much garbage in
strings before the stuff we want.

*** YOU NEED TO RECOMPILE config(8) ***

Pyramids had something like this too.

sys/i386/conf/Makefile.i386
usr.sbin/config/config.8
usr.sbin/config/main.c

index db28a34..b4f8cbf 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1990 W. Jolitz
 #      from: @(#)Makefile.i386 7.1 5/10/91
 # Copyright 1990 W. Jolitz
 #      from: @(#)Makefile.i386 7.1 5/10/91
-#      $Id: Makefile.i386,v 1.23 1994/03/21 20:48:47 ats Exp $
+#      $Id: Makefile.i386,v 1.24 1994/04/02 07:00:12 davidg Exp $
 #
 # Makefile for FreeBSD
 #
 #
 # Makefile for FreeBSD
 #
@@ -51,7 +51,7 @@ NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
 NORMAL_S= ${CPP} -I. -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
 DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
 DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
 NORMAL_S= ${CPP} -I. -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
 DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
 DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
-SYSTEM_OBJS=locore.o exception.o swtch.o support.o ${OBJS} param.o \
+SYSTEM_OBJS=locore.o config.o exception.o swtch.o support.o ${OBJS} param.o \
        ioconf.o conf.o machdep.o
 SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS}
 SYSTEM_LD_HEAD=        @echo loading $@; rm -f $@
        ioconf.o conf.o machdep.o
 SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS}
 SYSTEM_LD_HEAD=        @echo loading $@; rm -f $@
index 1712217..77fc9ee 100644 (file)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)config.8     6.5 (Berkeley) 3/16/91
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)config.8     6.5 (Berkeley) 3/16/91
-.\"    $Id: config.8,v 1.6 1993/08/07 07:53:27 cgd Exp $
+.\"    $Id: config.8,v 1.2 1993/09/26 23:11:06 rgrimes Exp $
 .\"
 .Dd March 16, 1991
 .Dt CONFIG 8
 .\"
 .Dd March 16, 1991
 .Dt CONFIG 8
@@ -133,6 +133,10 @@ the problems in the configuration file should be corrected and
 should be run again.
 Attempts to compile a system that had configuration errors
 are likely to fail.
 should be run again.
 Attempts to compile a system that had configuration errors
 are likely to fail.
+.Pp
+The entire input file is embedded in the new kernel.  This means that
+.Xr strings 1
+can be used to extract it from a kernel.
 .Sh FILES
 .Bl -tag -width /sys/i386/conf/Makefile.i386 -compact
 .It Pa /sys/conf/files
 .Sh FILES
 .Bl -tag -width /sys/i386/conf/Makefile.i386 -compact
 .It Pa /sys/conf/files
index 2ea5c3d..93c089b 100644 (file)
@@ -146,6 +146,7 @@ usage:              fputs("usage: config [-gp] sysname\n", stderr);
        makefile();                     /* build Makefile */
        headers();                      /* make a lot of .h files */
        swapconf();                     /* swap config files */
        makefile();                     /* build Makefile */
        headers();                      /* make a lot of .h files */
        swapconf();                     /* swap config files */
+       configfile();                   /* add config file into kernel */
        printf("Don't forget to run \"make depend\"\n");
        exit(0);
 }
        printf("Don't forget to run \"make depend\"\n");
        exit(0);
 }
@@ -256,3 +257,39 @@ path(file)
        }
        return (cp);
 }
        }
        return (cp);
 }
+
+
+configfile()
+{
+       FILE *fi, *fo;
+       char *p;
+       int i;
+       
+       fi = fopen(PREFIX,"r");
+       if(!fi) {
+               perror(PREFIX);
+               exit(2);
+       }
+       fo = fopen(p=path("config.c"),"w");
+       if(!fo) {
+               perror(p);
+               exit(2);
+       }
+       fprintf(fo,"static char *config = \"\n");
+       fprintf(fo,"START CONFIG FILE %s\n___",PREFIX);
+       while (EOF != (i=getc(fi))) {
+               if(i == '\n') {
+                       fprintf(fo,"\n___");
+               } else if(i == '\"') {
+                       fprintf(fo,"\\\"");
+               } else if(i == '\\') {
+                       fprintf(fo,"\\\\");
+               } else {
+                       putc(i,fo);
+               }
+       }
+       fprintf(fo,"\nEND CONFIG FILE %s\n",PREFIX);
+       fprintf(fo,"\";\n");
+       fclose(fi);
+       fclose(fo);
+}