Messages in this thread Patch in this message | | | Date | Sat, 13 Mar 1999 17:15:27 +0000 (GMT) | From | Tigran Aivazian <> | Subject | [patch] v1.02 of /proc/.config |
| |
On Sat, 13 Mar 1999, Tigran Aivazian wrote:
> > tmp1=`mktemp -q /tmp/dconfig1_XXXXXX` > > tmp2=`mktemp -q /tmp/dconfig2_XXXXXX` > > The above does not work as is (because there are probably some bugs with > mktemp(1) - I will get a source and start debugging it as soon as I have > time. But yes, I totally agree - I will get rid of $$-approach.
Sorry - works now. It did not work not "as is" but "as cut-n-pasted with some \"creativity\"" (i.e. reducing a few Xs) :)
Attached is the updated version of the patch
Thank you, Tigran.
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 Sat Mar 13 12:09:12 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 wish 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 Sat Mar 13 11:51:00 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/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/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/kernel/Makefile linux-2.2.3-dconfig/kernel/Makefile --- linux/kernel/Makefile Wed May 6 19:01:46 1998 +++ linux-2.2.3-dconfig/kernel/Makefile Sat Mar 13 11:58:27 1999 @@ -21,6 +21,10 @@ O_OBJS += kmod.o endif +ifeq ($(CONFIG_DCONFIG),y) +O_OBJS += dconfig.o +endif + ifeq ($(CONFIG_MODULES),y) OX_OBJS += ksyms.o endif diff -urN linux/kernel/dconfig.c linux-2.2.3-dconfig/kernel/dconfig.c --- linux/kernel/dconfig.c Thu Jan 1 01:00:00 1970 +++ linux-2.2.3-dconfig/kernel/dconfig.c Sat Mar 13 17:02:28 1999 @@ -0,0 +1,100 @@ +/* + * /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 (TA) <tigran@sco.com> : Initial version + * + * v1.01 + * TA : Made it a CONFIG_DCONFIG + * compile option. + * v1.02 + * TA : Fixed scripts/mkdconfig.sh + * to use mktemp(1) + */ + +#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); +} + + +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 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 Sat Mar 13 16:55:35 1999 @@ -0,0 +1,14 @@ +#!/bin/sh + +tmp1=`mktemp -q /tmp/dconfig1_XXXXXX` +tmp2=`mktemp -q /tmp/dconfig2_XXXXXX` + +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/x-gunzip] | |