diff -u --new-file --recursive linux/Documentation/Configure.help linux.hacked/Documentation/Configure.help
--- linux/Documentation/Configure.help	Thu Nov 15 19:29:01 2001
+++ linux.hacked/Documentation/Configure.help	Wed Nov 14 20:24:05 2001
@@ -13889,6 +13889,18 @@
   This option will enlarge your kernel by about 67 KB. Several
   programs depend on this, so everyone should say Y here.
 
+/proc/kconfig
+CONFIG_PROC_KCONFIG
+  This adds a file to the /proc filesystem, which when read returns a
+  copy of the configuration used to build the kernel.  This is generated
+  from the .config in the Linux source tree.
+
+  To rebuild the kernel with that configuration simply do the following
+  from inside your source tree:
+  	$ cat /proc/kconfig > .config
+  	$ make oldconfig
+  There you go the source tree is configured like the current kernel.
+
 Support for PReP Residual Data
 CONFIG_PREP_RESIDUAL
   Some PReP systems have residual data passed to the kernel by the
diff -u --new-file --recursive linux/Makefile linux.hacked/Makefile
--- linux/Makefile	Thu Nov 15 19:29:19 2001
+++ linux.hacked/Makefile	Thu Nov 15 19:33:07 2001
@@ -239,6 +239,7 @@
 	.menuconfig.log \
 	include/asm \
 	.hdepend scripts/mkdep scripts/split-include scripts/docproc \
+	$(TOPDIR)/include/linux/kconfig.h \
 	$(TOPDIR)/include/linux/modversions.h \
 	kernel.spec
 
@@ -474,6 +475,10 @@
 MODVERFILE :=
 endif
 export	MODVERFILE
+
+ifdef CONFIG_PROC_KCONFIG
+$(shell $(TOPDIR)/scripts/mkkconfigh $(TOPDIR))
+endif
 
 depend dep: dep-files
 
diff -u --new-file --recursive linux/fs/Config.in linux.hacked/fs/Config.in
--- linux/fs/Config.in	Thu Nov 15 19:29:06 2001
+++ linux.hacked/fs/Config.in	Wed Nov 14 20:15:26 2001
@@ -60,6 +60,7 @@
 tristate 'OS/2 HPFS file system support' CONFIG_HPFS_FS
 
 bool '/proc file system support' CONFIG_PROC_FS
+dep_bool '  Kernel configuration file in /proc' CONFIG_PROC_KCONFIG $CONFIG_PROC_FS
 
 dep_bool '/dev file system support (EXPERIMENTAL)' CONFIG_DEVFS_FS $CONFIG_EXPERIMENTAL
 dep_bool '  Automatically mount at boot' CONFIG_DEVFS_MOUNT $CONFIG_DEVFS_FS
diff -u --new-file --recursive linux/fs/proc/proc_misc.c linux.hacked/fs/proc/proc_misc.c
--- linux/fs/proc/proc_misc.c	Thu Nov 15 19:29:20 2001
+++ linux.hacked/fs/proc/proc_misc.c	Thu Nov 15 19:12:42 2001
@@ -40,6 +40,9 @@
 #include <asm/pgtable.h>
 #include <asm/io.h>
 
+#ifdef CONFIG_PROC_KCONFIG
+#include <linux/kconfig.h>
+#endif
 
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
@@ -554,6 +557,40 @@
 	write:		write_profile,
 };
 
+#ifdef CONFIG_PROC_KCONFIG
+/*
+ * /proc/kconfig is a lean copy of the .config used to build the kernel
+ *
+ */
+static int kconfig_read_proc(char *page, char **start, off_t off, 
+					int count, int *eof, void *data) {
+	char *p = page;
+	int len     = 0;	/* code from  net/ipv4/proc.c */
+	off_t pos   = 0;
+	off_t begin = 0;
+	unsigned int i;
+	
+	for (i = 0; kconfig_data[i] != NULL; ++i) {
+		p = page + len;
+		len += sprintf(p,"%s\n",kconfig_data[i]);
+		pos = begin + len;
+		if (pos < off) {
+			len = 0;
+			begin = pos;
+		}
+		pos = begin + len;
+		if (pos > off + count) {
+			break;
+		}
+	}
+	*start = page + (off - begin);
+	len -= (off - begin);
+	if (len > count) len = count;
+	if (len < count) *eof = 1;
+	return len;
+}
+#endif
+
 struct proc_dir_entry *proc_root_kcore;
 
 void __init proc_misc_init(void)
@@ -601,6 +638,9 @@
 		{"swaps",	swaps_read_proc},
 		{"iomem",	memory_read_proc},
 		{"execdomains",	execdomains_read_proc},
+#ifdef CONFIG_PROC_KCONFIG
+                {"kconfig",     kconfig_read_proc},
+#endif
 		{NULL,}
 	};
 	for (p = simple_ones; p->name; p++)
diff -u --new-file --recursive linux/scripts/mkkconfigh linux.hacked/scripts/mkkconfigh
--- linux/scripts/mkkconfigh	Thu Jan  1 01:00:00 1970
+++ linux.hacked/scripts/mkkconfigh	Thu Nov 15 19:05:21 2001
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+# Takes path of the kernel sources and turns .config into an .h file
+# for use with CONFIG_PROC_KCONFIG.
+
+$src = '.config';
+$dst = 'include/linux/kconfig.h';
+
+$path = shift;
+
+open(OUT,">$path/$dst");
+open(IN,"$path/$src");
+
+print OUT "const char *kconfig_data[] = {\n";
+while($line = <IN>) {
+	chomp($line);
+	if($line !~ /^#/ && length($line) > 1) {
+		$line =~ s/"/\\"/g;
+		print OUT "\t\"$line\",\n";
+	}
+}
+print OUT "\tNULL\n";
+print OUT "};\n";
+
+close(OUT);
+close(IN);
