[patch] v1.03 of /proc/.config support. (against 2.2.3)

Tigran Aivazian (tigran@aivazian.demon.co.uk)
Tue, 16 Mar 1999 21:42:39 +0000 (GMT)


Hi Brethren,

Attached is the latest version of /proc/.config patch.

Differences:

o scripts/mkdconfig.sh now has no races and does not use temporary
files. Also, it uses a small amount of sed(1)-magic to handle the
case of string-valued configuration parameters (e.g. sound firmware paths)
(Thanks to MEC for pointing this out)

o dconfig.c moved from kernel to fs/proc directory and tidied up a little.

For those not aware of what this small patch does -- it implements a
/proc/.config file containing the snapshot of your CONGIG_ options used
when the kernel was compiled in the format identical to the one used in
the disk file /usr/src/linux/.config.

Regards,
Tigran.

PS. Although I said in the subject "v1.03" to distinguish from previous
versions, internally it is still called "v1.0 Initial implementation",
until (if ever) it gets into the mainstream kernel.

diff -urN linux/Documentation/Configure.help linux-2.2.3-dconfig/Documentation/Configure.help
--- linux/Documentation/Configure.help Sat Mar 13 11:57:14 1999
+++ linux-2.2.3-dconfig/Documentation/Configure.help Tue Mar 16 21:05:26 1999
@@ -6931,6 +6931,16 @@
This option will enlarge your kernel by about 18 KB. Several
programs depend on this, so everyone should say Y here.

+/proc/.config support
+CONFIG_DCONFIG
+ Saying Y here will make a snapshot of your configuration options
+ permanently available via /proc/.config file. It is useful if you
+ compile several kernel images with different configuration options
+ and would like to keep track of which is which.
+
+ This option will enlarge your kernel by about 10-12 KB, depending on
+ the size of your /usr/src/linux/.config file.
+
NFS filesystem support
CONFIG_NFS_FS
If you are connected to some other (usually local) Unix computer
diff -urN linux/Makefile linux-2.2.3-dconfig/Makefile
--- linux/Makefile Sat Mar 13 11:57:14 1999
+++ linux-2.2.3-dconfig/Makefile Tue Mar 16 20:00:47 1999
@@ -223,17 +223,21 @@

oldconfig: symlinks
$(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
+ $(CONFIG_SHELL) scripts/mkdconfig.sh

xconfig: symlinks
$(MAKE) -C scripts kconfig.tk
wish -f scripts/kconfig.tk
+ $(CONFIG_SHELL) scripts/mkdconfig.sh

menuconfig: include/linux/version.h symlinks
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in
+ $(CONFIG_SHELL) scripts/mkdconfig.sh

config: symlinks
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
+ $(CONFIG_SHELL) scripts/mkdconfig.sh

include/config/MARKER: scripts/split-include include/linux/autoconf.h
scripts/split-include include/linux/autoconf.h include/config
@@ -376,6 +380,7 @@
rm -f $(TOPDIR)/include/linux/modversions.h
rm -rf $(TOPDIR)/include/linux/modules
rm -rf modules
+ rm -f fs/proc/dconfig_buf.c

distclean: mrproper
rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
diff -urN linux/fs/Config.in linux-2.2.3-dconfig/fs/Config.in
--- linux/fs/Config.in Sat Mar 13 11:57:16 1999
+++ linux-2.2.3-dconfig/fs/Config.in Sat Mar 13 12:05:41 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 support' CONFIG_DCONFIG
+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 -urN linux/fs/proc/Makefile linux-2.2.3-dconfig/fs/proc/Makefile
--- linux/fs/proc/Makefile Wed Jun 24 22:30:10 1998
+++ linux-2.2.3-dconfig/fs/proc/Makefile Tue Mar 16 20:01:42 1999
@@ -24,6 +24,10 @@
endif
endif

+ifeq ($(CONFIG_DCONFIG),y)
+O_OBJS += dconfig.o
+endif
+
ifeq ($(CONFIG_PROC_DEVICETREE),y)
O_OBJS += proc_devtree.o
endif
diff -urN linux/fs/proc/dconfig.c linux-2.2.3-dconfig/fs/proc/dconfig.c
--- linux/fs/proc/dconfig.c Thu Jan 1 01:00:00 1970
+++ linux-2.2.3-dconfig/fs/proc/dconfig.c Tue Mar 16 20:56:58 1999
@@ -0,0 +1,61 @@
+/*
+ * /proc/.config driver -- a snapshot of /usr/src/linux/.config
+ *
+ * Copyright (C) 1999 Tigran Aivazian <tigran@sco.com>
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Change History
+ *
+ * v1.0 Tigran Aivazian: Initial implementation
+ *
+ */
+
+#include <linux/proc_fs.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+
+#include <asm/uaccess.h>
+
+#include "dconfig_buf.c"
+
+static int dconfig_len; /* the size in bytes of /proc/.config */
+static ssize_t dconfig_read(struct file *, char *, size_t, loff_t *);
+
+static struct file_operations dconfig_fops =
+{
+ NULL, /* llseek */
+ dconfig_read /* read */
+};
+
+static struct inode_operations proc_dconfig_inops = {
+ &dconfig_fops
+};
+
+static struct proc_dir_entry proc_dconfig = {
+ PROC_DCONFIG, 7, ".config", S_IFREG | S_IRUGO,
+ 1, 0, 0, 0, &proc_dconfig_inops
+};
+
+void __init
+dconfig_init(void)
+{
+ proc_dconfig.size = dconfig_len = strlen(dconfig_buf);
+ proc_register(&proc_root, &proc_dconfig);
+}
+
+static ssize_t
+dconfig_read(struct file *file, char *buf, size_t len, loff_t *pos)
+{
+ if (*pos > dconfig_len)
+ return 0;
+ if (*pos + len > dconfig_len)
+ len = dconfig_len - *pos;
+ if (copy_to_user(buf, dconfig_buf + *pos, len))
+ return -EFAULT;
+ *pos += len;
+ return len;
+}
diff -urN linux/include/linux/proc_fs.h linux-2.2.3-dconfig/include/linux/proc_fs.h
--- linux/include/linux/proc_fs.h Sat Mar 13 11:57:17 1999
+++ linux-2.2.3-dconfig/include/linux/proc_fs.h Sat Mar 13 11:52:05 1999
@@ -52,7 +52,8 @@
PROC_STRAM,
PROC_SOUND,
PROC_MTRR, /* whether enabled or not */
- PROC_FS
+ PROC_FS,
+ PROC_DCONFIG /* whether enabled or not */
};

enum pid_directory_inos {
diff -urN linux/init/main.c linux-2.2.3-dconfig/init/main.c
--- linux/init/main.c Sat Mar 13 11:57:17 1999
+++ linux-2.2.3-dconfig/init/main.c Sat Mar 13 11:52:52 1999
@@ -79,6 +79,10 @@
extern void filescache_init(void);
extern void signals_init(void);

+#ifdef CONFIG_DCONFIG
+extern void dconfig_init(void);
+#endif
+
extern void device_setup(void);
extern void binfmt_setup(void);
extern void free_initmem(void);
@@ -1293,6 +1297,10 @@
real_root_mountflags = root_mountflags;
if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
else mount_initrd =0;
+#endif
+
+#ifdef CONFIG_DCONFIG
+ dconfig_init();
#endif

/* Set up devices .. */
diff -urN linux/scripts/mkdconfig.sh linux-2.2.3-dconfig/scripts/mkdconfig.sh
--- linux/scripts/mkdconfig.sh Thu Jan 1 01:00:00 1970
+++ linux-2.2.3-dconfig/scripts/mkdconfig.sh Tue Mar 16 20:57:19 1999
@@ -0,0 +1,9 @@
+#!/bin/sh
+( \
+ echo "/* DO NOT EDIT: Generated by scripts/mkdconfig.sh */" ; \
+ echo "" ; \
+ echo "static char dconfig_buf[] = " ; \
+ echo -n \" ; \
+ sed -e 's/\"/\\"/g' .config ; \
+ echo "\";" ; \
+) > fs/proc/dconfig_buf.c

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/