Subject: kern/23050: patch for kernfs: adds /kern/config
To: None <gnats-bugs@gnats.netbsd.org>
From: Ron Roskens <roskens@elfin.net>
List: netbsd-bugs
Date: 10/04/2003 01:13:33
>Number:         23050
>Category:       kern
>Synopsis:       patch for kernfs: adds /kern/config
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 04 06:14:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Ron Roskens
>Release:        NetBSD 1.6ZC
>Organization:
>Environment:
	
	
System: NetBSD tidell.tx.elfin.net 1.6ZC NetBSD 1.6ZC (GENERIC) #11: Sat Sep 27 15:06:05 CDT 2003  root@tidell.tx.elfin.net:/d/d1g/NetBSD/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
Enhances kernfs by adding a vnode for the config file used to compile the
kernel. Only included if INCLUDE_CONFIG_FILE or INCLUDE_JUST_CONFIG are
defined. In addition to using "strings /netbsd", if kernfs is mounted you
can run the following:
	$ cat /kern/config | sed -n 's/^_CFG_//p' | unvis


I renamed the variable under which the config file was stored to
"config_file". I had tried making it be a non-static variable, but there
were other files which had used 'config' as a variable too.

Some comments for thought:
If kernfs gives you the ability to see the config file, should we still need
to run unvis? sed?

If kernfs has the file, should "strings /netbsd |sed -n 's/^_CFG_//p' |unvis"
tell you to mount kernfs to see the config file?

>How-To-Repeat:
>Fix:

Index: usr.sbin/config/main.c
===================================================================
RCS file: /cvs/NetBSD/src/usr.sbin/config/main.c,v
retrieving revision 1.86
diff -b -u -r1.86 main.c
--- usr.sbin/config/main.c	14 Sep 2003 12:43:04 -0000	1.86
+++ usr.sbin/config/main.c	4 Oct 2003 00:34:43 -0000
@@ -1279,7 +1279,7 @@
 	(void)fprintf(cfg, "#if defined(%s) || defined(%s)\n\n",
 	    LOGCONFIG_LARGE, LOGCONFIG_SMALL);
 	(void)fprintf(cfg,
-	    "static const char config[] __attribute__((__unused__)) =\n\n");
+	    "static const char config_file[] __attribute__((__unused__)) =\n\n");
 
 	(void)fprintf(cfg, "#ifdef %s\n\n", LOGCONFIG_LARGE);
 	(void)fprintf(cfg, "\"_CFG_### START CONFIG FILE \\\"%s\\\"\\n\"\n\n",
Index: sys/conf/param.c
===================================================================
RCS file: /cvs/NetBSD/src/sys/conf/param.c,v
retrieving revision 1.41
diff -b -u -r1.41 param.c
--- sys/conf/param.c	7 Aug 2003 16:30:49 -0000	1.41
+++ sys/conf/param.c	4 Oct 2003 00:18:03 -0000
@@ -43,6 +43,7 @@
 #include "opt_sb_max.h"
 #include "opt_sysv.h"
 #include "opt_sysvparam.h"
+#include "fs_kernfs.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -67,8 +68,10 @@
 #include <sys/msg.h>
 #endif
 
+#ifndef	KERNFS
 #define CONFIG_FILE
 #include "config_file.h"
+#endif
 
 /*
  * System parameter formulae.
Index: sys/miscfs/kernfs/kernfs.h
===================================================================
RCS file: /cvs/NetBSD/src/sys/miscfs/kernfs/kernfs.h,v
retrieving revision 1.20
diff -b -u -r1.20 kernfs.h
--- sys/miscfs/kernfs/kernfs.h	27 Sep 2003 13:29:02 -0000	1.20
+++ sys/miscfs/kernfs/kernfs.h	4 Oct 2003 00:03:27 -0000
@@ -57,6 +57,7 @@
 	KFSipsecspdir,	/* ipsec security policy (top dir) */
 	KFSipsecsa,		/* ipsec security association entry */
 	KFSipsecsp,		/* ipsec security policy entry */
+	KFSconfig,	/* kernel configuration */
 } kfstype;
 
 /*
Index: sys/miscfs/kernfs/kernfs_vnops.c
===================================================================
RCS file: /cvs/NetBSD/src/sys/miscfs/kernfs/kernfs_vnops.c,v
retrieving revision 1.98
diff -b -u -r1.98 kernfs_vnops.c
--- sys/miscfs/kernfs/kernfs_vnops.c	27 Sep 2003 13:29:02 -0000	1.98
+++ sys/miscfs/kernfs/kernfs_vnops.c	4 Oct 2003 00:34:22 -0000
@@ -43,6 +43,7 @@
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
+#include "opt_config.h"
 #endif
 
 #include <sys/param.h>
@@ -72,6 +73,9 @@
 #include <netkey/key.h>
 #endif
 
+#define CONFIG_FILE
+#include "config_file.h"
+
 #include <uvm/uvm_extern.h>
 
 #define KSTRING	256		/* Largest I/O available via this filesystem */
@@ -111,6 +115,10 @@
 			/* XXX cast away const */
      { DT_REG, N("version"),   (void *)version,
      					     KFSstring,      VREG, READ_MODE  },
+#ifdef INCLUDE_CONFIG_FILE
+     { DT_REG, N("config"),   (void *)config_file,
+     					     KFSstring,      VREG, READ_MODE  },
+#endif
 };
 #ifdef IPSEC
 const struct kern_target ipsecsa_targets[] = {
>Release-Note:
>Audit-Trail:
>Unformatted: