remove (now-)redundant swapgeneric on lint
[unix-history] / usr / src / usr.sbin / config / config.y
CommitLineData
22d68ad0
BJ
1%union {
2 char *str;
3 int val;
36edb824 4 struct file_list *file;
22d68ad0
BJ
5 struct idlst *lst;
6}
7
36edb824
SL
8%token AND
9%token ANY
10%token ARGS
11%token AT
12%token COMMA
13%token CONFIG
14%token CONTROLLER
15%token CPU
16%token CSR
17%token DEVICE
18%token DISK
19%token DRIVE
20%token DST
21%token DUMPS
22%token EQUALS
23%token FLAGS
24%token HZ
25%token IDENT
f025f13d 26%token MACHINE
36edb824
SL
27%token MAJOR
28%token MASTER
29%token MAXUSERS
30%token MBA
31%token MINOR
32%token MINUS
33%token NEXUS
34%token ON
35%token OPTIONS
7c1d4665 36%token MAKEOPTIONS
36edb824
SL
37%token PRIORITY
38%token PSEUDO_DEVICE
39%token ROOT
40%token SEMICOLON
41%token SIZE
42%token SLAVE
43%token SWAP
44%token TIMEZONE
45%token TRACE
46%token UBA
a0105456 47%token VBA
36edb824 48%token VECTOR
22d68ad0
BJ
49
50%token <str> ID
51%token <val> NUMBER
52%token <val> FPNUMBER
53
54%type <str> Save_id
55%type <str> Opt_value
56%type <str> Dev
57%type <lst> Id_list
36edb824
SL
58%type <val> optional_size
59%type <str> device_name
60%type <val> major_minor
61%type <val> arg_device_spec
62%type <val> root_device_spec
63%type <val> dump_device_spec
64%type <file> swap_device_spec
22d68ad0 65
2f47f1cc 66%{
0bf41cfc 67
cd68466f
DF
68/*
69 * Copyright (c) 1980 Regents of the University of California.
70 * All rights reserved. The Berkeley software License Agreement
71 * specifies the terms and conditions for redistribution.
72 *
a0105456 73 * @(#)config.y 5.3 (Berkeley) %G%
cd68466f 74 */
0bf41cfc 75
2f47f1cc 76#include "config.h"
36edb824 77#include <ctype.h>
2f47f1cc 78#include <stdio.h>
f025f13d
BJ
79
80struct device cur;
81struct device *curp = 0;
82char *temp_id;
83char *val_id;
22d68ad0 84char *malloc();
f025f13d 85
2f47f1cc
MT
86%}
87%%
88Configuration:
89 Many_specs
36edb824 90 = { verifysystemspecs(); }
22d68ad0 91 ;
2f47f1cc
MT
92
93Many_specs:
94 Many_specs Spec
22d68ad0
BJ
95 |
96 /* lambda */
97 ;
2f47f1cc
MT
98
99Spec:
22d68ad0
BJ
100 Device_spec SEMICOLON
101 = { newdev(&cur); } |
102 Config_spec SEMICOLON
103 |
104 TRACE SEMICOLON
105 = { do_trace = !do_trace; } |
106 SEMICOLON
107 |
2f47f1cc 108 error SEMICOLON
22d68ad0 109 ;
2f47f1cc
MT
110
111Config_spec:
22d68ad0
BJ
112 MACHINE Save_id
113 = {
0bf41cfc
BJ
114 if (!strcmp($2, "vax")) {
115 machine = MACHINE_VAX;
116 machinename = "vax";
a0105456
SL
117 } else if (!strcmp($2, "tahoe")) {
118 machine = MACHINE_TAHOE;
119 machinename = "tahoe";
0bf41cfc
BJ
120 } else
121 yyerror("Unknown machine type");
22d68ad0
BJ
122 } |
123 CPU Save_id
124 = {
125 struct cputype *cp =
126 (struct cputype *)malloc(sizeof (struct cputype));
127 cp->cpu_name = ns($2);
128 cp->cpu_next = cputype;
129 cputype = cp;
130 free(temp_id);
131 } |
132 OPTIONS Opt_list
133 |
7c1d4665
MK
134 MAKEOPTIONS Mkopt_list
135 |
22d68ad0
BJ
136 IDENT ID
137 = { ident = ns($2); } |
36edb824
SL
138 System_spec
139 |
22d68ad0
BJ
140 HZ NUMBER
141 = { yyerror("HZ specification obsolete; delete"); } |
142 TIMEZONE NUMBER
143 = { timezone = 60 * $2; check_tz(); } |
c00c470f
SL
144 TIMEZONE NUMBER DST NUMBER
145 = { timezone = 60 * $2; dst = $4; check_tz(); } |
22d68ad0
BJ
146 TIMEZONE NUMBER DST
147 = { timezone = 60 * $2; dst = 1; check_tz(); } |
148 TIMEZONE FPNUMBER
149 = { timezone = $2; check_tz(); } |
c00c470f
SL
150 TIMEZONE FPNUMBER DST NUMBER
151 = { timezone = $2; dst = $4; check_tz(); } |
22d68ad0
BJ
152 TIMEZONE FPNUMBER DST
153 = { timezone = $2; dst = 1; check_tz(); } |
154 TIMEZONE MINUS NUMBER
155 = { timezone = -60 * $3; check_tz(); } |
c00c470f
SL
156 TIMEZONE MINUS NUMBER DST NUMBER
157 = { timezone = -60 * $3; dst = $5; check_tz(); } |
22d68ad0
BJ
158 TIMEZONE MINUS NUMBER DST
159 = { timezone = -60 * $3; dst = 1; check_tz(); } |
160 TIMEZONE MINUS FPNUMBER
161 = { timezone = -$3; check_tz(); } |
c00c470f
SL
162 TIMEZONE MINUS FPNUMBER DST NUMBER
163 = { timezone = -$3; dst = $5; check_tz(); } |
22d68ad0
BJ
164 TIMEZONE MINUS FPNUMBER DST
165 = { timezone = -$3; dst = 1; check_tz(); } |
166 MAXUSERS NUMBER
167 = { maxusers = $2; };
2f47f1cc 168
36edb824
SL
169System_spec:
170 System_id System_parameter_list
171 = { checksystemspec(*confp); }
172 ;
173
174System_id:
175 CONFIG Save_id
176 = { mkconf($2); }
177 ;
178
179System_parameter_list:
180 System_parameter_list System_parameter
181 | System_parameter
182 ;
183
184System_parameter:
185 swap_spec
186 | root_spec
187 | dump_spec
188 | arg_spec
189 ;
190
191swap_spec:
192 SWAP optional_on swap_device_list
193 ;
194
195swap_device_list:
196 swap_device_list AND swap_device
197 | swap_device
198 ;
199
200swap_device:
201 swap_device_spec optional_size
202 = { mkswap(*confp, $1, $2); }
203 ;
204
205swap_device_spec:
206 device_name
207 = {
208 struct file_list *fl = newswap();
209
210 if (eq($1, "generic"))
211 fl->f_fn = $1;
212 else {
213 fl->f_swapdev = nametodev($1, 0, 'b');
214 fl->f_fn = devtoname(fl->f_swapdev);
215 }
216 $$ = fl;
217 }
218 | major_minor
219 = {
220 struct file_list *fl = newswap();
221
222 fl->f_swapdev = $1;
223 fl->f_fn = devtoname($1);
224 $$ = fl;
225 }
226 ;
227
228root_spec:
229 ROOT optional_on root_device_spec
230 = {
231 struct file_list *fl = *confp;
232
233 if (fl && fl->f_rootdev != NODEV)
234 yyerror("extraneous root device specification");
235 else
236 fl->f_rootdev = $3;
237 }
238 ;
239
240root_device_spec:
241 device_name
242 = { $$ = nametodev($1, 0, 'a'); }
243 | major_minor
244 ;
245
246dump_spec:
247 DUMPS optional_on dump_device_spec
248 = {
249 struct file_list *fl = *confp;
250
251 if (fl && fl->f_dumpdev != NODEV)
252 yyerror("extraneous dump device specification");
253 else
254 fl->f_dumpdev = $3;
255 }
256
257 ;
258
259dump_device_spec:
260 device_name
261 = { $$ = nametodev($1, 0, 'b'); }
262 | major_minor
263 ;
264
265arg_spec:
266 ARGS optional_on arg_device_spec
267 = {
268 struct file_list *fl = *confp;
269
270 if (fl && fl->f_argdev != NODEV)
271 yyerror("extraneous arg device specification");
272 else
273 fl->f_argdev = $3;
274 }
275 ;
276
277arg_device_spec:
278 device_name
279 = { $$ = nametodev($1, 0, 'b'); }
280 | major_minor
281 ;
282
283major_minor:
284 MAJOR NUMBER MINOR NUMBER
285 = { $$ = makedev($2, $4); }
286 ;
287
288optional_on:
289 ON
290 | /* empty */
291 ;
292
293optional_size:
294 SIZE NUMBER
295 = { $$ = $2; }
296 | /* empty */
297 = { $$ = 0; }
298 ;
299
300device_name:
301 Save_id
302 = { $$ = $1; }
303 | Save_id NUMBER
304 = {
305 char buf[80];
306
307 (void) sprintf(buf, "%s%d", $1, $2);
308 $$ = ns(buf); free($1);
309 }
310 | Save_id NUMBER ID
311 = {
312 char buf[80];
313
314 (void) sprintf(buf, "%s%d%s", $1, $2, $3);
315 $$ = ns(buf); free($1);
316 }
317 ;
318
b1e602f2 319Opt_list:
22d68ad0
BJ
320 Opt_list COMMA Option
321 |
b1e602f2 322 Option
22d68ad0 323 ;
b1e602f2
MT
324
325Option:
22d68ad0
BJ
326 Save_id
327 = {
328 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
329 op->op_name = ns($1);
330 op->op_next = opt;
331 op->op_value = 0;
332 opt = op;
333 free(temp_id);
334 } |
335 Save_id EQUALS Opt_value
336 = {
337 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
338 op->op_name = ns($1);
339 op->op_next = opt;
340 op->op_value = ns($3);
341 opt = op;
342 free(temp_id);
343 free(val_id);
344 } ;
b1e602f2 345
841254c0 346Opt_value:
22d68ad0
BJ
347 ID
348 = { $$ = val_id = ns($1); } |
349 NUMBER
350 = { char nb[16]; $$ = val_id = ns(sprintf(nb, "%d", $1)); };
841254c0
RE
351
352
2f47f1cc 353Save_id:
22d68ad0
BJ
354 ID
355 = { $$ = temp_id = ns($1); }
2f47f1cc 356 ;
7c1d4665
MK
357
358Mkopt_list:
359 Mkopt_list COMMA Mkoption
360 |
361 Mkoption
362 ;
363
364Mkoption:
365 Save_id EQUALS Opt_value
366 = {
367 struct opt *op = (struct opt *)malloc(sizeof (struct opt));
368 op->op_name = ns($1);
369 op->op_next = mkopt;
370 op->op_value = ns($3);
371 mkopt = op;
372 free(temp_id);
373 free(val_id);
374 } ;
2f47f1cc
MT
375
376Dev:
22d68ad0
BJ
377 UBA
378 = { $$ = ns("uba"); } |
a0105456
SL
379 VBA
380 = { $$ = ns("vba"); } |
22d68ad0
BJ
381 MBA
382 = { $$ = ns("mba"); } |
383 ID
384 = { $$ = ns($1); }
2f47f1cc
MT
385 ;
386
387Device_spec:
22d68ad0
BJ
388 DEVICE Dev_name Dev_info Int_spec
389 = { cur.d_type = DEVICE; } |
390 MASTER Dev_name Dev_info Int_spec
391 = { cur.d_type = MASTER; } |
392 DISK Dev_name Dev_info Int_spec
393 = { cur.d_dk = 1; cur.d_type = DEVICE; } |
394 CONTROLLER Dev_name Dev_info Int_spec
395 = { cur.d_type = CONTROLLER; } |
396 PSEUDO_DEVICE Init_dev Dev
397 = {
398 cur.d_name = $3;
399 cur.d_type = PSEUDO_DEVICE;
400 } |
401 PSEUDO_DEVICE Init_dev Dev NUMBER
402 = {
403 cur.d_name = $3;
404 cur.d_type = PSEUDO_DEVICE;
405 cur.d_slave = $4;
406 };
2f47f1cc
MT
407
408Dev_name:
22d68ad0
BJ
409 Init_dev Dev NUMBER
410 = {
411 cur.d_name = $2;
412 if (eq($2, "mba"))
413 seen_mba = 1;
414 else if (eq($2, "uba"))
415 seen_uba = 1;
a0105456
SL
416 else if (eq($2, "vba"))
417 seen_vba = 1;
22d68ad0
BJ
418 cur.d_unit = $3;
419 };
2f47f1cc
MT
420
421Init_dev:
22d68ad0
BJ
422 /* lambda */
423 = { init_dev(&cur); };
2f47f1cc
MT
424
425Dev_info:
426 Con_info Info_list
22d68ad0
BJ
427 |
428 /* lambda */
429 ;
2f47f1cc
MT
430
431Con_info:
22d68ad0
BJ
432 AT Dev NUMBER
433 = {
b1e602f2
MT
434 if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba"))
435 yyerror(sprintf(errbuf,
22d68ad0 436 "%s must be connected to a nexus", cur.d_name));
b1e602f2 437 cur.d_conn = connect($2, $3);
22d68ad0
BJ
438 } |
439 AT NEXUS NUMBER
440 = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; };
2f47f1cc
MT
441
442Info_list:
443 Info_list Info
22d68ad0
BJ
444 |
445 /* lambda */
446 ;
2f47f1cc
MT
447
448Info:
22d68ad0
BJ
449 CSR NUMBER
450 = { cur.d_addr = $2; } |
451 DRIVE NUMBER
452 = { cur.d_drive = $2; } |
453 SLAVE NUMBER
454 = {
455 if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS &&
456 cur.d_conn->d_type == MASTER)
b1e602f2
MT
457 cur.d_slave = $2;
458 else
459 yyerror("can't specify slave--not to master");
22d68ad0
BJ
460 } |
461 FLAGS NUMBER
462 = { cur.d_flags = $2; };
2f47f1cc
MT
463
464Int_spec:
22d68ad0
BJ
465 VECTOR Id_list
466 = { cur.d_vec = $2; } |
467 PRIORITY NUMBER
468 = { cur.d_pri = $2; } |
469 /* lambda */
470 ;
08f9a943
BJ
471
472Id_list:
22d68ad0
BJ
473 Save_id
474 = {
475 struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
476 a->id = $1; a->id_next = 0; $$ = a;
477 } |
08f9a943 478 Save_id Id_list =
22d68ad0
BJ
479 {
480 struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
481 a->id = $1; a->id_next = $2; $$ = a;
482 };
483
2f47f1cc
MT
484%%
485
486yyerror(s)
f025f13d 487 char *s;
2f47f1cc 488{
f025f13d 489
36edb824 490 fprintf(stderr, "config: line %d: %s\n", yyline, s);
2f47f1cc
MT
491}
492
493/*
f025f13d 494 * return the passed string in a new space
2f47f1cc 495 */
2f47f1cc
MT
496char *
497ns(str)
f025f13d 498 register char *str;
2f47f1cc
MT
499{
500 register char *cp;
501
22d68ad0
BJ
502 cp = malloc((unsigned)(strlen(str)+1));
503 (void) strcpy(cp, str);
504 return (cp);
2f47f1cc
MT
505}
506
507/*
f025f13d 508 * add a device to the list of devices
2f47f1cc 509 */
2f47f1cc 510newdev(dp)
f025f13d 511 register struct device *dp;
2f47f1cc
MT
512{
513 register struct device *np;
514
515 np = (struct device *) malloc(sizeof *np);
516 *np = *dp;
f025f13d 517 if (curp == 0)
b1e602f2
MT
518 dtab = np;
519 else
520 curp->d_next = np;
521 curp = np;
2f47f1cc
MT
522}
523
524/*
f025f13d 525 * note that a configuration should be made
2f47f1cc 526 */
36edb824
SL
527mkconf(sysname)
528 char *sysname;
2f47f1cc 529{
36edb824 530 register struct file_list *fl, **flp;
2f47f1cc
MT
531
532 fl = (struct file_list *) malloc(sizeof *fl);
36edb824
SL
533 fl->f_type = SYSTEMSPEC;
534 fl->f_needs = sysname;
535 fl->f_rootdev = NODEV;
536 fl->f_argdev = NODEV;
537 fl->f_dumpdev = NODEV;
538 fl->f_fn = 0;
539 fl->f_next = 0;
540 for (flp = confp; *flp; flp = &(*flp)->f_next)
541 ;
542 *flp = fl;
543 confp = flp;
544}
545
546struct file_list *
547newswap()
548{
549 struct file_list *fl = (struct file_list *)malloc(sizeof (*fl));
550
551 fl->f_type = SWAPSPEC;
552 fl->f_next = 0;
553 fl->f_swapdev = NODEV;
554 fl->f_swapsize = 0;
555 fl->f_needs = 0;
556 fl->f_fn = 0;
557 return (fl);
558}
559
560/*
561 * Add a swap device to the system's configuration
562 */
563mkswap(system, fl, size)
564 struct file_list *system, *fl;
565 int size;
566{
567 register struct file_list **flp;
568 char *cp, name[80];
569
570 if (system == 0 || system->f_type != SYSTEMSPEC) {
571 yyerror("\"swap\" spec precedes \"config\" specification");
572 return;
573 }
574 if (size < 0) {
575 yyerror("illegal swap partition size");
576 return;
577 }
578 /*
579 * Append swap description to the end of the list.
580 */
581 flp = &system->f_next;
582 for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next)
583 ;
584 fl->f_next = *flp;
585 *flp = fl;
8df5b824 586 fl->f_swapsize = size;
36edb824
SL
587 /*
588 * If first swap device for this system,
589 * set up f_fn field to insure swap
590 * files are created with unique names.
591 */
592 if (system->f_fn)
593 return;
594 if (eq(fl->f_fn, "generic"))
595 system->f_fn = ns(fl->f_fn);
2f47f1cc 596 else
36edb824 597 system->f_fn = ns(system->f_needs);
2f47f1cc
MT
598}
599
600/*
f025f13d
BJ
601 * find the pointer to connect to the given device and number.
602 * returns 0 if no such device and prints an error message
2f47f1cc 603 */
f025f13d
BJ
604struct device *
605connect(dev, num)
606 register char *dev;
607 register int num;
2f47f1cc
MT
608{
609 register struct device *dp;
f6f4af06 610 struct device *huhcon();
2f47f1cc 611
a5e18d6b 612 if (num == QUES)
f025f13d
BJ
613 return (huhcon(dev));
614 for (dp = dtab; dp != 0; dp = dp->d_next) {
615 if ((num != dp->d_unit) || !eq(dev, dp->d_name))
616 continue;
617 if (dp->d_type != CONTROLLER && dp->d_type != MASTER) {
a5e18d6b
MT
618 yyerror(sprintf(errbuf,
619 "%s connected to non-controller", dev));
f025f13d
BJ
620 return (0);
621 }
622 return (dp);
623 }
2f47f1cc 624 yyerror(sprintf(errbuf, "%s %d not defined", dev, num));
f025f13d 625 return (0);
2f47f1cc 626}
f6f4af06
MT
627
628/*
f025f13d 629 * connect to an unspecific thing
f6f4af06 630 */
f025f13d
BJ
631struct device *
632huhcon(dev)
633 register char *dev;
f6f4af06 634{
f025f13d
BJ
635 register struct device *dp, *dcp;
636 struct device rdev;
637 int oldtype;
638
f6f4af06 639 /*
f025f13d 640 * First make certain that there are some of these to wildcard on
f6f4af06 641 */
f025f13d
BJ
642 for (dp = dtab; dp != 0; dp = dp->d_next)
643 if (eq(dp->d_name, dev))
644 break;
645 if (dp == 0) {
646 yyerror(sprintf(errbuf, "no %s's to wildcard", dev));
647 return (0);
648 }
649 oldtype = dp->d_type;
650 dcp = dp->d_conn;
651 /*
652 * Now see if there is already a wildcard entry for this device
653 * (e.g. Search for a "uba ?")
654 */
655 for (; dp != 0; dp = dp->d_next)
656 if (eq(dev, dp->d_name) && dp->d_unit == -1)
657 break;
658 /*
659 * If there isn't, make one because everything needs to be connected
660 * to something.
661 */
662 if (dp == 0) {
663 dp = &rdev;
664 init_dev(dp);
665 dp->d_unit = QUES;
666 dp->d_name = ns(dev);
667 dp->d_type = oldtype;
668 newdev(dp);
669 dp = curp;
670 /*
671 * Connect it to the same thing that other similar things are
672 * connected to, but make sure it is a wildcard unit
673 * (e.g. up connected to sc ?, here we make connect sc? to a
674 * uba?). If other things like this are on the NEXUS or
675 * if they aren't connected to anything, then make the same
676 * connection, else call ourself to connect to another
677 * unspecific device.
678 */
679 if (dcp == TO_NEXUS || dcp == 0)
680 dp->d_conn = dcp;
681 else
682 dp->d_conn = connect(dcp->d_name, QUES);
683 }
684 return (dp);
f6f4af06
MT
685}
686
687init_dev(dp)
f025f13d 688 register struct device *dp;
f6f4af06 689{
f025f13d
BJ
690
691 dp->d_name = "OHNO!!!";
692 dp->d_type = DEVICE;
693 dp->d_conn = 0;
694 dp->d_vec = 0;
695 dp->d_addr = dp->d_pri = dp->d_flags = dp->d_dk = 0;
696 dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN;
a5e18d6b
MT
697}
698
699/*
f025f13d 700 * make certain that this is a reasonable type of thing to connect to a nexus
a5e18d6b 701 */
a5e18d6b 702check_nexus(dev, num)
f025f13d
BJ
703 register struct device *dev;
704 int num;
a5e18d6b 705{
f025f13d 706
0bf41cfc 707 switch (machine) {
f025f13d 708
0bf41cfc
BJ
709 case MACHINE_VAX:
710 if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba"))
711 yyerror("only uba's and mba's should be connected to the nexus");
712 if (num != QUES)
713 yyerror("can't give specific nexus numbers");
714 break;
715
a0105456
SL
716 case MACHINE_TAHOE:
717 if (!eq(dev->d_name, "vba"))
718 yyerror("only vba's should be connected to the nexus");
0bf41cfc
BJ
719 break;
720 }
f6f4af06 721}
b1e602f2
MT
722
723/*
724 * Check the timezone to make certain it is sensible
725 */
726
727check_tz()
728{
841254c0 729 if (abs(timezone) > 12 * 60)
b1e602f2
MT
730 yyerror("timezone is unreasonable");
731 else
f025f13d 732 hadtz = 1;
b1e602f2 733}
36edb824
SL
734
735/*
736 * Check system specification and apply defaulting
737 * rules on root, argument, dump, and swap devices.
738 */
739checksystemspec(fl)
740 register struct file_list *fl;
741{
742 char buf[BUFSIZ];
743 register struct file_list *swap;
744 int generic;
745
746 if (fl == 0 || fl->f_type != SYSTEMSPEC) {
747 yyerror("internal error, bad system specification");
748 exit(1);
749 }
750 swap = fl->f_next;
751 generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic");
752 if (fl->f_rootdev == NODEV && !generic) {
753 yyerror("no root device specified");
754 exit(1);
755 }
756 /*
757 * Default swap area to be in 'b' partition of root's
758 * device. If root specified to be other than on 'a'
759 * partition, give warning, something probably amiss.
760 */
761 if (swap == 0 || swap->f_type != SWAPSPEC) {
762 dev_t dev;
763
764 swap = newswap();
765 dev = fl->f_rootdev;
766 if (minor(dev) & 07) {
767 sprintf(buf,
768"Warning, swap defaulted to 'b' partition with root on '%c' partition",
769 (minor(dev) & 07) + 'a');
770 yyerror(buf);
771 }
772 swap->f_swapdev =
773 makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a'));
774 swap->f_fn = devtoname(swap->f_swapdev);
775 mkswap(fl, swap, 0);
776 }
777 /*
778 * Make sure a generic swap isn't specified, along with
779 * other stuff (user must really be confused).
780 */
781 if (generic) {
782 if (fl->f_rootdev != NODEV)
783 yyerror("root device specified with generic swap");
784 if (fl->f_argdev != NODEV)
785 yyerror("arg device specified with generic swap");
786 if (fl->f_dumpdev != NODEV)
787 yyerror("dump device specified with generic swap");
788 return;
789 }
790 /*
791 * Default argument device and check for oddball arrangements.
792 */
793 if (fl->f_argdev == NODEV)
794 fl->f_argdev = swap->f_swapdev;
795 if (fl->f_argdev != swap->f_swapdev)
796 yyerror("Warning, arg device different than primary swap");
797 /*
798 * Default dump device and warn if place is not a
799 * swap area or the argument device partition.
800 */
801 if (fl->f_dumpdev == NODEV)
802 fl->f_dumpdev = swap->f_swapdev;
803 if (fl->f_dumpdev != swap->f_swapdev && fl->f_dumpdev != fl->f_argdev) {
804 struct file_list *p = swap->f_next;
805
806 for (; p && p->f_type == SWAPSPEC; p = p->f_next)
807 if (fl->f_dumpdev == p->f_swapdev)
808 return;
809 sprintf(buf, "Warning, orphaned dump device, %s",
810 "do you know what you're doing");
811 yyerror(buf);
812 }
813}
814
815/*
816 * Verify all devices specified in the system specification
817 * are present in the device specifications.
818 */
819verifysystemspecs()
820{
821 register struct file_list *fl;
822 dev_t checked[50], *verifyswap();
823 register dev_t *pchecked = checked;
824
825 for (fl = conf_list; fl; fl = fl->f_next) {
826 if (fl->f_type != SYSTEMSPEC)
827 continue;
828 if (!finddev(fl->f_rootdev))
829 deverror(fl->f_needs, "root");
830 *pchecked++ = fl->f_rootdev;
831 pchecked = verifyswap(fl->f_next, checked, pchecked);
832#define samedev(dev1, dev2) \
833 ((minor(dev1) &~ 07) != (minor(dev2) &~ 07))
834 if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) {
835 if (!finddev(fl->f_dumpdev))
836 deverror(fl->f_needs, "dump");
837 *pchecked++ = fl->f_dumpdev;
838 }
839 if (!alreadychecked(fl->f_argdev, checked, pchecked)) {
840 if (!finddev(fl->f_argdev))
841 deverror(fl->f_needs, "arg");
842 *pchecked++ = fl->f_argdev;
843 }
844 }
845}
846
847/*
848 * Do as above, but for swap devices.
849 */
850dev_t *
851verifyswap(fl, checked, pchecked)
852 register struct file_list *fl;
853 dev_t checked[];
854 register dev_t *pchecked;
855{
856
857 for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) {
858 if (eq(fl->f_fn, "generic"))
859 continue;
860 if (alreadychecked(fl->f_swapdev, checked, pchecked))
861 continue;
862 if (!finddev(fl->f_swapdev))
863 fprintf(stderr,
864 "config: swap device %s not configured", fl->f_fn);
865 *pchecked++ = fl->f_swapdev;
866 }
867 return (pchecked);
868}
869
870/*
871 * Has a device already been checked
872 * for it's existence in the configuration?
873 */
874alreadychecked(dev, list, last)
875 dev_t dev, list[];
876 register dev_t *last;
877{
878 register dev_t *p;
879
880 for (p = list; p < last; p++)
881 if (samedev(*p, dev))
882 return (1);
883 return (0);
884}
885
886deverror(systemname, devtype)
887 char *systemname, *devtype;
888{
889
890 fprintf(stderr, "config: %s: %s device not configured\n",
891 systemname, devtype);
892}
893
894/*
895 * Look for the device in the list of
896 * configured hardware devices. Must
897 * take into account stuff wildcarded.
898 */
899finddev(dev)
900 dev_t dev;
901{
902
903 /* punt on this right now */
904 return (1);
905}