From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 26696 invoked from network); 9 Sep 1999 15:42:13 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 9 Sep 1999 15:42:13 -0000 Received: from mail13.digital.com (mail13.digital.com [192.208.46.30]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id LAA12663 for ; Thu, 9 Sep 1999 11:42:12 -0400 Received: from pdgsrv.mro.dec.com (pdgsrv.mro.dec.com [16.34.112.86]) by mail13.digital.com (8.9.2/8.9.2/WV2.0g) with ESMTP id LAA00223 for ; Thu, 9 Sep 1999 11:42:11 -0400 (EDT) Received: from linux08.mro.dec.com by pdgsrv.mro.dec.com; (8.8.8/1.1.8.2/13Dec96-1209PM) id LAA17525; Thu, 9 Sep 1999 11:42:11 -0400 (EDT) Received: (from jmartin@localhost) by linux08.mro.dec.com (8.9.3/8.9.3) id LAA12759; Thu, 9 Sep 1999 11:42:09 -0400 Date: Thu, 9 Sep 1999 11:42:09 -0400 Message-Id: <199909091542.LAA12759@linux08.mro.dec.com> X-Authentication-Warning: linux08.mro.dec.com: jmartin set sender to jmartin@linux08.mro.dec.com using -f From: "Joseph A. Martin" To: axp-list@redhat.com Subject: How was this kernel built? Reply-to: Joseph.Martin@Compaq.com On Wed, Sep 08, 1999 at 04:31:37PM -0400, Eran Guendelman wrote: > In general, how do I find out the options the kernel was compiled with, > because if I have to recompile it I want to make sure I only change > this specific setting. Someone published a solution to this problem on the linux-kernel list a few weeks ago. Unfortunately, it is a prospective solution rather than a retrospective one: he proposed embedding the .config file in the /proc file system. I don't know if the idea was accepted and will appear soon or if it was rejected/ignored. As it happens, the original author beat me by a day to the same idea. Below are MY previously unpublished patches to achieve the same effect. \Joe Joseph A. Martin Joseph.Martin@Compaq.com Compaq Computer Corporation 200 Forest Street MRO1-2/K20 (508) 467-2100 Marlboro, MA 01752 U.S.A. diff -urp rth1-pre1-2.2.11/Documentation/Configure.help patch_CONFIGZ/Documentation/Configure.help --- rth1-pre1-2.2.11/Documentation/Configure.help Tue Jun 29 13:58:39 1999 +++ patch_CONFIGZ/Documentation/Configure.help Wed Jul 14 17:52:14 1999 @@ -7092,6 +7092,17 @@ CONFIG_PROC_FS This option will enlarge your kernel by about 18 KB. Several programs depend on this, so everyone should say Y here. +compressed configuration (/proc/.config.gz) +CONFIG_PROC_CONFIGZ + A compressed version of the configuration file (.config) from which + the kernel was built is placed in the /proc filesystem. One can + think of this as the rest of /proc/version. Sample usage: + "gunzip - < /proc/.config.gz | more" + + This option is useful for kernel developers and for users who need + to communicate their exact configuration to technical support. It + adds about 2 KB to the kernel. + NFS filesystem support CONFIG_NFS_FS If you are connected to some other (usually local) Unix computer diff -urp rth1-pre1-2.2.11/fs/Config.in patch_CONFIGZ/fs/Config.in --- rth1-pre1-2.2.11/fs/Config.in Tue Jun 29 13:58:42 1999 +++ patch_CONFIGZ/fs/Config.in Wed Jul 14 17:52:14 1999 @@ -34,6 +34,9 @@ if [ "$CONFIG_NTFS_FS" != "n" -a "$CONFI 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 ' compressed configuration (/proc/.config.gz)' CONFIG_PROC_CONFIGZ +fi if [ "$CONFIG_UNIX98_PTYS" = "y" ]; then # It compiles as a module for testing only. It should not be used # as a module in general. If we make this "tristate", a bunch of people diff -urp rth1-pre1-2.2.11/fs/proc/Makefile patch_CONFIGZ/fs/proc/Makefile --- rth1-pre1-2.2.11/fs/proc/Makefile Wed Jun 24 17:30:10 1998 +++ patch_CONFIGZ/fs/proc/Makefile Wed Jul 14 17:52:14 1999 @@ -29,3 +29,13 @@ O_OBJS += proc_devtree.o endif include $(TOPDIR)/Rules.make + +ifeq ($(CONFIG_PROC_CONFIGZ),y) +array.o: configz.h + +configz.h: $(TOPDIR)/.config + @echo 'static const char configz_array[] = {' > .conf + @gzip -9 - < $(TOPDIR)/.config | od -An -t x1 | tr -s '\040' '\012' | \ +sed -e '/[0-9a-f][0-9a-f]/s/\(.*\)/0x\1,/' -e '$$s/,/};/' >> .conf + @mv -f .conf $@ +endif diff -urp rth1-pre1-2.2.11/fs/proc/array.c patch_CONFIGZ/fs/proc/array.c --- rth1-pre1-2.2.11/fs/proc/array.c Tue Jun 29 13:58:38 1999 +++ patch_CONFIGZ/fs/proc/array.c Wed Jul 14 17:52:14 1999 @@ -1242,6 +1242,20 @@ static int get_pidcpu(int pid, char * bu } #endif +#ifdef CONFIG_PROC_CONFIGZ +#include "configz.h" +static int get_configz(char *buffer, char **start, off_t offset, off_t length) +{ + if (offset >= sizeof(configz_array)) + return 0; + if (length + offset > sizeof(configz_array)) + length = sizeof(configz_array) - offset; + memcpy(buffer, &configz_array[offset], length); + *start = buffer; + return length; +} +#endif + #ifdef CONFIG_MODULES extern int get_module_list(char *); extern int get_ksyms_list(char *, char **, off_t, int); @@ -1351,6 +1365,10 @@ static long get_root_array(char * page, #ifdef CONFIG_STRAM_PROC case PROC_STRAM: return get_stram_list(page); +#endif +#ifdef CONFIG_PROC_CONFIGZ + case PROC_CONFIGZ: + return get_configz(page, start, offset, length); #endif } return -EBADF; diff -urp rth1-pre1-2.2.11/fs/proc/root.c patch_CONFIGZ/fs/proc/root.c --- rth1-pre1-2.2.11/fs/proc/root.c Thu Apr 29 12:50:46 1999 +++ patch_CONFIGZ/fs/proc/root.c Wed Jul 14 17:52:14 1999 @@ -668,6 +668,13 @@ static struct proc_dir_entry proc_root_p NULL, NULL /* parent, subdir */ }; #endif +#if CONFIG_PROC_CONFIGZ +static struct proc_dir_entry proc_root_configz = { + PROC_CONFIGZ, 10, ".config.gz", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations +}; +#endif __initfunc(void proc_root_init(void)) { @@ -737,6 +744,9 @@ __initfunc(void proc_root_init(void)) proc_tty_init(); #ifdef __powerpc__ proc_register(&proc_root, &proc_root_ppc_htab); +#endif +#if CONFIG_PROC_CONFIGZ + proc_register(&proc_root, &proc_root_configz); #endif #ifdef CONFIG_PROC_DEVICETREE proc_device_tree_init(); diff -urp rth1-pre1-2.2.11/include/linux/proc_fs.h patch_CONFIGZ/include/linux/proc_fs.h --- rth1-pre1-2.2.11/include/linux/proc_fs.h Fri Jul 9 16:55:57 1999 +++ patch_CONFIGZ/include/linux/proc_fs.h Thu Jul 15 11:12:18 1999 @@ -52,7 +52,8 @@ enum root_directory_inos { PROC_STRAM, PROC_SOUND, PROC_MTRR, /* whether enabled or not */ - PROC_FS + PROC_FS, + PROC_CONFIGZ }; enum pid_directory_inos {