config procfs patch

Andrew Purtell (apurtell@ieinc.com)
Thu, 22 May 1997 18:21:57 -0400


This is a multi-part message in MIME format.

--------------2E6F60E42714425978FDB028
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've put together a small (rather silly) patch to 2.0.30 that
others may find useful. I'm not sure if this is the right
list on which to post it, because I'm not advocating that
this go into the kernel distribution, but it is a kernel
hack...

We have a couple of operators who know basic UNIX
administration but don't much about the Linux kernel. In
my support role, I've found it helpful if they can provide
me with the kernel configuration. The attached patch adds
a build option for incorporating the settings in .config
into the kernel as a file in /proc. It can be added to the
kernel statically or made into a module.

Doing this:

echo /proc/config | mail apurtell

or this I guess:

/sbin/modprobe config && echo /proc/config | \
mail apurtell

gives me the information I need. Simple but effective.
Sure, just leaving the .config file on the machine and
mailing that would work, but this has been useful in
guaranteeing the information I get back is accurate.

-- 
Andrew Purtell                  phone: (617) 272-9700
Network Administrator           fax  : (617) 272-9300
Intelligent Environments        email: apurtell@ieinc.com
http://www.ieinc.com/                  akp@tiac.net

--------------2E6F60E42714425978FDB028 Content-Type: text/plain; charset=us-ascii; name="procfs-config-2.0.30.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="procfs-config-2.0.30.patch"

diff -u --recursive --new-file linux-2.0.30-vanilla/fs/Config.in linux-2.0.30/fs/Config.in --- linux-2.0.30-vanilla/fs/Config.in Sun Dec 1 08:58:05 1996 +++ linux-2.0.30/fs/Config.in Wed May 21 22:36:44 1997 @@ -18,6 +18,8 @@ dep_tristate 'umsdos: Unix like fs on top of std MSDOS FAT fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS bool '/proc filesystem support' CONFIG_PROC_FS +dep_tristate ' Show configuration as /proc/config' CONFIG_PROC_CONF $CONFIG_PROC_FS + if [ "$CONFIG_INET" = "y" ]; then tristate 'NFS filesystem support' CONFIG_NFS_FS if [ "$CONFIG_NFS_FS" = "y" ]; then diff -u --recursive --new-file linux-2.0.30-vanilla/fs/Makefile linux-2.0.30/fs/Makefile --- linux-2.0.30-vanilla/fs/Makefile Wed May 8 11:28:01 1996 +++ linux-2.0.30/fs/Makefile Wed May 21 22:40:15 1997 @@ -17,7 +17,7 @@ MOD_LIST_NAME := FS_MODULES ALL_SUB_DIRS = minix ext ext2 fat msdos vfat proc isofs nfs xiafs umsdos \ - hpfs sysv smbfs ncpfs ufs affs + hpfs sysv smbfs ncpfs ufs affs config ifeq ($(CONFIG_QUOTA),y) O_OBJS += dquot.o @@ -75,6 +75,13 @@ ifdef CONFIG_PROC_FS SUB_DIRS += proc + ifeq ($(CONFIG_PROC_CONF),y) + SUB_DIRS += config + else + ifeq ($(CONFIG_PROC_CONF),m) + MOD_SUB_DIRS += config + endif + endif endif ifeq ($(CONFIG_ISO9660_FS),y) diff -u --recursive --new-file linux-2.0.30-vanilla/fs/config/Makefile linux-2.0.30/fs/config/Makefile --- linux-2.0.30-vanilla/fs/config/Makefile Wed Dec 31 19:00:00 1969 +++ linux-2.0.30/fs/config/Makefile Wed May 21 22:41:11 1997 @@ -0,0 +1,19 @@ +# +# Makefile for config procfs module +# Andrew Purtell, Intelligent Environments +# + +O_TARGET := config.o +O_OBJS := conf.o conf_data.o +M_OBJS := $(O_TARGET) + +AWK = gawk +AWKCMD = '/^[A-Za-z_]+/ { printf "%c%s\\n%c\n", "\"", $$0, "\"" ; }' + +conf_data.o: + @echo "char *config_data = " > conf_data.c + @$(AWK) $(AWKCMD) $(TOPDIR)/.config >> conf_data.c + @echo ";" >> conf_data.c + @$(CC) $(CFLAGS) -c -o conf_data.o conf_data.c + +include $(TOPDIR)/Rules.make diff -u --recursive --new-file linux-2.0.30-vanilla/fs/config/conf.c linux-2.0.30/fs/config/conf.c --- linux-2.0.30-vanilla/fs/config/conf.c Wed Dec 31 19:00:00 1969 +++ linux-2.0.30/fs/config/conf.c Wed May 21 22:32:57 1997 @@ -0,0 +1,64 @@ +/* + * conf.c + * silly little config procfs module + * adds /proc/config + * Andrew Purtell, Intelligent Environments + */ + +#include <linux/autoconf.h> +#include <linux/config.h> +#include <linux/module.h> + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/string.h> +#include <linux/errno.h> +#include <linux/malloc.h> +#include <linux/stat.h> +#include <linux/fs.h> +#include <linux/proc_fs.h> + +extern char *config_data; + +int +config_get_info(char *buffer,char **start, off_t offset, int length, int dummy) +{ + off_t len = 0, size; + + size = strlen(config_data); + len = (size - offset < length) ? size - offset : length; + memcpy(buffer, config_data + offset, len); + *start = buffer; + + return len; +} + +struct proc_dir_entry proc_config = { + 0, 6, "config", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_net_inode_operations, + config_get_info +}; + +int +init_proc_conf(void) { + return proc_register_dynamic(&proc_root, &proc_config); +} + +#ifdef MODULE + +int init_module(void) +{ + int status; + + if ((status = init_proc_conf()) == 0) + register_symtab(0); + return status; +} + +void cleanup_module(void) +{ + proc_unregister(&proc_root, proc_config.low_ino); +} + +#endif diff -u --recursive --new-file linux-2.0.30-vanilla/fs/filesystems.c linux-2.0.30/fs/filesystems.c --- linux-2.0.30-vanilla/fs/filesystems.c Thu Apr 25 05:32:39 1996 +++ linux-2.0.30/fs/filesystems.c Wed May 21 22:33:25 1997 @@ -78,6 +78,10 @@ init_proc_fs(); #endif +#ifdef CONFIG_PROC_CONF + init_proc_conf(); +#endif + #ifdef CONFIG_NFS_FS init_nfs_fs(); #endif

--------------2E6F60E42714425978FDB028--