Subject: kern/3446: enhancement to config
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael C. Richardson <mcr@istari.sandelman.ottawa.on.ca>
List: netbsd-bugs
Date: 04/03/1997 14:44:22
>Number:         3446
>Category:       kern
>Synopsis:       config looks for, and includes files.CONFIG
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Apr  3 12:05:02 1997
>Last-Modified:
>Originator:     Michael C. Richardson
>Organization:
Sandelman Software Works
>Release:        1.2
>Environment:
System: NetBSD istari.sandelman.ottawa.on.ca 1.2D NetBSD 1.2D (SSW) #1: Wed Apr 2 16:21:04 EST 1997 mcr@lox.sandelman.ottawa.on.ca:/sandel/netbsd/src/sys/arch/i386/compile/SSW i386
Architecture: i386

>Description:
	config has been modified to look for a file in the same directory
	as the kernel configuration file that provides additional device
	definitions. The file is named files.SYSTEMNAME. This is useful
	with -s and -b to develope custom kernels without having to have
	write permissions on the kernel source.

>How-To-Repeat:
	
>Fix:
*** /w/netbsd/src/usr.sbin/config/gram.y	Mon Feb  3 07:25:59 1997
--- gram.y	Thu Apr  3 14:26:24 1997
***************
*** 146,151 ****
--- 146,152 ----
  	dev_defs dev_eof		/* sys/conf/files */
  	dev_defs dev_eof		/* sys/arch/${MACHINE_ARCH}/... */
  	dev_defs dev_eof		/* sys/arch/${MACHINE}/... */
+ 	dev_defs dev_eof		/* possible files.CONFIG */
  					{ check_maxpart(); }
  	specs;				/* rest of machine description */
  
***************
*** 442,451 ****
--- 443,482 ----
  	const char *mcharch;
  {
  	char buf[MAXPATHLEN];
+ 	const char *last_component;
+ 	char        configpath[MAXPATHLEN];
  
  	machine = mch;
  	machinearch = mcharch;
  
+ 	last_component=strrchr(conffile, '/');
+ 	if(last_component)
+ 	  {
+ 	    configpath[0]='\0';
+ 	    strncat(configpath, conffile, last_component-conffile);
+ 	    
+ 	    /* advance past / */
+ 	    last_component++;
+ 	  }
+ 	else
+ 	  {
+ 	    last_component = conffile;
+ 	    getcwd(configpath, sizeof(configpath));
+ 	  }
+ 	
+ 
+ 	(void)snprintf(buf, MAXPATHLEN, "%s/files.%s", configpath, last_component);
+ 	if(access(buf, F_OK) == 0)
+ 	  {
+ 	    if (include(buf, ENDFILE) != 0)
+ 	      exit(1);
+ 	  }
+ 	else
+ 	  {
+ 	    if(include(_PATH_DEVNULL, ENDFILE) != 0)
+ 	      exit(1);
+ 	  }
+ 
  	(void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine);
  	if (include(buf, ENDFILE) != 0)
  		exit(1);
***************
*** 460,465 ****
--- 491,497 ----
  
  	if (include("conf/files", ENDFILE) != 0)
  		exit(1);
+ 
  }
  
  static void

>Audit-Trail:
>Unformatted: