lkml.org 
[lkml]   [1999]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[Patch] support for /proc/.config (against 2.2.3)
Dear Everyone,

Many people (on various wishlists) requested this feature so I implemented
it.

Features:

o Correct size of /proc/.config file and binary identical to
/usr/src/linux/.config:

o kernel/dconfig.c #includes "dconfig_buf.c" which is generated
on the fly by new scripts/mkdconfig.sh bash script.

o imho, a useful thing although eats about 10K of memory
(The possible uses are for those who (like me) keep 20-30 different
kernels ready to boot but only 6-7 sets of complete source so it is hard
to know which one was compiled with which options).

If you decide to give it a try, please do
chmod 0755 scripts/mkdconfig.sh after applying the patch because diff -urN
does not seem to store mode info so patch(1) makes it not executable.

If nobody objects to it being in the mainstream kernel I will send this
patch to Linus.

Regards,
Tigran.

PS. Having learned how to maintain the correct size of /proc files
(looking at mtrr) I intend to try and do it for a few more files.

Here is a copy for those too lazy to gunzip attachment and yet curious
enough:

diff -urN linux/Makefile 223-dconfig/Makefile
--- linux/Makefile Thu Feb 25 00:30:59 1999
+++ 223-dconfig/Makefile Fri Mar 12 16:33:44 1999
@@ -223,17 +223,21 @@

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

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

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

config: symlinks
$(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
+ 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 kernel/dconfig_buf.c

distclean: mrproper
rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
diff -urN linux/include/linux/proc_fs.h 223-dconfig/include/linux/proc_fs.h
--- linux/include/linux/proc_fs.h Mon Mar 8 23:51:59 1999
+++ 223-dconfig/include/linux/proc_fs.h Fri Mar 12 16:33:44 1999
@@ -52,7 +52,8 @@
PROC_STRAM,
PROC_SOUND,
PROC_MTRR, /* whether enabled or not */
- PROC_FS
+ PROC_FS,
+ PROC_DCONFIG
};

enum pid_directory_inos {
diff -urN linux/init/main.c 223-dconfig/init/main.c
--- linux/init/main.c Thu Feb 25 00:27:54 1999
+++ 223-dconfig/init/main.c Fri Mar 12 17:10:43 1999
@@ -79,6 +79,10 @@
extern void filescache_init(void);
extern void signals_init(void);

+#ifdef CONFIG_PROC_FS
+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_PROC_FS
+ dconfig_init();
#endif

/* Set up devices .. */
diff -urN linux/kernel/Makefile 223-dconfig/kernel/Makefile
--- linux/kernel/Makefile Wed May 6 19:01:46 1998
+++ 223-dconfig/kernel/Makefile Fri Mar 12 16:33:44 1999
@@ -21,6 +21,10 @@
O_OBJS += kmod.o
endif

+ifeq ($(CONFIG_PROC_FS),y)
+O_OBJS += dconfig.o
+endif
+
ifeq ($(CONFIG_MODULES),y)
OX_OBJS += ksyms.o
endif
diff -urN linux/kernel/dconfig.c 223-dconfig/kernel/dconfig.c
--- linux/kernel/dconfig.c Thu Jan 1 01:00:00 1970
+++ 223-dconfig/kernel/dconfig.c Fri Mar 12 16:33:44 1999
@@ -0,0 +1,96 @@
+/*
+ * /proc/.config driver - a snapshot of /usr/src/linux/.config
+ *
+ * Copyright (C) 1999 Tigran Aivazian
+ *
+ * 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 <tigran@sco.com> : Initial version
+ *
+ */
+
+#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; /* set in dconfig_init() */
+static ssize_t dconfig_read(struct file *, char *, size_t, loff_t *);
+
+static struct file_operations dconfig_fops =
+{
+ NULL, /* llseek */
+ dconfig_read, /* read */
+ NULL, /* write */
+ NULL, /* readdir */
+ NULL, /* poll */
+ NULL, /* ioctl */
+ NULL, /* mmap */
+ NULL, /* open */
+ NULL, /* flush */
+ NULL, /* release */
+ NULL, /* fsync */
+ NULL, /* fasync */
+ NULL, /* check_media_change */
+ NULL, /* revalidate */
+ NULL, /* lock */
+};
+
+static struct inode_operations proc_dconfig_inops = {
+ &dconfig_fops, /* default property file-ops */
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ NULL, /* readlink */
+ NULL, /* follow_link */
+ NULL, /* readpage */
+ NULL, /* writepage */
+ NULL, /* bmap */
+ NULL, /* truncate */
+ NULL /* permission */
+};
+
+
+static struct proc_dir_entry proc_root_dconfig = {
+ PROC_DCONFIG, 7, ".config",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_dconfig_inops
+};
+
+
+void __init
+dconfig_init(void)
+{
+ proc_root_dconfig.size = dconfig_len = strlen(dconfig_buf);
+ proc_register(&proc_root, &proc_root_dconfig);
+ return 0;
+}
+
+
+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/scripts/mkdconfig.sh 223-dconfig/scripts/mkdconfig.sh
--- linux/scripts/mkdconfig.sh Thu Jan 1 01:00:00 1970
+++ 223-dconfig/scripts/mkdconfig.sh Fri Mar 12 16:33:44 1999
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+tmp1=/tmp/dconfig1_$$
+tmp2=/tmp/dconfig2_$$
+
+echo "/* DO NOT EDIT: Automatically generated by scripts/mkdconfig.sh */" > $tmp1
+echo "" >> $tmp1
+echo "static char *dconfig_buf = " >> $tmp1
+echo -n \" >> $tmp1
+echo "\";" > $tmp2
+
+rm -f ./kernel/dconfig_buf.c 2> /dev/null
+cat $tmp1 .config $tmp2 > ./kernel/dconfig_buf.c
+rm -f $tmp1 $tmp2 2> /dev/null

[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.358 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site