[PATCH] /proc/config.gz V0.3

nicholas@binary9.net
Sun, 31 May 1998 12:48:30 -0400 (EDT)


Alrighty folks -

Here is version 0.3 of my /proc/config.gz implementation. Thanks to the
input from several very helpful people, I've made a few changes. I've now
made it a configurable item (CONFIG_PROC_CONFIG), though I did make it
default to "Y" for all architectures.

The makehexhash.c program has been replaced with an od|sed pipe in the
shell script that generates the kernel/config.c
(scripts/makeproconfig.sh).

During the generation of config.c, I do a quick test to verify that the
compressed .config is less than 4K in size.

As always, input is welcome!

diff -Nur linux.104-prist/Documentation/Configure.help linux.104-config/Documentation/Configure.help
--- linux.104-prist/Documentation/Configure.help Thu May 28 11:18:37 1998
+++ linux.104-config/Documentation/Configure.help Sun May 31 12:35:14 1998
@@ -5748,6 +5748,14 @@
18 kB. Several programs depend on this, so everyone should say Y
here.

+/proc/config.gz support
+CONFIG_PROC_CONFIG
+ Say Y here if you want a copy of your current kernel configuration
+ saved in the kernel that you build. This is extremely useful if you
+ ever build more than one kernel. The cost is around 1K-4K of running
+ memory. Only say no if you really can't spare this. You can sneeze
+ and lose more on memory than this.
+
NFS filesystem support
CONFIG_NFS_FS
If you are connected to some other (usually local) Unix computer
diff -Nur linux.104-prist/Makefile linux.104-config/Makefile
--- linux.104-prist/Makefile Sat May 30 14:30:06 1998
+++ linux.104-config/Makefile Sun May 31 12:34:09 1998
@@ -197,11 +197,18 @@
mkdir include/linux/modules; \
fi

+proconfig: $(TOPDIR)/kernel/config.c
+
+
+$(TOPDIR)/kernel/config.c:
+ $(CONFIG_SHELL) scripts/makeproconfig.sh > $(TOPDIR)/kernel/config.c
+
oldconfig: symlinks scripts/split-include
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
if [ -r include/linux/autoconf.h ]; then \
scripts/split-include include/linux/autoconf.h include/config; \
fi
+ $(MAKE) proconfig

xconfig: symlinks scripts/split-include
$(MAKE) -C scripts kconfig.tk
@@ -209,6 +216,7 @@
if [ -r include/linux/autoconf.h ]; then \
scripts/split-include include/linux/autoconf.h include/config; \
fi
+ $(MAKE) proconfig

menuconfig: include/linux/version.h symlinks scripts/split-include
$(MAKE) -C scripts/lxdialog all
@@ -216,12 +224,27 @@
if [ -r include/linux/autoconf.h ]; then \
scripts/split-include include/linux/autoconf.h include/config; \
fi
+ $(MAKE) proconfig

config: symlinks scripts/split-include
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
if [ -r include/linux/autoconf.h ]; then \
scripts/split-include include/linux/autoconf.h include/config; \
fi
+ $(MAKE) proconfig
+
+cloneconfig: symlinks scripts/split-include
+ @if [ -f "/proc/config.gz" ]; then \
+ mv -f .config .config.bak; \
+ cat /proc/config.gz | gzip -dc | sed 's/^/CONFIG_/' >> .config; \
+ $(CONFIG_SHELL) scripts/Configure -di arch/$(ARCH)/config.in; \
+ if [ -r include/linux/autoconf.h ]; then \
+ scripts/split-include include/linux/autoconf.h include/config; \
+ fi; \
+ $(MAKE) proconfig; \
+ else \
+ echo "Your current kernel does not support cloning."; \
+ fi

linuxsubdirs: dummy
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
@@ -344,7 +367,7 @@
rm -f core `find . -name '.*.flags' -print`
rm -f vmlinux System.map
rm -f .tmp*
- rm -f drivers/char/consolemap_deftbl.c drivers/char/conmakehash
+ rm -f drivers/char/consolemap_deftbl.c drivers/char/conmakehash
rm -f drivers/sound/bin2hex drivers/sound/hex2hex
if [ -d modules ]; then \
rm -f core `find modules/ -type f -print`; \
@@ -360,7 +383,7 @@
rm -f drivers/char/hfmodem/gentbl drivers/char/hfmodem/tables.h
rm -f drivers/sound/*_boot.h drivers/sound/.*.boot
rm -f .version .config* config.in config.old
- rm -f scripts/tkparse scripts/kconfig.tk scripts/kconfig.tmp
+ rm -f scripts/tkparse scripts/kconfig.tk scripts/kconfig.tmp kernel/config.c
rm -f scripts/lxdialog/*.o scripts/lxdialog/lxdialog
rm -f .menuconfig.log
rm -f include/asm
diff -Nur linux.104-prist/arch/alpha/defconfig linux.104-config/arch/alpha/defconfig
--- linux.104-prist/arch/alpha/defconfig Mon Mar 30 03:21:39 1998
+++ linux.104-config/arch/alpha/defconfig Sun May 31 12:36:32 1998
@@ -234,6 +234,7 @@
# CONFIG_UMSDOS_FS is not set
# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
# CONFIG_NFSD is not set
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/arch/arm/defconfig linux.104-config/arch/arm/defconfig
--- linux.104-prist/arch/arm/defconfig Sun Apr 12 14:42:15 1998
+++ linux.104-config/arch/arm/defconfig Sun May 31 12:36:53 1998
@@ -187,6 +187,7 @@
# CONFIG_UMSDOS_FS is not set
CONFIG_VFAT_FS=y
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
CONFIG_NFSD=y
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/arch/i386/defconfig linux.104-config/arch/i386/defconfig
--- linux.104-prist/arch/i386/defconfig Thu May 14 13:43:36 1998
+++ linux.104-config/arch/i386/defconfig Sun May 31 12:36:29 1998
@@ -228,6 +228,7 @@
# CONFIG_UMSDOS_FS is not set
# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
CONFIG_NFSD=y
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/arch/m68k/defconfig linux.104-config/arch/m68k/defconfig
--- linux.104-prist/arch/m68k/defconfig Tue Mar 10 17:43:13 1998
+++ linux.104-config/arch/m68k/defconfig Sun May 31 12:36:45 1998
@@ -160,6 +160,7 @@
# CONFIG_UMSDOS_FS is not set
# CONFIG_MSDOS_PARTITION is not set
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
# CONFIG_ROOT_NFS is not set
# CONFIG_SMB_FS is not set
diff -Nur linux.104-prist/arch/mips/defconfig linux.104-config/arch/mips/defconfig
--- linux.104-prist/arch/mips/defconfig Fri May 8 03:13:23 1998
+++ linux.104-config/arch/mips/defconfig Sun May 31 12:36:40 1998
@@ -246,6 +246,7 @@
# CONFIG_UMSDOS_FS is not set
CONFIG_VFAT_FS=y
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
CONFIG_NFSD=y
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/arch/sparc/defconfig linux.104-config/arch/sparc/defconfig
--- linux.104-prist/arch/sparc/defconfig Fri May 8 03:11:28 1998
+++ linux.104-config/arch/sparc/defconfig Sun May 31 12:36:36 1998
@@ -239,6 +239,7 @@
# CONFIG_UMSDOS_FS is not set
# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
CONFIG_NFSD=m
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/arch/sparc64/defconfig linux.104-config/arch/sparc64/defconfig
--- linux.104-prist/arch/sparc64/defconfig Fri May 8 03:11:28 1998
+++ linux.104-config/arch/sparc64/defconfig Sun May 31 12:36:49 1998
@@ -248,6 +248,7 @@
# CONFIG_UMSDOS_FS is not set
# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
+CONFIG_PROC_CONFIG=y
CONFIG_NFS_FS=y
CONFIG_NFSD=m
CONFIG_SUNRPC=y
diff -Nur linux.104-prist/fs/Config.in linux.104-config/fs/Config.in
--- linux.104-prist/fs/Config.in Sat Apr 4 12:45:14 1998
+++ linux.104-config/fs/Config.in Sat May 30 23:29:43 1998
@@ -21,6 +21,10 @@
dep_tristate 'VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS

bool '/proc filesystem support' CONFIG_PROC_FS
+if [ "$CONFIG_PROC_FS" = "y" ]; then
+ bool ' /proc/config.gz (kernel configuration)' CONFIG_PROC_CONFIG
+fi
+
if [ "$CONFIG_INET" = "y" ]; then
tristate 'NFS filesystem support' CONFIG_NFS_FS
if [ "$CONFIG_NFS_FS" = "y" -a "$CONFIG_IP_PNP" = "y" ]; then
diff -Nur linux.104-prist/fs/proc/array.c linux.104-config/fs/proc/array.c
--- linux.104-prist/fs/proc/array.c Wed May 6 14:01:45 1998
+++ linux.104-config/fs/proc/array.c Sun May 31 10:50:55 1998
@@ -1200,6 +1200,7 @@
extern int get_rtc_status (char *);
extern int get_locks_status (char *, char **, off_t, int);
extern int get_swaparea_info (char *);
+extern int get_proc_config (char *);
#ifdef CONFIG_ZORRO
extern int zorro_get_list(char *);
#endif
@@ -1290,6 +1291,11 @@
case PROC_HARDWARE:
return get_hardware_list(page);
#endif
+#ifdef CONFIG_PROC_CONFIG
+ case PROC_CONFIG:
+ return get_proc_config(page);
+#endif
+
}
return -EBADF;
}
diff -Nur linux.104-prist/fs/proc/root.c linux.104-config/fs/proc/root.c
--- linux.104-prist/fs/proc/root.c Sun May 17 14:34:57 1998
+++ linux.104-config/fs/proc/root.c Sun May 31 11:13:21 1998
@@ -623,7 +623,13 @@
NULL, NULL /* parent, subdir */
};
#endif
-
+#ifdef CONFIG_PROC_CONFIG
+static struct proc_dir_entry proc_root_config = {
+ PROC_CONFIG, 9, "config.gz",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_array_inode_operations
+};
+#endif
void proc_root_init(void)
{
proc_base_init();
@@ -694,7 +700,9 @@
#ifdef CONFIG_PROC_DEVICETREE
proc_device_tree_init();
#endif
-
+#ifdef CONFIG_PROC_CONFIG
+ proc_register(&proc_root, &proc_root_config);
+#endif
proc_bus = create_proc_entry("bus", S_IFDIR, 0);
}

diff -Nur linux.104-prist/include/linux/proc_fs.h linux.104-config/include/linux/proc_fs.h
--- linux.104-prist/include/linux/proc_fs.h Sat May 30 22:44:14 1998
+++ linux.104-config/include/linux/proc_fs.h Sun May 31 12:08:01 1998
@@ -51,6 +51,9 @@
PROC_PPC_HTAB,
PROC_SOUND,
PROC_MTRR, /* whether enabled or not */
+#ifdef CONFIG_PROC_CONFIG
+ PROC_CONFIG,
+#endif
PROC_FS
};

diff -Nur linux.104-prist/kernel/Makefile linux.104-config/kernel/Makefile
--- linux.104-prist/kernel/Makefile Wed May 6 14:01:46 1998
+++ linux.104-config/kernel/Makefile Sun May 31 10:50:07 1998
@@ -25,6 +25,10 @@
OX_OBJS += ksyms.o
endif

+ifeq ($(CONFIG_PROC_CONFIG),y)
+O_OBJS += config.o
+endif
+
CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer

include $(TOPDIR)/Rules.make
diff -Nur linux.104-prist/scripts/Configure linux.104-config/scripts/Configure
--- linux.104-prist/scripts/Configure Sun May 3 20:52:06 1998
+++ linux.104-config/scripts/Configure Sat May 30 23:31:48 1998
@@ -120,14 +120,19 @@
# readln prompt default oldval
#
function readln () {
- if [ "$DEFAULT" = "-d" -a -n "$3" ]; then
+ if [ \( "$DEFAULT" = "-d" -o "$DEFAULT" = "-di" \) -a -n "$3" ]; then
echo "$1"
ans=$2
else
- echo -n "$1"
- [ -z "$3" ] && echo -n "(NEW) "
- IFS='@' read ans </dev/tty || exit 1
- [ -z "$ans" ] && ans=$2
+ if [ "$DEFAULT" = "-di" -a -z "$3" ]; then
+ echo "$1"
+ ans=$2
+ else
+ echo -n "$1"
+ [ -z "$3" ] && echo -n "(NEW) "
+ IFS='@' read ans </dev/tty || exit 1
+ [ -z "$ans" ] && ans=$2
+ fi
fi
}

@@ -488,6 +493,10 @@
DEFAULT=""
if [ "$1" = "-d" ] ; then
DEFAULT="-d"
+ shift
+fi
+if [ "$1" = "-di" ] ; then
+ DEFAULT="-di"
shift
fi

diff -Nur linux.104-prist/scripts/Makefile linux.104-config/scripts/Makefile
--- linux.104-prist/scripts/Makefile Mon Jan 5 04:41:01 1998
+++ linux.104-config/scripts/Makefile Sun May 31 10:36:48 1998
@@ -34,6 +34,6 @@
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ $(@:.o=.c)

clean:
- rm -f *~ kconfig.tk *.o tkparse mkdep split-include
+ rm -f *~ kconfig.tk *.o tkparse mkdep split-include

include $(TOPDIR)/Rules.make
diff -Nur linux.104-prist/scripts/makeproconfig.sh linux.104-config/scripts/makeproconfig.sh
--- linux.104-prist/scripts/makeproconfig.sh Wed Dec 31 19:00:00 1969
+++ linux.104-config/scripts/makeproconfig.sh Sun May 31 12:02:34 1998
@@ -0,0 +1,54 @@
+#!/bin/sh
+##############################################################################
+# <author> Nicholas J. Leon
+# <email> nicholas@binary9.net
+# <date> May 31 1998
+# <partof> CONFIG_PROC_CONFIG
+# <version> 0.3
+#
+# with help from Peter T. Breuer <ptb@it.uc3m.es>
+#
+##############################################################################
+# generates $TOPDIR/kernel/config.c which contains the current .config file
+# file in gzip compressed format.
+
+tmpfile=/tmp/.mpc.$$
+
+cat $TOPDIR/.config | grep '^CONFIG' | sed 's/CONFIG_//' | gzip -9c > $tmpfile
+
+if [ `cat $tmpfile | wc -c` -gt 4000 ]; then
+ echo "Your compressed configuration exceeds ~4K! It is not possible"
+ echo "to store it in this kernel."
+ rm -f $tmpfile
+ exit 100
+fi
+
+echo '/*'
+echo ' Autogenerated file by' $0
+echo ' On' `date` 'by' $USER "from $TOPDIR/.config"
+echo ' */'
+echo ''
+
+cat -<<EOT
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/malloc.h>
+#include <linux/unistd.h>
+
+EOT
+
+
+cat $tmpfile | od -v -tx1 -w10 | cut -d' ' -f2- | sed -e '/^[^ ]*$/d' | ( echo "unsigned char ucTable[]= {"; \
+ sed -e 's/[^ ][^ ]*/ 0x&,/g' ; echo "};" )
+
+
+cat -<<EOT
+
+int get_proc_config(char *page) {
+ memcpy(page,ucTable,sizeof(ucTable));
+ return sizeof(ucTable);
+}
+
+EOT
+
+rm -f $tmpfile

.............................................................................
..nicholas j. leon..........mrnick.binary9.net.........nicholas@binary9.net..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu