Skip to contentSkip to conversation

kernel .config support?

PATCH New Robert P. J. Day 6 participants 10 messages Jan 2, 2003 – Jan 5, 2003

Subsystems (10)
Arm (32-bit) Kbuild MIPS s390 +6 more subsystems
lore
Share & tools
lore
#0 lore raw

whatever happened to that funky option from 2.4 --
for kernel .config support, which allegedly buried the config file inside the kernel itself. (it never worked -- the alleged extraction script scripts/extract-ikconfig depended on a program called "binoffset" that didn't exist in that distribution.)

any plans to resurrect this, or something like it?

rday

#1 lore raw

On Thu, 2 Jan 2003, Robert P. J. Day wrote:

|   whatever happened to that funky option from 2.4 --
| for kernel .config support, which allegedly buried the
| config file inside the kernel itself.  (it never worked --
| the alleged extraction script scripts/extract-ikconfig
| depended on a program called "binoffset" that didn't
| exist in that distribution.)
|
|   any plans to resurrect this, or something like it?

Khalid Aziz et al (HP) have updated it to 2.5.
It's also part of the OSDL 2.5 DCL and CGL trees.
See http://developer.osdl.org/ for info on them.

I'll check to make sure there is a separate patch available for it and repost it.

Thanks,

Signature · 1 line
~Randy
#2 lore raw

On Thu, 2 Jan 2003, Randy.Dunlap wrote:

| On Thu, 2 Jan 2003, Robert P. J. Day wrote:
|
| |   whatever happened to that funky option from 2.4 --
| | for kernel .config support, which allegedly buried the
| | config file inside the kernel itself.  (it never worked --
| | the alleged extraction script scripts/extract-ikconfig
| | depended on a program called "binoffset" that didn't
| | exist in that distribution.)
| |
| |   any plans to resurrect this, or something like it?
|
| Khalid Aziz et al (HP) have updated it to 2.5.
| It's also part of the OSDL 2.5 DCL and CGL trees.
| See http://developer.osdl.org/ for info on them.
|
| I'll check to make sure there is a separate patch available for it
| and repost it.

I have updated Khalid's 2.5.50 patch for 2.5.54 for comments or use. It is below.
Here is Khalid's 2.5.50 email also.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am including a patch for 2.5.50 that allows a user to embed kernel configuration in the kernel and retrieve it later either from a running kernel or from the kernel image file. This is an enhancement to Randy's patch that was discussed on LKML before and is part of -ac series kernels.

This patch provides three choices for embedding kernel configuration:

1. Include configuration in running kernel image. This adds to the footprint of the running kernel but allows configuration to be retrieved using "cat /proc/ikconfig/config".

2. Include configuration in kernel image file but not in the running kernel. This adds to the kernel image file size but not the footprint of running kernel. Configuration can be extracted from kernel image file using scripts/extract-ikconfig. This script is in principle the same as what Randy had written originally. I have made it little more robust and structured it to accomodate more than just x86 architecture.

3. Not include kernel configuration in the running kernel or kernel image file.

With these three choices, users can make the appropriate tradeoff. This feature is especially useful for support folks who need to know the kernel configuration for a customer's kernel with fairly high degree of confidence that they are getting the right configuration. This feature is turned off in the default configuration.

[Linus, please apply.]

====================================================================

patch_name:     ikconfig-2554.patch
patch_version:  2003.01.02
author:         Randy Dunlap <[email protected]>
description:    add in-kernel and /proc config options
product:        linux
product_versions: 2.5.54
changelog:      (a) add 2 options in General Setup
URL:            http://www.osdl.org/archive/rddunlap/patches/
requires:
conflicts:
diffstat:
 linux-2554-ikconfig/arch/alpha/defconfig     |    2
 linux-2554-ikconfig/arch/arm/defconfig       |    2
 linux-2554-ikconfig/arch/cris/defconfig      |    2
 linux-2554-ikconfig/arch/i386/defconfig      |    2
 linux-2554-ikconfig/arch/ia64/defconfig      |    2
 linux-2554-ikconfig/arch/m68k/defconfig      |    2
 linux-2554-ikconfig/arch/mips/defconfig      |    2
 linux-2554-ikconfig/arch/mips64/defconfig    |    3
 linux-2554-ikconfig/arch/ppc/defconfig       |    2
 linux-2554-ikconfig/arch/ppc64/defconfig     |    2
 linux-2554-ikconfig/arch/s390/defconfig      |    2
 linux-2554-ikconfig/arch/s390x/defconfig     |    2
 linux-2554-ikconfig/arch/sh/defconfig        |    2
 linux-2554-ikconfig/arch/sparc/defconfig     |    2
 linux-2554-ikconfig/arch/sparc64/defconfig   |    2
 linux-2554-ikconfig/arch/um/defconfig        |    2
 linux-2554-ikconfig/arch/x86_64/defconfig    |    2
 linux-2554-ikconfig/init/Kconfig             |   25 +++
 linux-2554-ikconfig/kernel/configs.c         |  206 +++++++++++++++++++++++++++
 linux-2554-ikconfig/scripts/extract-ikconfig |  101 +++++++++++++
 linux-2554-ikconfig/scripts/mkconfigs        |   81 ++++++++++
 linux-2554/kernel/Makefile                   |   11 +
 22 files changed, 459 insertions(+)
arch/alpha/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/alpha/defconfig linux-2554-ikconfig/arch/alpha/defconfig
@@ -19,6 +19,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/arm/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/arm/defconfig linux-2554-ikconfig/arch/arm/defconfig
@@ -80,6 +80,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_NWFPE=y
 CONFIG_KCORE_ELF=y
 # CONFIG_KCORE_AOUT is not set
arch/cris/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/cris/defconfig linux-2554-ikconfig/arch/cris/defconfig
@@ -17,6 +17,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_SYSCTL is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_BINFMT_ELF=y
 # CONFIG_ETRAX_KGDB is not set
 # CONFIG_ETRAX_WATCHDOG is not set
arch/i386/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/i386/defconfig linux-2554-ikconfig/arch/i386/defconfig
@@ -19,6 +19,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/ia64/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/ia64/defconfig linux-2554-ikconfig/arch/ia64/defconfig
@@ -14,6 +14,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/m68k/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/m68k/defconfig linux-2554-ikconfig/arch/m68k/defconfig
@@ -42,6 +42,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_KCORE_ELF=y
 # CONFIG_KCORE_AOUT is not set
 CONFIG_BINFMT_AOUT=y
arch/mips/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/mips/defconfig linux-2554-ikconfig/arch/mips/defconfig
@@ -93,6 +93,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Memory Technology Devices (MTD)
arch/mips64/defconfig +3 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/mips64/defconfig linux-2554-ikconfig/arch/mips64/defconfig
@@ -56,6 +56,9 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
+
 CONFIG_BINFMT_ELF=y
 CONFIG_MIPS32_COMPAT=y
 CONFIG_BINFMT_ELF32=y
arch/ppc/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/ppc/defconfig linux-2554-ikconfig/arch/ppc/defconfig
@@ -64,6 +64,8 @@
 CONFIG_PCI=y
 CONFIG_NET=y
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_KCORE_ELF=y
arch/ppc64/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/ppc64/defconfig linux-2554-ikconfig/arch/ppc64/defconfig
@@ -20,6 +20,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/s390/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/s390/defconfig linux-2554-ikconfig/arch/s390/defconfig
@@ -19,6 +19,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/s390x/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/s390x/defconfig linux-2554-ikconfig/arch/s390x/defconfig
@@ -19,6 +19,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/sh/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/sh/defconfig linux-2554-ikconfig/arch/sh/defconfig
@@ -45,6 +45,8 @@
 # CONFIG_SYSVIPC is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_SYSCTL is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_KCORE_ELF=y
 # CONFIG_KCORE_AOUT is not set
 CONFIG_BINFMT_ELF=y
arch/sparc/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/sparc/defconfig linux-2554-ikconfig/arch/sparc/defconfig
@@ -19,6 +19,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/sparc64/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/sparc64/defconfig linux-2554-ikconfig/arch/sparc64/defconfig
@@ -16,6 +16,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
arch/um/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/um/defconfig linux-2554-ikconfig/arch/um/defconfig
@@ -20,6 +20,8 @@
 CONFIG_SYSVIPC=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 CONFIG_BINFMT_AOUT=y
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
arch/x86_64/defconfig +2 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/arch/x86_64/defconfig linux-2554-ikconfig/arch/x86_64/defconfig
@@ -23,6 +23,8 @@
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKCONFIG_PROC is not set
 
 #
 # Loadable module support
init/Kconfig +25 -0
diff -urN --exclude-from=diff_exclude_file linux-2554/init/Kconfig linux-2554-ikconfig/init/Kconfig
@@ -98,6 +98,31 @@
 	  building a kernel for install/rescue disks or your system is very
 	  limited in memory.
 
+config IKCONFIG
+	bool "Kernel .config support"
+	---help---
+	  This option enables the complete Linux kernel ".config" file
+	  contents, information on compiler used to build the kernel,
+	  kernel running when this kernel was built and kernel version
+	  from Makefile to be saved in kernel. It provides documentation
+	  of which kernel options are used in a running kernel or in an
+	  on-disk kernel.  This information can be extracted from the kernel
+	  image file with the script scripts/extract-ikconfig and used as
+	  input to rebuild the current kernel or to build another kernel.
+	  It can also be extracted from a running kernel by reading
+	  /proc/ikconfig/config and /proc/ikconfig/built_with, if enabled.
+	  /proc/ikconfig/config will list the configuration that was used
+	  to build the kernel and /proc/ikconfig/built_with will list
+	  information on the compiler and host machine that was used to
+	  build the kernel.
+
+config IKCONFIG_PROC
+	bool "Enable access to .config through /proc/ikconfig"
+	depends on IKCONFIG
+	---help---
+	  This option enables access to kernel configuration file and build
+	  information through /proc/ikconfig.
+
 endmenu
 
 
kernel/configs.c +206 -0

206 lines not on this page · raw message

scripts/extract-ikconfig +101 -0

101 lines not on this page · raw message

scripts/mkconfigs +81 -0

81 lines not on this page · raw message

kernel/Makefile renamed from kernel/Makefile%IKC +11 -0
@@ -22,6 +22,10 @@
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o
 obj-$(CONFIG_COMPAT) += compat.o
+obj-$(CONFIG_IKCONFIG) += configs.o
+
+# files to be removed upon make clean
+clean-files := ikconfig.h
 
 ifneq ($(CONFIG_IA64),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
@@ -31,3 +35,10 @@
 # to get a correct value for the wait-channel (WCHAN in ps). --davidm
 CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer
 endif
+
+$(obj)/ikconfig.h: $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile
+	$(CONFIG_SHELL) $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile > $(obj)/ikconfig.h
+
+$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \
+		$(TOPDIR)/include/linux/version.h \
+		$(TOPDIR)/include/linux/compile.h
#3 lore raw
In reply to Robert P. J. Day
Quoted 7 lines · Robert P. J. Day

whatever happened to that funky option from 2.4 --
for kernel .config support, which allegedly buried the config file inside the kernel itself. (it never worked -- the alleged extraction script scripts/extract-ikconfig depended on a program called "binoffset" that didn't exist in that distribution.)

Its never been in the standard 2.4 kernel. The facility has been in the -ac kernel, and was recently submitted for consideration in 2.5

#4 lore raw
Quoted 11 lines · Alan Cox
Quoted 7 lines · Robert P. J. Day

whatever happened to that funky option from 2.4 --
for kernel .config support, which allegedly buried the config file inside the kernel itself. (it never worked -- the alleged extraction script scripts/extract-ikconfig depended on a program called "binoffset" that didn't exist in that distribution.)

Its never been in the standard 2.4 kernel. The facility has been in the -ac kernel, and was recently submitted for consideration in 2.5

that's odd. the selection for kernel .config support has been in the red hat config menus for at least the last release, as well as the extraction script .../scripts/extract-ikconfig. but this never worked due to a missing "binoffset" utility. i even filed a bugzilla on that (bug 65677).

just curious -- how did that ever end up in the distributed red hat kernel if it was never standard? strange.

rday

#5 lore raw
Quoted 7 lines · Robert P. J. Day
Quoted 3 lines · Alan Cox

Its never been in the standard 2.4 kernel. The facility has been in the -ac kernel, and was recently submitted for consideration in 2.5

Quoted 9 lines

that's odd. the selection for kernel .config support has been in the red hat config menus for at least the last release, as well as the extraction script .../scripts/extract-ikconfig. but this never worked due to a missing "binoffset" utility. i even filed a bugzilla on that (bug 65677).

just curious -- how did that ever end up in the distributed red hat kernel if it was never standard? strange.

Redhat kernel is not the same as standard kernel (the official one, on kernel.org). Redhat adds a number of patches to the standard kernel before releasing it.

Signature · 9 lines
Khalid

====================================================================
Khalid Aziz                                Linux and Open Source Lab
(970)898-9214                                        Hewlett-Packard
[email protected]                                       Fort Collins, CO

"The Linux kernel is subject to relentless development" 
				- Alessandro Rubini
#6 lore raw

Hello,

Following some advices from the list, here is my patch updated, to embed the .config in the kernel and give access to a gzip'ed copy thru /proc/config/config.gz

Regards,
Paul

diff -urN linux-2.5.53-orig/drivers/char/Kconfig
linux-2.5.53/drivers/char/Kconfig

drivers/char/Kconfig Mon Dec 30 08:35:54 2002 renamed from drivers/char/Kconfig Tue Dec 24 06:19:26 2002 +4 -0
@@ -4,6 +4,13 @@
 
 menu "Character devices"
 
+config CONFIG
+       bool "Linux Kernel Configuration Driver"
+       ---help---
+         If you say Y here, and if you have /proc support enabled,

you'll find
+ a /proc/config directory that will contain a copy of the
.config used
+ to generate the running kernel.
+
config VT
bool "Virtual terminal"
---help---
diff -urN linux-2.5.53-orig/drivers/char/Makefile
linux-2.5.53/drivers/char/Makefile

drivers/char/Makefile Mon Dec 30 12:06:53 2002 renamed from drivers/char/Makefile Tue Dec 24 06:21:17 2002 +3 -0
@@ -7,6 +7,9 @@
 #
 FONTMAPFILE = cp437.uni
 
+EXTRA_TARGETS  := config.h
+host-progs     := dotHmaker
+
 obj-y   += mem.o tty_io.o n_tty.o tty_ioctl.o pty.o misc.o random.o
 
 # All of the (potential) objects that export symbols.
@@ -16,6 +19,7 @@
                        ite_gpio.o keyboard.o misc.o nvram.o random.o

rtc.o \
selection.o sonypi.o sysrq.o tty_io.o
tty_ioctl.o

+obj-$(CONFIG_CONFIG) += config.o
obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o consolemap.o
consolemap_deftbl.o selection.o keyboard.o
obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
@@ -85,7 +89,7 @@

# Files generated that shall be removed upon make clean
-clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c +clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c dotHmaker config.txt config.txt.gz config.h

$(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)

        $(call do_cmd,CONMK  $@,$(objtree)/scripts/conmakehash $< > $@)
@@ -107,3 +111,13 @@
        rm [email protected]

endif
+
+$(obj)/config.o: $(obj)/config.h
+
+$(obj)/config.h: $(obj)/config.txt.gz $(obj)/dotHmaker
+ $(obj)/dotHmaker < $< > $@
+
+$(obj)/config.txt.gz: .config FORCE
+ cp .config $(obj)/config.txt
+ $(call if_changed,gzip)
+
diff -urN linux-2.5.53-orig/drivers/char/config.c linux-2.5.53/drivers/char/config.c

drivers/char/config.c Mon Dec 30 08:33:48 2002 renamed from drivers/char/config.c Thu Jan 1 01:00:00 1970 +71 -0

73 lines not on this page · raw message

offset,
+ int size)
+{
+ int i;
+
+ for (i=0; i<DOT_CONFIG_GZ_SIZE; i++) {
+ PRINT_PROC("%c", config_gz[i]);
+ }
+
+ return(1);
+}
+
+static int config_read_proc( char *buffer, char **start, off_t offset,
+ int size, int *eof, void *data )
+{
+ int len = 0;
+ off_t begin = 0;
+
+ *eof = config_version_infos(buffer, &len, &begin, offset, size); +
+ if (offset >= begin + len)
+ return(0);
+ *start = buffer + (offset - begin);
+ return( size < begin + len - offset ? size : begin + len - offset ); +}
+
+static int config_gz_read_proc( char *buffer, char **start, off_t offset,
+ int size, int *eof, void *data ) {
+ int len = 0;
+ off_t begin = 0;
+
+ *eof = config_gz_infos(buffer, &len, &begin, offset, size); +
+ if (offset >= begin + len)
+ return(0);
+ *start = buffer + (offset - begin);
+ return( size < begin + len - offset ? size : begin + len - offset ); +}
+
+static int __init config_init(void)
+{

+  struct proc_dir_entry * entry;
+  entry = create_proc_entry("config", S_IRUGO|S_IXUGO|S_IFDIR, NULL);
+  if (entry == NULL) {

+ printk(KERN_ERR "config: can't create /proc/config\n");
+ return(-ENOMEM);
+ }
+
+ if (!create_proc_read_entry("config/version",0,0,config_read_proc,NULL)) {
+ printk(KERN_ERR "config: can't create /proc/config/version\n");
+ return(-ENOMEM);
+ }
+ if (!create_proc_read_entry("config/config.gz",0,0,config_gz_read_proc,NULL )) {
+ printk(KERN_ERR "config: can't create /proc/config/config.gz\n");
+ return(-ENOMEM);
+ }
+
+ printk(KERN_INFO "Linux Kernel Configuration driver v" DOT_CONFIG_VERSION
+ " (c) Paul Rolland\n");
+
+ return( 0 );
+}
+
+static void __exit config_cleanup_module (void)
+{

+  remove_proc_entry( "config/version", 0 );
+  remove_proc_entry( "config/config.gz", 0 );
+  remove_proc_entry( "config", 0 );

+}
+
+module_init(config_init); +module_exit(config_cleanup_module);
+
+#endif /* CONFIG_PROC_FS */
+
+MODULE_AUTHOR("Paul Rolland"); +MODULE_DESCRIPTION("Driver for accessing kernel configuration"); +MODULE_LICENSE("GPL");
+
diff -urN linux-2.5.53-orig/drivers/char/dotHmaker.c linux-2.5.53/drivers/char/dotHmaker.c

drivers/char/dotHmaker.c Mon Dec 30 08:33:04 2002 renamed from drivers/char/dotHmaker.c Thu Jan 1 01:00:00 1970 +41 -0

41 lines not on this page · raw message

+}
+

#7 lore raw
In reply to Robert P. J. Day

On Thu, 2 Jan 2003, Robert P. J. Day wrote:

| On 2 Jan 2003, Alan Cox wrote:
|
| > On Thu, 2003-01-02 at 14:32, Robert P. J. Day wrote:
| > >
| > >   whatever happened to that funky option from 2.4 --
| > > for kernel .config support, which allegedly buried the
| > > config file inside the kernel itself.  (it never worked --
| > > the alleged extraction script scripts/extract-ikconfig
| > > depended on a program called "binoffset" that didn't
| > > exist in that distribution.)
| >
| > Its never been in the standard 2.4 kernel. The facility has been in the
| > -ac kernel, and was recently submitted for consideration in 2.5
|
| that's odd.  the selection for kernel .config support has been in
| the red hat config menus for at least the last release, as well
| as the extraction script .../scripts/extract-ikconfig.  but this
| never worked due to a missing "binoffset" utility.  i even filed
| a bugzilla on that (bug 65677).

I wasn't aware of this...oh well.
"binoffset.c" is available at
http://www.osdl.org/archive/rddunlap/patches/

| just curious -- how did that ever end up in the distributed red hat | kernel if it was never standard? strange.

Not really.

Signature · 1 line
~Randy
#8 lore raw

PATCH 1/1 [Patch 2.5] [Was: RE : kernel .config support?]

In reply to Alan Cox

Hello,

I've just corrected two problems in the patch I submitted.

Here it is, just tested againt 2.5.54.

diff -urN linux-2.5.53-orig/drivers/char/Kconfig
linux-2.5.53/drivers/char/Kconfig

drivers/char/Kconfig Mon Dec 30 08:35:54 2002 renamed from drivers/char/Kconfig Tue Dec 24 06:19:26 2002 +4 -0
@@ -4,6 +4,13 @@
 
 menu "Character devices"
 
+config CONFIG
+       bool "Linux Kernel Configuration Driver"
+       ---help---
+         If you say Y here, and if you have /proc support enabled,

you'll find
+ a /proc/config directory that will contain a copy of the
.config used
+ to generate the running kernel.
+
config VT
bool "Virtual terminal"
---help---
diff -urN linux-2.5.53-orig/drivers/char/Makefile
linux-2.5.53/drivers/char/Makefile

drivers/char/Makefile Mon Dec 30 12:06:53 2002 renamed from drivers/char/Makefile Tue Dec 24 06:21:17 2002 +3 -0
@@ -7,6 +7,9 @@
 #
 FONTMAPFILE = cp437.uni
 
+EXTRA_TARGETS  := config.h
+host-progs     := dotHmaker
+
 obj-y   += mem.o tty_io.o n_tty.o tty_ioctl.o pty.o misc.o random.o
 
 # All of the (potential) objects that export symbols.
@@ -16,6 +19,7 @@
                        ite_gpio.o keyboard.o misc.o nvram.o random.o

rtc.o \
selection.o sonypi.o sysrq.o tty_io.o
tty_ioctl.o

+obj-$(CONFIG_CONFIG) += config.o
obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o consolemap.o
consolemap_deftbl.o selection.o keyboard.o
obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
@@ -85,7 +89,7 @@

# Files generated that shall be removed upon make clean
-clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c +clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c dotHmaker config.txt config.txt.gz config.h

$(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)

        $(call do_cmd,CONMK  $@,$(objtree)/scripts/conmakehash $< > $@)
@@ -107,3 +111,13 @@
        rm [email protected]

endif
+
+$(obj)/config.o: $(obj)/config.h
+
+$(obj)/config.h: $(obj)/config.txt.gz $(obj)/dotHmaker
+ $(obj)/dotHmaker < $< > $@
+
+$(obj)/config.txt.gz: .config FORCE
+ cp .config $(obj)/config.txt
+ $(call if_changed,gzip)
+
diff -urN linux-2.5.53-orig/drivers/char/config.c linux-2.5.53/drivers/char/config.c

drivers/char/config.c Mon Dec 30 08:33:48 2002 renamed from drivers/char/config.c Thu Jan 1 01:00:00 1970 +74 -0

76 lines not on this page · raw message

offset,
+ int size)
+{
+ int i;
+
+ for (i=0; i<DOT_CONFIG_GZ_SIZE; i++) {
+ PRINT_PROC("%c", config_gz[i]);
+ }
+
+ return(1);
+}
+
+static int config_read_proc( char *buffer, char **start, off_t offset,
+ int size, int *eof, void *data )
+{
+ int len = 0;
+ off_t begin = 0;
+
+ *eof = config_version_infos(buffer, &len, &begin, offset, size); +
+ if (offset >= begin + len)
+ return(0);
+ *start = buffer + (offset - begin);
+ return( size < begin + len - offset ? size : begin + len - offset ); +}
+
+static int config_gz_read_proc( char *buffer, char **start, off_t offset,
+ int size, int *eof, void *data ) {
+ int len = 0;
+ off_t begin = 0;
+
+ *eof = config_gz_infos(buffer, &len, &begin, offset, size); +
+ if (offset >= begin + len)
+ return(0);
+ *start = buffer + (offset - begin);
+ return( size < begin + len - offset ? size : begin + len - offset ); +}
+
+static int __init config_init(void)
+{

+  struct proc_dir_entry * entry;
+  entry = create_proc_entry("config", S_IRUGO|S_IXUGO|S_IFDIR, NULL);
+  if (entry == NULL) {

+ printk(KERN_ERR "config: can't create /proc/config\n");
+ return(-ENOMEM);
+ }
+
+ if (!create_proc_read_entry("config/version",0,0,config_read_proc,NULL)) {
+ printk(KERN_ERR "config: can't create /proc/config/version\n");
+ return(-ENOMEM);
+ }
+ if (!create_proc_read_entry("config/config.gz",0,0,config_gz_read_proc,NULL )) {
+ printk(KERN_ERR "config: can't create /proc/config/config.gz\n");
+ return(-ENOMEM);
+ }
+
+ printk(KERN_INFO "Linux Kernel Configuration driver v" DOT_CONFIG_VERSION
+ " (c) Paul Rolland\n");
+
+ return( 0 );
+}
+
+static void __exit config_cleanup_module (void)
+{

+  remove_proc_entry( "config/version", 0 );
+  remove_proc_entry( "config/config.gz", 0 );
+  remove_proc_entry( "config", 0 );

+}
+
+module_init(config_init); +module_exit(config_cleanup_module);
+
+#endif /* CONFIG_PROC_FS */
+
+MODULE_AUTHOR("Paul Rolland"); +MODULE_DESCRIPTION("Driver for accessing kernel configuration"); +MODULE_LICENSE("GPL");
+
diff -urN linux-2.5.53-orig/drivers/char/dotHmaker.c linux-2.5.53/drivers/char/dotHmaker.c

drivers/char/dotHmaker.c Mon Dec 30 08:33:04 2002 renamed from drivers/char/dotHmaker.c Thu Jan 1 01:00:00 1970 +44 -0

44 lines not on this page · raw message

#9 lore raw
In reply to Robert P. J. Day
Quoted 9 lines · Robert P. J. Day

whatever happened to that funky option from 2.4 --
for kernel .config support, which allegedly buried the config file inside the kernel itself. (it never worked -- the alleged extraction script scripts/extract-ikconfig depended on a program called "binoffset" that didn't exist in that distribution.)

any plans to resurrect this, or something like it?

It's never been part of the standard kernel distribution. Your distribution probably has an extra patch compiled in in order to provide this.

It's IMO not very usefull: each distribution of a compiled kernel should just include a seperate file containing the .config, just like it contains seperate modules. The prefered name is $IMAGENAME.config, where $IMAGENAME is the name of the installed kernel image. No need to bloat the kernel with this information, IMHO.

I'd love to see a patch which copies the .config to /vmlinuz.config on a standard make {zlilo|bzlilo|install} though.

(yes, I know that the .config won't be available on a bootfloppy without a fs. Then again, on a bootfloppy /with/ fs, there won't be space for a .config...)

Signature · 1 line
Erik Hensema <[email protected]>