4 struct file_list *file;
40 * Copyright (c) 1988, 1993
41 * The Regents of the University of California. All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 4. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * @(#)config.y 8.1 (Berkeley) 6/6/93
79 struct device_head dtab;
86 struct file_list_head ftab;
87 struct files_name_head fntab;
91 #define ns(s) strdup(s)
92 int include(const char *, int);
93 void yyerror(const char *s);
96 static void newdev(char *name);
97 static void newfile(char *name);
98 static void rmdev_schedule(struct device_head *dh, char *name);
99 static void newopt(struct opt_head *list, char *name, char *value, int append);
100 static void rmopt_schedule(struct opt_head *list, char *name);
105 char *ret = malloc(strlen(dev) + 5);
107 sprintf(ret, "DEV_%s", dev);
125 Device_spec SEMICOLON
127 Config_spec SEMICOLON
129 INCLUDE PATH SEMICOLON {
134 INCLUDE ID SEMICOLON {
139 FILES ID SEMICOLON { newfile($2); };
148 if (machinename != NULL && !eq($2, machinename))
149 errx(1, "%s:%d: only one machine directive is allowed",
154 ARCH Save_id Save_id {
155 if (machinename != NULL &&
156 !(eq($2, machinename) && eq($3, machinearch)))
157 errx(1, "%s:%d: only one machine directive is allowed",
164 (struct cputype *)calloc(1, sizeof (struct cputype));
166 err(EXIT_FAILURE, "calloc");
168 SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
171 struct cputype *cp, *cp2;
172 SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) {
173 if (eq(cp->cpu_name, $2)) {
174 SLIST_REMOVE(&cputype, cp, cputype, cpu_next);
181 NOOPTION Save_id { rmopt_schedule(&opt, $2); } |
182 MAKEOPTIONS Mkopt_list
184 NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } |
185 IDENT ID { ident = $2; } |
188 MAXUSERS NUMBER { maxusers = $2; } |
189 PROFILE NUMBER { profiling = $2; } |
197 hint = (struct hint *)calloc(1, sizeof (struct hint));
199 err(EXIT_FAILURE, "calloc");
200 hint->hint_name = $2;
201 STAILQ_INSERT_TAIL(&hints, hint, hint_next);
206 CONFIG System_id System_parameter_list {
207 errx(1, "%s:%d: root/dump/swap specifications obsolete",
215 Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0); };
217 System_parameter_list:
218 System_parameter_list ID
223 Opt_list COMMA Option
230 newopt(&opt, $1, NULL, 0);
231 if (strchr($1, '=') != NULL)
232 errx(1, "%s:%d: The `=' in options should not be "
233 "quoted", yyfile, yyline);
235 Save_id EQUALS Opt_value {
236 newopt(&opt, $1, $3, 0);
244 (void) snprintf(buf, sizeof(buf), "%d", $1);
253 Mkopt_list COMMA Mkoption
259 Save_id { newopt(&mkopt, $1, ns(""), 0); } |
260 Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0); } |
261 Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0); } |
262 Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1); } ;
275 Dev_list COMMA Device
281 NoDev_list COMMA NoDevice
288 newopt(&opt, devopt($1), ns("1"), 0);
289 /* and the device part */
295 char *s = devopt($1);
297 rmopt_schedule(&opt, s);
299 /* and the device part */
300 rmdev_schedule(&dtab, $1);
306 yyerror(const char *s)
309 errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
315 if (found_defaults) {
316 if (freopen(PREFIX, "r", stdin) == NULL)
317 err(2, "%s", PREFIX);
327 * Add a new file to the list of files.
332 struct files_name *nl;
334 nl = (struct files_name *) calloc(1, sizeof *nl);
336 err(EXIT_FAILURE, "calloc");
338 STAILQ_INSERT_TAIL(&fntab, nl, f_next);
342 * Find a device in the list of devices.
344 static struct device *
345 finddev(struct device_head *dlist, char *name)
349 STAILQ_FOREACH(dp, dlist, d_next)
350 if (eq(dp->d_name, name))
357 * Add a device to the list of devices.
364 if (finddev(&dtab, name)) {
366 "WARNING: duplicate device `%s' encountered.\n", name);
370 np = (struct device *) calloc(1, sizeof *np);
372 err(EXIT_FAILURE, "calloc");
374 STAILQ_INSERT_TAIL(&dtab, np, d_next);
378 * Schedule a device to removal.
381 rmdev_schedule(struct device_head *dh, char *name)
385 dp = finddev(dh, name);
387 STAILQ_REMOVE(dh, dp, device, d_next);
394 * Find an option in the list of options.
397 findopt(struct opt_head *list, char *name)
401 SLIST_FOREACH(op, list, op_next)
402 if (eq(op->op_name, name))
409 * Add an option to the list of options.
412 newopt(struct opt_head *list, char *name, char *value, int append)
414 struct opt *op, *op2;
417 * Ignore inclusions listed explicitly for configuration files.
419 if (eq(name, OPT_AUTOGEN)) {
424 op2 = findopt(list, name);
425 if (op2 != NULL && !append) {
427 "WARNING: duplicate option `%s' encountered.\n", name);
431 op = (struct opt *)calloc(1, sizeof (struct opt));
433 err(EXIT_FAILURE, "calloc");
436 op->op_value = value;
438 while (SLIST_NEXT(op2, op_append) != NULL)
439 op2 = SLIST_NEXT(op2, op_append);
440 SLIST_NEXT(op2, op_append) = op;
442 SLIST_INSERT_HEAD(list, op, op_next);
446 * Remove an option from the list of options.
449 rmopt_schedule(struct opt_head *list, char *name)
453 op = findopt(list, name);
455 SLIST_REMOVE(list, op, opt, op_next);