diff options
author | peter <peter@FreeBSD.org> | 2001-08-27 05:11:53 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-08-27 05:11:53 +0000 |
commit | e031b90e2a515850159496b7a6da3b8595780427 (patch) | |
tree | 06393996c5f6b3f52eee5b7462bc0a12683ef517 /usr.sbin/config | |
parent | 4892f8428ad2764ed6430b35aeb7d3bb88df4b87 (diff) | |
download | FreeBSD-src-e031b90e2a515850159496b7a6da3b8595780427.zip FreeBSD-src-e031b90e2a515850159496b7a6da3b8595780427.tar.gz |
Enable hardwiring of things like tunables from embedded enironments
that do not start from loader(8).
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/config.y | 8 | ||||
-rw-r--r-- | usr.sbin/config/configvers.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/lang.l | 1 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 62 |
5 files changed, 61 insertions, 14 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 8b6606f..7c493d8 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -122,8 +122,10 @@ struct opt_list { } *otab; extern char *ident; +extern char *env; extern char *hints; extern int do_trace; +extern int envmode; extern int hintmode; char *get_word(FILE *); diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 5f15774..b1f5f2b 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -9,6 +9,7 @@ %token CONFIG %token CPU %token DEVICE +%token ENV %token EQUALS %token HINTS %token IDENT @@ -75,6 +76,8 @@ static struct device *curp = 0; struct device *dtab; char *ident; +char *env; +int envmode; char *hints; int hintmode; int yyline; @@ -145,6 +148,11 @@ Config_spec: = { maxusers = $2; } | PROFILE NUMBER = { profiling = $2; } | + ENV ID + = { + env = $2; + envmode = 1; + } | HINTS ID = { hints = $2; diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index 3dbb96d..e62ab7b 100644 --- a/usr.sbin/config/configvers.h +++ b/usr.sbin/config/configvers.h @@ -8,4 +8,4 @@ * * $FreeBSD$ */ -#define CONFIGVERS 500007 +#define CONFIGVERS 500008 diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 63e46e4..f7f6ee0 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -67,6 +67,7 @@ struct kt { { "config", CONFIG }, { "cpu", CPU }, { "device", DEVICE }, + { "env", ENV }, { "hints", HINTS }, { "ident", IDENT }, { "machine", ARCH }, /* MACHINE is defined in /sys/param.h */ diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 45516fc..29a5cb0 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -206,19 +206,6 @@ makefile(void) ofp = fopen(path("hints.c.new"), "w"); if (ofp == NULL) err(1, "%s", path("hints.c.new")); -#if 0 - /* - * This is causing more pain than it is worth. And besides, the - * release has been fixed so that this isn't necessary anymore. - * The boot floppies load hints now. - */ - if (hintmode == 0) { - snprintf(line, sizeof(line), "%s.hints", PREFIX); - ifp = fopen(line, "r"); - if (ifp) - hintmode = 2; - } -#endif fprintf(ofp, "int hintmode = %d;\n", hintmode); fprintf(ofp, "char static_hints[] = {\n"); if (ifp) { @@ -257,6 +244,55 @@ makefile(void) fclose(ifp); fclose(ofp); moveifchanged(path("hints.c.new"), path("hints.c")); + + if (env) { + ifp = fopen(env, "r"); + if (ifp == NULL) + err(1, "%s", env); + } else { + ifp = NULL; + } + ofp = fopen(path("env.c.new"), "w"); + if (ofp == NULL) + err(1, "%s", path("env.c.new")); + fprintf(ofp, "int envmode = %d;\n", envmode); + fprintf(ofp, "char static_env[] = {\n"); + if (ifp) { + while (fgets(line, BUFSIZ, ifp) != 0) { + /* zap trailing CR and/or LF */ + while ((s = rindex(line, '\n')) != NULL) + *s = '\0'; + while ((s = rindex(line, '\r')) != NULL) + *s = '\0'; + /* remove # comments */ + s = index(line, '#'); + if (s) + *s = '\0'; + /* remove any whitespace and " characters */ + s = line; + while (*s) { + if (*s == ' ' || *s == '\t' || *s == '"') { + while (*s) { + s[0] = s[1]; + s++; + } + /* start over */ + s = line; + continue; + } + s++; + } + /* anything left? */ + if (*line == '\0') + continue; + fprintf(ofp, "\"%s\\0\"\n", line); + } + } + fprintf(ofp, "\"\\0\"\n};\n"); + if (ifp) + fclose(ifp); + fclose(ofp); + moveifchanged(path("env.c.new"), path("env.c")); } /* |