Annotation of cci/usr/src/etc/config/config.y, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.