summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/main.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-10-27 17:13:23 +0000
committerjhb <jhb@FreeBSD.org>2005-10-27 17:13:23 +0000
commit36d533d5436d4b351fc1f691415956afc77d5b12 (patch)
tree423a0bffe2fa7e681c7f2dd245f1856a9aa8ce9c /usr.sbin/config/main.c
parent5da09e19375e739cfe4a6df1906f5829439049c4 (diff)
downloadFreeBSD-src-36d533d5436d4b351fc1f691415956afc77d5b12.zip
FreeBSD-src-36d533d5436d4b351fc1f691415956afc77d5b12.tar.gz
Optionally include a DEFAULTS config file if it is present in the current
directory before the specified config file. This is implemented by opening DEFAULTS as stdin if it exists, and if so resetting stdin to the actual config file when DEFAULTS is fully parsed via yywrap(). In short, this lets us create DEFAULTS kernel configs in /sys/<arch>/conf that can enable certain options or devices by default and allow users to disable them via 'nooptions' or 'nodevice' rather than having to create kludge NO_FOO options. Requested by: scottl Reviewed by: scottl
Diffstat (limited to 'usr.sbin/config/main.c')
-rw-r--r--usr.sbin/config/main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 78d82ec..3ff1575 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -72,6 +72,7 @@ char srcdir[MAXPATHLEN];
int debugging;
int profiling;
+int found_defaults;
static void configfile(void);
static void get_srcdir(void);
@@ -123,8 +124,15 @@ main(int argc, char **argv)
if (argc != 1)
usage();
- if (freopen(PREFIX = *argv, "r", stdin) == NULL)
- err(2, "%s", PREFIX);
+ PREFIX = *argv;
+ if (freopen("DEFAULTS", "r", stdin) != NULL) {
+ found_defaults = 1;
+ yyfile = "DEFAULTS";
+ } else {
+ if (freopen(PREFIX, "r", stdin) == NULL)
+ err(2, "%s", PREFIX);
+ yyfile = PREFIX;
+ }
if (*destdir != '\0') {
len = strlen(destdir);
@@ -148,7 +156,6 @@ main(int argc, char **argv)
STAILQ_INIT(&fntab);
SLIST_INIT(&cputype);
STAILQ_INIT(&ftab);
- yyfile = *argv;
if (yyparse())
exit(3);
if (machinename == NULL) {
OpenPOWER on IntegriCloud