Messages in this thread Patch in this message | | | Date | Thu, 14 Jan 1999 20:44:52 -0500 (EST) | From | "Nicholas J. Leon" <> | Subject | [PATCH] Re: Building .config into the kernel |
| |
On Fri, 15 Jan 1999, Peter T. Breuer wrote:
For everyone's reviewing pleasure, here's an update of my /proc/config.gz patch I did a year ago. It increased my kernel size by:
-rw-r--r-- 1 root root 478800 Jan 14 20:30 bz-config -rw-r--r-- 1 root root 477843 Jan 13 20:53 bzImage-standard
957 bytes (if I can subtract correctly).
It makes /proc/config.gz a configurable option (as it should be), and adds a makefile entry for "cloneconfig" which will take the contents of /proc/config.gz and put it back into .config[1].
[1] Problem #1, if you do a "make oldconfig" after this, it will stop at each and every CONFIG_ option that should be "N". That's because the newly created .config does NOT have the # CONFIG_FOO is not set lines in it.
G'day! -- n i c h o l a s j l e o n elegance through simplicity*http://mrnick.binary9.net*nicholas@binary9.net good fortune through truth*roaming:njllm@email.msn.com*ICQ#2170994*U+($++) TRA#6805*not all questions have answers*pseudogeek:P+++($++)L+($++)W=lm@b9 trust no-one with an iq under 150*understand yourself before trying others diff -Nur linux/Documentation/Configure.help linux.c/Documentation/Configure.help --- linux/Documentation/Configure.help Wed Jan 13 20:36:56 1999 +++ linux.c/Documentation/Configure.help Thu Jan 14 20:18:47 1999 @@ -6810,6 +6810,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/Makefile linux.c/Makefile --- linux/Makefile Wed Jan 13 20:39:43 1999 +++ linux.c/Makefile Thu Jan 14 20:40:18 1999 @@ -221,11 +221,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 @@ -233,6 +240,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 @@ -240,12 +248,26 @@ 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; \ + 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: $(patsubst %, _dir_%, $(SUBDIRS)) @@ -373,7 +395,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/fs/Config.in linux.c/fs/Config.in --- linux/fs/Config.in Mon Jan 4 15:05:11 1999 +++ linux.c/fs/Config.in Thu Jan 14 20:22:37 1999 @@ -34,6 +34,9 @@ fi tristate 'OS/2 HPFS filesystem support (read only)' CONFIG_HPFS_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_UNIX98_PTYS" = "y" ]; then tristate '/dev/pts filesystem for Unix98 PTYs' CONFIG_DEVPTS_FS fi diff -Nur linux/fs/proc/array.c linux.c/fs/proc/array.c --- linux/fs/proc/array.c Wed Jan 13 20:36:56 1999 +++ linux.c/fs/proc/array.c Thu Jan 14 20:27:28 1999 @@ -1243,6 +1243,9 @@ extern int get_swaparea_info (char *); extern int get_hardware_list(char *); extern int get_stram_list(char *); +#ifdef CONFIG_PROC_CONFIG +extern int get_proc_config(char *); +#endif static long get_root_array(char * page, int type, char **start, off_t offset, unsigned long length) @@ -1335,6 +1338,11 @@ case PROC_STRAM: return get_stram_list(page); #endif +#ifdef CONFIG_PROC_CONFIG + case PROC_CONFIG: + return get_proc_config(page); +#endif + } return -EBADF; } diff -Nur linux/fs/proc/root.c linux.c/fs/proc/root.c --- linux/fs/proc/root.c Wed Jan 13 20:36:56 1999 +++ linux.c/fs/proc/root.c Thu Jan 14 20:21:09 1999 @@ -641,6 +641,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 __initfunc(void proc_root_init(void)) { @@ -714,7 +721,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/include/linux/proc_fs.h linux.c/include/linux/proc_fs.h --- linux/include/linux/proc_fs.h Wed Jan 13 20:46:06 1999 +++ linux.c/include/linux/proc_fs.h Thu Jan 14 20:25:45 1999 @@ -52,6 +52,9 @@ PROC_STRAM, PROC_SOUND, PROC_MTRR, /* whether enabled or not */ +#ifdef CONFIG_PROC_CONFIG + PROC_CONFIG, +#endif PROC_FS }; diff -Nur linux/kernel/Makefile linux.c/kernel/Makefile --- linux/kernel/Makefile Wed May 6 14:01:46 1998 +++ linux.c/kernel/Makefile Thu Jan 14 20:18:47 1999 @@ -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/scripts/makeproconfig.sh linux.c/scripts/makeproconfig.sh --- linux/scripts/makeproconfig.sh Wed Dec 31 19:00:00 1969 +++ linux.c/scripts/makeproconfig.sh Thu Jan 14 20:18:47 1999 @@ -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 | |