Subject: kern/4191: allow config to have a local files.BRI
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael C. Richardson <mcr@sandelman.ottawa.on.ca>
List: netbsd-bugs
Date: 09/29/1997 04:47:11
>Number: 4191
>Category: kern
>Synopsis: look for a local file with more device definitions
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Sep 29 17:35:00 1997
>Last-Modified:
>Originator: Michael C. Richardson
>Organization:
Sandelman Software Works Corp
>Release: 1.2G
>Environment:
System: NetBSD istari.sandelman.ottawa.on.ca 1.2D NetBSD 1.2D (SSW) #10: Wed Jun 11 00:01:01 EDT 1997 mcr@istari.sandelman.ottawa.on.ca:/j/netbsd/src/sys/arch/i386/compile/SSW i386
Architecture: i386
>Description:
This patch makes config look for a files.CONFIG in the current
directory. This is very useful when working on a new driver
that may never be checked into the source tree, and/or with
source trees that are read-only.
{I may have submitted this before, I can't recall.}
>How-To-Repeat:
>Fix:
diff -c -r /usr/src/usr.sbin/config/gram.y ./gram.y
*** /usr/src/usr.sbin/config/gram.y Fri Jun 13 07:30:04 1997
--- ./gram.y Sun Sep 21 14:31:38 1997
***************
*** 146,151 ****
--- 147,153 ----
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 */
***************
*** 436,445 ****
--- 444,486 ----
const char *mcharch;
{
char buf[MAXPATHLEN];
+ const char *last_component;
+ char configpath[MAXPATHLEN];
+ extern char origdir[];
machine = mch;
machinearch = mcharch;
+ configpath[0]='\0';
+ last_component=strrchr(conffile, '/');
+ if(last_component)
+ {
+ strncat(configpath, conffile, last_component-conffile);
+ /* advance past / */
+ last_component++;
+ }
+ else
+ {
+ last_component = conffile;
+ strncat(configpath, origdir, sizeof(configpath));
+ }
+
+
+ (void)snprintf(buf, MAXPATHLEN, "%s/files.%s", configpath, last_component);
+ printf("looking for %s (%s)\n", buf, getwd(NULL));
+
+ if(access(buf, F_OK) == 0)
+ {
+ printf("got %s\n", buf);
+ 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);
***************
*** 449,454 ****
--- 490,496 ----
machinearch, machinearch);
else
strcpy(buf, _PATH_DEVNULL);
+
if (include(buf, ENDFILE) != 0)
exit(1);
diff -c -r /usr/src/usr.sbin/config/main.c ./main.c
*** /usr/src/usr.sbin/config/main.c Fri Jun 13 07:30:04 1997
--- ./main.c Sun Sep 21 14:36:15 1997
***************
*** 83,88 ****
--- 83,90 ----
static int hasparent __P((struct devi *));
static int cfcrosscheck __P((struct config *, const char *, struct nvlist *));
+ char origdir[MAXPATHLEN];
+
int
main(argc, argv)
int argc;
***************
*** 144,149 ****
--- 151,159 ----
exit(1);
}
conffile = (argc == 1) ? argv[0] : "CONFIG";
+
+ getcwd(origdir, sizeof(origdir));
+
if (firstfile(conffile)) {
(void)fprintf(stderr, "config: cannot read %s: %s\n",
conffile, strerror(errno));
>Audit-Trail:
>Unformatted: