Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/config Add a mechanism for files.* files to be incl...
details: https://anonhg.NetBSD.org/src/rev/14ff8fe8ba37
branches: trunk
changeset: 474451:14ff8fe8ba37
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jul 07 00:02:09 1999 +0000
description:
Add a mechanism for files.* files to be included, in the kernel configuration
file, conditional on their existence. For example:
[ in ../conf/GENERIC ]
cinclude "../crypto-intl/sys/conf/files.crypto-intl"
This required a change to the files.* grammar; pseudo-device in that
context has been changed to defpseudo, to avoid a conflicting rule
for pseudo-device in the kernel config files.
The same grammar change allows vendors to ship files.* files for
commercial drivers, rather than diffs to e.g. files.pci, i.e.:
include "arch/i386/pci/files.zap"
zap* at pci? device ? function ?
Where files.zap might contain:
device zap: ether, ifnet, arp, mii
attach zap at pci
object arch/i386/pci/zap.o zap
diffstat:
usr.sbin/config/config.h | 4 ++--
usr.sbin/config/gram.y | 23 ++++++++++-------------
usr.sbin/config/scan.l | 14 +++++++++-----
3 files changed, 21 insertions(+), 20 deletions(-)
diffs (155 lines):
diff -r 5dd4780b9d83 -r 14ff8fe8ba37 usr.sbin/config/config.h
--- a/usr.sbin/config/config.h Tue Jul 06 23:15:48 1999 +0000
+++ b/usr.sbin/config/config.h Wed Jul 07 00:02:09 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.42 1999/04/02 06:36:30 gwr Exp $ */
+/* $NetBSD: config.h,v 1.43 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -409,7 +409,7 @@
/* scan.l */
int currentline __P((void));
int firstfile __P((const char *));
-int include __P((const char *, int));
+int include __P((const char *, int, int));
/* sem.c, other than for yacc actions */
void initsem __P((void));
diff -r 5dd4780b9d83 -r 14ff8fe8ba37 usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y Tue Jul 06 23:15:48 1999 +0000
+++ b/usr.sbin/config/gram.y Wed Jul 07 00:02:09 1999 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.25 1999/01/21 13:10:09 pk Exp $ */
+/* $NetBSD: gram.y,v 1.26 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -59,8 +59,6 @@
#define stop(s) error(s), exit(1)
-int include __P((const char *, int));
-
static struct config conf; /* at most one active at a time */
/* the following is used to recover nvlist space after errors */
@@ -103,8 +101,8 @@
int val;
}
-%token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT
-%token DEFPARAM DEFFLAG DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
+%token AND AT ATTACH BUILD CINCLUDE COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT
+%token DEFPARAM DEFFLAG DEFPSEUDO DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
%token FILE_SYSTEM FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS
%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE
%token TYPE WITH NEEDS_COUNT NEEDS_FLAG
@@ -224,7 +222,8 @@
/* empty */ { $$ = NULL; };
include:
- INCLUDE WORD { include($2, 0); };
+ INCLUDE WORD { (void) include($2, 0, 0); } |
+ CINCLUDE WORD { (void) include($2, 0, 1); };
/*
@@ -258,7 +257,7 @@
{ defdevattach($5, $2, $4, $6); } |
MAXPARTITIONS NUMBER { maxpartitions = $2; } |
MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2, $3, $4); } |
- PSEUDO_DEVICE devbase attrs_opt { defdev($2, NULL, $3, 1); } |
+ DEFPSEUDO devbase attrs_opt { defdev($2, NULL, $3, 1); } |
MAJOR '{' majorlist '}';
atlist:
@@ -378,9 +377,7 @@
error '\n' { cleanup(); };
config_spec:
- file |
- object |
- include |
+ one_def |
FILE_SYSTEM fs_list |
OPTIONS opt_list |
MAKEOPTIONS mkopt_list |
@@ -511,7 +508,7 @@
machinearch = mcharch;
(void)sprintf(buf, "arch/%s/conf/files.%s", machine, machine);
- if (include(buf, ENDFILE) != 0)
+ if (include(buf, ENDFILE, 0) != 0)
exit(1);
if (machinearch != NULL)
@@ -519,10 +516,10 @@
machinearch, machinearch);
else
strcpy(buf, _PATH_DEVNULL);
- if (include(buf, ENDFILE) != 0)
+ if (include(buf, ENDFILE, 0) != 0)
exit(1);
- if (include("conf/files", ENDFILE) != 0)
+ if (include("conf/files", ENDFILE, 0) != 0)
exit(1);
}
diff -r 5dd4780b9d83 -r 14ff8fe8ba37 usr.sbin/config/scan.l
--- a/usr.sbin/config/scan.l Tue Jul 06 23:15:48 1999 +0000
+++ b/usr.sbin/config/scan.l Wed Jul 07 00:02:09 1999 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.22 1998/06/24 11:20:55 jonathan Exp $ */
+/* $NetBSD: scan.l,v 1.23 1999/07/07 00:02:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -86,6 +86,7 @@
at return AT;
attach return ATTACH;
build return BUILD;
+cinclude return CINCLUDE;
compile-with return COMPILE_WITH;
config return CONFIG;
deffs return DEFFS;
@@ -93,6 +94,7 @@
defflag return DEFFLAG;
defopt return DEFOPT;
defparam return DEFPARAM;
+defpseudo return DEFPSEUDO;
devclass return DEVCLASS;
device return DEVICE;
dumps return DUMPS;
@@ -201,9 +203,9 @@
* If ateof == 0 then nothing is inserted.
*/
int
-include(fname, ateof)
+include(fname, ateof, conditional)
const char *fname;
- int ateof;
+ int ateof, conditional;
{
FILE *fp;
struct incl *in;
@@ -216,12 +218,14 @@
}
/* Kludge until files.* files are fixed. */
- if (strncmp(fname, "../../../", 9) == 0)
+ if (conditional == 0 && strncmp(fname, "../../../", 9) == 0)
fname += 9;
s = (*fname == '/') ? strdup(fname) : sourcepath(fname);
if ((fp = fopen(s, "r")) == NULL) {
- error("cannot open %s for reading: %s\n", s, strerror(errno));
+ if (conditional == 0)
+ error("cannot open %s for reading: %s\n", s,
+ strerror(errno));
free(s);
return (-1);
}
Home |
Main Index |
Thread Index |
Old Index