Messages in this thread Patch in this message | | | From | "Peter T. Breuer" <> | Subject | Re: [EXAMPLE-PATCH] /proc/config | Date | Mon, 1 Jun 1998 21:08:36 +0200 (MET DST) |
| |
Here is the definitive version of the 2.0.* patch of the moment. Whilst the code has always been fine, my construction of the patch has at times been wayward because I've had lots of interrupts (like having to run to the theatre).
This corrects my omission last time (1) of a change in scripts/configure to support the -di (ignore the user entirely) option while doing a make, something that nobody noticed was absent since it only affects the new make cloneconfig thing, which I don't like anyway, and (2) my forgetting to put the linkage of config.o in ifdefs. Goodness knows what I forgot this time!
The patch is originally from N.J. Leon for 2.1.*. Pester him for that. This is the 2.0.* trivial port of that.
Peter
--- /usr/src/linux-2.0.25/fs/proc/array.c.pre-proc-config Sun May 31 01:11:30 1998 +++ /usr/src/linux-2.0.25/fs/proc/array.c Sun May 31 15:03:10 1998 @@ -998,6 +998,7 @@ extern int get_md_status (char *); extern int get_rtc_status (char *); extern int get_locks_status (char *); +extern int get_proc_config (char *); #ifdef __SMP_PROF__ extern int get_smp_prof_list(char *); #endif @@ -1074,6 +1075,12 @@ #endif case PROC_LOCKS: return get_locks_status(page); + +#ifdef CONFIG_PROC_CONFIG + case PROC_CONFIG: + return get_proc_config(page); +#endif + } return -EBADF; } --- /usr/src/linux-2.0.25/fs/proc/root.c.pre-proc-config Sun May 31 01:15:39 1998 +++ /usr/src/linux-2.0.25/fs/proc/root.c Sun May 31 15:03:56 1998 @@ -382,8 +382,17 @@ S_IFREG | S_IRUGO, 1, 0, 0, }); - proc_register( &proc_root, &(struct proc_dir_entry) - { PROC_MTAB, 6, "mounts", S_IFREG | S_IRUGO, 1, 0, 0, } ); + proc_register( &proc_root, &(struct proc_dir_entry) { + PROC_MTAB, 6, "mounts", + S_IFREG | S_IRUGO, 1, 0, 0, + } ); + +#ifdef CONFIG_PROC_CONFIG + proc_register(&proc_root, &(struct proc_dir_entry) { + PROC_CONFIG, 9, "config.gz", + S_IFREG | S_IRUGO, 1, 0, 0, + }); +#endif if (prof_shift) { proc_register(&proc_root, &(struct proc_dir_entry) { --- /usr/src/linux-2.0.25/fs/Config.in.pre-proc-config Sun May 31 15:19:41 1998 +++ /usr/src/linux-2.0.25/fs/Config.in Sun May 31 15:21:37 1998 @@ -91,6 +91,10 @@ dep_tristate 'ISO9660 cdrom filesystem support' CONFIG_ISO9660_FS $CONFIG_NLS bool '/proc filesystem support' CONFIG_PROC_FS +if [ "$CONFIG_PROC_FS" != "n" ]; then + bool 'record current CONFIG in /proc/config.gz' CONFIG_PROC_CONFIG +fi + dep_tristate 'LM78 motherboard temperature monitor support' CONFIG_LM78 $CONFIG_PROC_FS if [ "$CONFIG_INET" = "y" ]; then tristate 'NFS filesystem support' CONFIG_NFS_FS --- /usr/src/linux-2.0.25/init/patches/proc-config.pre-proc-config Sun May 31 03:20:21 1998 +++ /usr/src/linux-2.0.25/init/patches/proc-config Sun May 31 03:21:56 1998 @@ -0,0 +1 @@ +/proc/config.gz (N.J. Leon for 2.1.104 adapted by P.T.Breuer for 2.0.25) --- /usr/src/linux-2.0.25/kernel/Makefile.pre-proc-config Sun May 31 02:15:01 1998 +++ /usr/src/linux-2.0.25/kernel/Makefile Mon Jun 1 19:42:28 1998 @@ -15,6 +15,10 @@ module.o exit.o signal.o itimer.o info.o time.o softirq.o \ resource.o sysctl.o +ifdef CONFIG_PROC_CONFIG +O_OBJS += config.o +endif + ifeq ($(CONFIG_MODULES),y) OX_OBJS = ksyms.o endif --- /usr/src/linux-2.0.25/include/linux/proc_fs.h.pre-proc-config Sun May 31 01:47:01 1998 +++ /usr/src/linux-2.0.25/include/linux/proc_fs.h Sun May 31 15:05:41 1998 @@ -45,6 +45,9 @@ PROC_MD, PROC_RTC, PROC_LOCKS +#ifdef CONFIG_PROC_CONFIG + ,PROC_CONFIG +#endif }; enum pid_directory_inos { --- /usr/src/linux-2.0.25/scripts/Makefile.pre-proc-config Sun May 31 02:10:15 1998 +++ /usr/src/linux-2.0.25/scripts/Makefile Sun May 31 11:35:19 1998 @@ -44,7 +44,10 @@ tkgen.o: tkgen.c tkparse.h $(HOSTCC) $(HOSTCFLAGS) -c -o tkgen.o tkgen.c +makeproconfig: makeproconfig.c + $(CC) makeproconfig.c -o makeproconfig + clean: - rm -f *~ kconfig.tk *.o tkparse + rm -f *~ kconfig.tk *.o tkparse makeproconfig include $(TOPDIR)/Rules.make --- /usr/src/linux-2.0.25/scripts/makeproconfig.sh.pre-proc-config Sun May 31 02:01:52 1998 +++ /usr/src/linux-2.0.25/scripts/makeproconfig.sh Mon Jun 1 20:42:40 1998 @@ -0,0 +1,27 @@ +#!/bin/sh + +# make a suitable kernel/config.c file + +# headers +cat -<<EOT +#include <linux/config.h> +#include <linux/version.h> +#include <linux/malloc.h> +#include <linux/unistd.h> + +EOT + +# a "ucTable" +cat $TOPDIR/.config | grep '^CONFIG' | sed 's/CONFIG_//' | gzip -9c | \ + od -v -t x1 -w8 | sed -e '/^[^ ]*$/d' | cut -d' ' -f 2- | \ + ( echo "unsigned char ucTable[]= {"; sed -e 's/[^ ][^ ]*/ 0x&,/g' ; echo "};" ) + +# finally, what to return when get_proc_config is called +cat -<<EOT + +int get_proc_config(char *page) { + memcpy(page,ucTable,sizeof(ucTable)); + return sizeof(ucTable); +} + +EOT --- /usr/src/linux-2.0.25/scripts/Configure.pre-proc-config Sun May 31 02:21:28 1998 +++ /usr/src/linux-2.0.25/scripts/Configure Sun May 31 02:26:03 1998 @@ -107,14 +107,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 } @@ -426,6 +431,10 @@ DEFAULT="" if [ "$1" = "-d" ] ; then DEFAULT="-d" + shift +fi +if [ "$1" = "-di" ] ; then + DEFAULT="-di" shift fi --- /usr/src/linux-2.0.25/Documentation/Configure.help.pre-proc-config Sun May 31 15:23:51 1998 +++ /usr/src/linux-2.0.25/Documentation/Configure.help Sun May 31 15:27:32 1998 @@ -3406,6 +3406,14 @@ source of trouble if two devices are mistakenly configured to use the same IRQ). 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 you build. This is extremely useful if you ever + build more than one kernel. The cost is about 1K-4K of running + memory. Only say no if you really can't spare it. You can sneeze + and lose out on more memory than this. TCFS filesystem support HAVE_TCFS --- /usr/src/linux-2.0.25/Makefile.pre-proc-config Sun May 31 01:49:13 1998 +++ /usr/src/linux-2.0.25/Makefile Mon Jun 1 20:41:23 1998 @@ -190,19 +190,38 @@ rm -f include/asm ( cd include ; ln -sf asm-$(ARCH) asm) +proconfig: $(TOPDIR)/kernel/config.c + +$(TOPDIR)/kernel/config.c: dummy + $(CONFIG_SHELL) scripts/makeproconfig.sh > $(TOPDIR)/kernel/config.c + oldconfig: symlinks $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in + $(MAKE) -s proconfig xconfig: symlinks $(MAKE) -C scripts kconfig.tk wish -f scripts/kconfig.tk + $(MAKE) -s proconfig menuconfig: include/linux/version.h symlinks $(MAKE) -C scripts/lxdialog all $(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in + $(MAKE) -s proconfig config: symlinks $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in + $(MAKE) -s proconfig + +cloneconfig: symlinks + @if [ -f "/proc/config.gz" ]; then \ + rm -f .config; \ + cat /proc/config.gz | gzip -dc | sed 's/^/CONFIG_/' >> .config; \ + $(CONFIG_SHELL) scripts/Configure -di arch/$(ARCH)/config.in; \ + $(MAKE) -s proconfig; \ + else \ + echo "Your current kernel does not support cloning."; \ + fi linuxsubdirs: dummy set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done @@ -376,7 +395,7 @@ rm -f drivers/scsi/aic7xxx_asm drivers/scsi/aic7xxx_seq.h rm -f drivers/char/uni_hash.tbl drivers/char/conmakehash 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 .menuconfig.log rm -f include/asm - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |