4 struct file_list *file;
39 * Copyright (c) 1988, 1993
40 * The Regents of the University of California. All rights reserved.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in the
49 * documentation and/or other materials provided with the distribution.
50 * 3. All advertising materials mentioning features or use of this software
51 * must display the following acknowledgement:
52 * This product includes software developed by the University of
53 * California, Berkeley and its contributors.
54 * 4. Neither the name of the University nor the names of its contributors
55 * may be used to endorse or promote products derived from this software
56 * without specific prior written permission.
58 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 * @(#)config.y 8.1 (Berkeley) 6/6/93
82 struct device_head dtab;
89 struct file_list_head ftab;
90 struct files_name_head fntab;
94 #define ns(s) strdup(s)
95 int include(const char *, int);
96 void yyerror(const char *s);
99 static void newdev(char *name);
100 static void newfile(char *name);
101 static void rmdev_schedule(struct device_head *dh, char *name);
102 static void newopt(struct opt_head *list, char *name, char *value);
103 static void rmopt_schedule(struct opt_head *list, char *name);
108 char *ret = malloc(strlen(dev) + 5);
110 sprintf(ret, "DEV_%s", dev);
128 Device_spec SEMICOLON
130 Config_spec SEMICOLON
132 INCLUDE PATH SEMICOLON {
137 INCLUDE ID SEMICOLON {
142 FILES ID SEMICOLON { newfile($2); };
151 if (machinename != NULL && !eq($2, machinename))
152 errx(1, "%s:%d: only one machine directive is allowed",
157 ARCH Save_id Save_id {
158 if (machinename != NULL &&
159 !(eq($2, machinename) && eq($3, machinearch)))
160 errx(1, "%s:%d: only one machine directive is allowed",
167 (struct cputype *)calloc(1, sizeof (struct cputype));
169 SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
172 struct cputype *cp, *cp2;
173 SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) {
174 if (eq(cp->cpu_name, $2)) {
175 SLIST_REMOVE(&cputype, cp, cputype, cpu_next);
182 NOOPTION Save_id { rmopt_schedule(&opt, $2); } |
183 MAKEOPTIONS Mkopt_list
185 NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } |
186 IDENT ID { ident = $2; } |
189 MAXUSERS NUMBER { maxusers = $2; } |
190 PROFILE NUMBER { profiling = $2; } |
198 hint = (struct hint *)calloc(1, sizeof (struct hint));
199 hint->hint_name = $2;
200 STAILQ_INSERT_TAIL(&hints, hint, hint_next);
205 CONFIG System_id System_parameter_list {
206 errx(1, "%s:%d: root/dump/swap specifications obsolete",
214 Save_id { newopt(&mkopt, ns("KERNEL"), $1); };
216 System_parameter_list:
217 System_parameter_list ID
222 Opt_list COMMA Option
229 newopt(&opt, $1, NULL);
230 if (strchr($1, '=') != NULL)
231 errx(1, "%s:%d: The `=' in options should not be "
232 "quoted", yyfile, yyline);
234 Save_id EQUALS Opt_value {
235 newopt(&opt, $1, $3);
243 (void) snprintf(buf, sizeof(buf), "%d", $1);
252 Mkopt_list COMMA Mkoption
258 Save_id { newopt(&mkopt, $1, ns("")); } |
259 Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3); } ;
272 Dev_list COMMA Device
278 NoDev_list COMMA NoDevice
285 newopt(&opt, devopt($1), ns("1"));
286 /* and the device part */
292 char *s = devopt($1);
294 rmopt_schedule(&opt, s);
296 /* and the device part */
297 rmdev_schedule(&dtab, $1);
303 yyerror(const char *s)
306 errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
312 if (found_defaults) {
313 if (freopen(PREFIX, "r", stdin) == NULL)
314 err(2, "%s", PREFIX);
324 * Add a new file to the list of files.
329 struct files_name *nl;
331 nl = (struct files_name *) calloc(1, sizeof *nl);
333 STAILQ_INSERT_TAIL(&fntab, nl, f_next);
337 * Find a device in the list of devices.
339 static struct device *
340 finddev(struct device_head *dlist, char *name)
344 STAILQ_FOREACH(dp, dlist, d_next)
345 if (eq(dp->d_name, name))
352 * Add a device to the list of devices.
359 if (finddev(&dtab, name)) {
360 printf("WARNING: duplicate device `%s' encountered.\n", name);
364 np = (struct device *) calloc(1, sizeof *np);
366 STAILQ_INSERT_TAIL(&dtab, np, d_next);
370 * Schedule a device to removal.
373 rmdev_schedule(struct device_head *dh, char *name)
377 dp = finddev(dh, name);
379 STAILQ_REMOVE(dh, dp, device, d_next);
386 * Find an option in the list of options.
389 findopt(struct opt_head *list, char *name)
393 SLIST_FOREACH(op, list, op_next)
394 if (eq(op->op_name, name))
401 * Add an option to the list of options.
404 newopt(struct opt_head *list, char *name, char *value)
409 * Ignore inclusions listed explicitly for configuration files.
411 if (eq(name, OPT_AUTOGEN)) {
416 if (findopt(list, name)) {
417 printf("WARNING: duplicate option `%s' encountered.\n", name);
421 op = (struct opt *)calloc(1, sizeof (struct opt));
424 op->op_value = value;
425 SLIST_INSERT_HEAD(list, op, op_next);
429 * Remove an option from the list of options.
432 rmopt_schedule(struct opt_head *list, char *name)
436 op = findopt(list, name);
438 SLIST_REMOVE(list, op, opt, op_next);