aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2001-08-27 05:11:53 +0000
committerPeter Wemm <peter@FreeBSD.org>2001-08-27 05:11:53 +0000
commit76cb0cadf1469e60fd6b4aa0c0dc10ef98700220 (patch)
tree06393996c5f6b3f52eee5b7462bc0a12683ef517 /usr.sbin
parentd0b8716702265fa10d0f73a377e15018c67f6e08 (diff)
downloadsrc-76cb0cadf1469e60fd6b4aa0c0dc10ef98700220.tar.gz
src-76cb0cadf1469e60fd6b4aa0c0dc10ef98700220.zip
Enable hardwiring of things like tunables from embedded enironments
that do not start from loader(8).
Notes
Notes: svn path=/head/; revision=82393
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/config.h2
-rw-r--r--usr.sbin/config/config.y8
-rw-r--r--usr.sbin/config/configvers.h2
-rw-r--r--usr.sbin/config/lang.l1
-rw-r--r--usr.sbin/config/mkmakefile.c62
5 files changed, 61 insertions, 14 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 8b6606fabc46..7c493d83cec7 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 5f1577471ac5..b1f5f2b47e5d 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 3dbb96db0309..e62ab7b7f80d 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 63e46e4823c3..f7f6ee058ac1 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 45516fc3889f..29a5cb097c71 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"));
}
/*