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