4 struct file_list *file;
40 * SPDX-License-Identifier: BSD-3-Clause
42 * Copyright (c) 1988, 1993
43 * The Regents of the University of California. All rights reserved.
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. Neither the name of the University nor the names of its contributors
54 * may be used to endorse or promote products derived from this software
55 * without specific prior written permission.
57 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
58 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
61 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
62 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
63 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * @(#)config.y 8.1 (Berkeley) 6/6/93
81 struct device_head dtab;
88 struct file_list_head ftab;
89 struct files_name_head fntab;
93 #define ns(s) strdup(s)
94 int include(const char *, int);
95 void yyerror(const char *s);
98 static void newdev(char *name);
99 static void newfile(char *name);
100 static void rmdev_schedule(struct device_head *dh, char *name);
101 static void newopt(struct opt_head *list, char *name, char *value, int append);
102 static void rmopt_schedule(struct opt_head *list, char *name);
107 char *ret = malloc(strlen(dev) + 5);
109 sprintf(ret, "DEV_%s", dev);
127 Device_spec SEMICOLON
129 Config_spec SEMICOLON
131 INCLUDE PATH SEMICOLON {
136 INCLUDE ID SEMICOLON {
141 FILES ID SEMICOLON { newfile($2); };
150 if (machinename != NULL && !eq($2, machinename))
151 errx(1, "%s:%d: only one machine directive is allowed",
156 ARCH Save_id Save_id {
157 if (machinename != NULL &&
158 !(eq($2, machinename) && eq($3, machinearch)))
159 errx(1, "%s:%d: only one machine directive is allowed",
166 (struct cputype *)calloc(1, sizeof (struct cputype));
168 err(EXIT_FAILURE, "calloc");
170 SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
173 struct cputype *cp, *cp2;
174 SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) {
175 if (eq(cp->cpu_name, $2)) {
176 SLIST_REMOVE(&cputype, cp, cputype, cpu_next);
183 NOOPTION NoOpt_list |
184 MAKEOPTIONS Mkopt_list
186 NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } |
187 IDENT ID { ident = $2; } |
190 MAXUSERS NUMBER { maxusers = $2; } |
191 PROFILE NUMBER { profiling = $2; } |
199 hint = (struct hint *)calloc(1, sizeof (struct hint));
201 err(EXIT_FAILURE, "calloc");
202 hint->hint_name = $2;
203 STAILQ_INSERT_TAIL(&hints, hint, hint_next);
208 CONFIG System_id System_parameter_list {
209 errx(1, "%s:%d: root/dump/swap specifications obsolete",
217 Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0); };
219 System_parameter_list:
220 System_parameter_list ID
225 Opt_list COMMA Option
231 NoOpt_list COMMA NoOption
237 newopt(&opt, $1, NULL, 0);
238 if (strchr($1, '=') != NULL)
239 errx(1, "%s:%d: The `=' in options should not be "
240 "quoted", yyfile, yyline);
242 Save_id EQUALS Opt_value {
243 newopt(&opt, $1, $3, 0);
248 rmopt_schedule(&opt, $1);
256 (void) snprintf(buf, sizeof(buf), "%d", $1);
265 Mkopt_list COMMA Mkoption
271 Save_id { newopt(&mkopt, $1, ns(""), 0); } |
272 Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0); } |
273 Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0); } |
274 Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1); } ;
287 Dev_list COMMA Device
293 NoDev_list COMMA NoDevice
300 newopt(&opt, devopt($1), ns("1"), 0);
301 /* and the device part */
307 char *s = devopt($1);
309 rmopt_schedule(&opt, s);
311 /* and the device part */
312 rmdev_schedule(&dtab, $1);
318 yyerror(const char *s)
321 errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
327 if (found_defaults) {
328 if (freopen(PREFIX, "r", stdin) == NULL)
329 err(2, "%s", PREFIX);
339 * Add a new file to the list of files.
344 struct files_name *nl;
346 nl = (struct files_name *) calloc(1, sizeof *nl);
348 err(EXIT_FAILURE, "calloc");
350 STAILQ_INSERT_TAIL(&fntab, nl, f_next);
354 * Find a device in the list of devices.
356 static struct device *
357 finddev(struct device_head *dlist, char *name)
361 STAILQ_FOREACH(dp, dlist, d_next)
362 if (eq(dp->d_name, name))
369 * Add a device to the list of devices.
376 if (finddev(&dtab, name)) {
378 "WARNING: duplicate device `%s' encountered.\n", name);
382 np = (struct device *) calloc(1, sizeof *np);
384 err(EXIT_FAILURE, "calloc");
386 STAILQ_INSERT_TAIL(&dtab, np, d_next);
390 * Schedule a device to removal.
393 rmdev_schedule(struct device_head *dh, char *name)
397 dp = finddev(dh, name);
399 STAILQ_REMOVE(dh, dp, device, d_next);
406 * Find an option in the list of options.
409 findopt(struct opt_head *list, char *name)
413 SLIST_FOREACH(op, list, op_next)
414 if (eq(op->op_name, name))
421 * Add an option to the list of options.
424 newopt(struct opt_head *list, char *name, char *value, int append)
426 struct opt *op, *op2;
429 * Ignore inclusions listed explicitly for configuration files.
431 if (eq(name, OPT_AUTOGEN)) {
436 op2 = findopt(list, name);
437 if (op2 != NULL && !append) {
439 "WARNING: duplicate option `%s' encountered.\n", name);
443 op = (struct opt *)calloc(1, sizeof (struct opt));
445 err(EXIT_FAILURE, "calloc");
448 op->op_value = value;
450 while (SLIST_NEXT(op2, op_append) != NULL)
451 op2 = SLIST_NEXT(op2, op_append);
452 SLIST_NEXT(op2, op_append) = op;
454 SLIST_INSERT_HEAD(list, op, op_next);
458 * Remove an option from the list of options.
461 rmopt_schedule(struct opt_head *list, char *name)
465 op = findopt(list, name);
467 SLIST_REMOVE(list, op, opt, op_next);