Annotation of cci/sys/stand/vdfmt/proc_cmd.c, revision 1.1.1.1

1.1       root        1: #include       "vdfmt.h"
                      2: #include       "cmd.h"
                      3: 
                      4: #define        RESET           1
                      5: #define        LIST            2
                      6: #define        DELETE          3
                      7: #define        FORMAT          4
                      8: #define        VERIFY          5
                      9: #define        RELOCATE        6
                     10: #define        CORRECT         7
                     11: #define        INFO            8
                     12: #define        PROFILE         9
                     13: #define        EXERCISE        10
                     14: #define        START           11
                     15: 
                     16: static cmd_text_element        commands[] = {
                     17:        { RESET,     "RESET",     "Reinitialize VDFORMAT, and start over" },
                     18:        { LIST,      "List",      "List operations specified so far" },
                     19:        { DELETE,    "Delete",    "Delete specific operations" },
                     20:        { FORMAT,    "Format",    "Format and verify disk surface" },
                     21:        { VERIFY,    "Verify",    "Destructively verify disk surface" },
                     22:        { RELOCATE,  "Relocate",  "Add known flaws to bad sector map" },
                     23:        { CORRECT,   "Correct",   "Correct erroneous relocations or drive ID" },
                     24:        { INFO,      "Info",      "Display known disk information" },
                     25:        { PROFILE,   "Profile",   "Display seek profile graph of disk" },
                     26:        { EXERCISE,  "Exercise",  "Perform seek exercises on disk" },
                     27:        { START,     "STARt",     "Start operations" },
                     28:        { 0,         "",          "" }
                     29: };
                     30: 
                     31: static cmd_text_element        drive_types[20];
                     32: 
                     33: 
                     34: /*
                     35: **
                     36: */
                     37: 
                     38: process_commands()
                     39: {
                     40:        int     type, tokens[20];
                     41:        int     *tok_ptr, count;
                     42:        int     op_mask = 0;
                     43:        char    *cptr;
                     44:        boolean should_start = false;
                     45: 
                     46:        for(type=0; type<nvddrv; type++) {
                     47:                drive_types[type].cmd_token = (int)&vdst[type];
                     48:                drive_types[type].cmd_text = vdst[type].type_name;
                     49:                cptr = drive_types[type].cmd_text;
                     50:                while(*cptr) {
                     51:                        *cptr = toupper(*cptr);
                     52:                        cptr++;
                     53:                }
                     54:                drive_types[type].cmd_help = vdst[type].type_discript;
                     55:        }
                     56:        drive_types[type].cmd_token = 0;
                     57:        for(;;) {
                     58:                cur.state = cmd;
                     59:                kill_processes = false;
                     60:                exdent(-1);
                     61:                op_mask = 0;
                     62:                print("Operation? ");
                     63:                count = get_text_cmd(commands, tokens);
                     64:                if(kill_processes == true)
                     65:                        _longjmp(quit_environ, 1);
                     66:                tok_ptr = tokens;
                     67:                if((*tok_ptr == 0) || !count)
                     68:                        continue;
                     69:                while(*tok_ptr) {
                     70:                        switch (*tok_ptr) {
                     71:                        case RESET :
                     72:                                reset();
                     73:                                break;
                     74:                        case LIST :
                     75:                                list();
                     76:                                break;
                     77:                        case DELETE :
                     78:                                delete();
                     79:                                break;
                     80:                        case FORMAT :
                     81:                                op_mask |= FORMAT_OP;
                     82:                                break;
                     83:                        case VERIFY :
                     84:                                op_mask |= VERIFY_OP;
                     85:                                break;
                     86:                        case RELOCATE :
                     87:                                op_mask |= RELOCATE_OP;
                     88:                                break;
                     89:                        case CORRECT :
                     90:                                op_mask |= CORRECT_OP;
                     91:                                break;
                     92:                        case INFO :
                     93:                                op_mask |= INFO_OP;
                     94:                                break;
                     95:                        case PROFILE :
                     96:                                op_mask |= PROFILE_OP;
                     97:                                break;
                     98:                        case EXERCISE :
                     99:                                op_mask |= EXERCISE_OP;
                    100:                                break;
                    101:                        case START :
                    102:                                should_start = true;
                    103:                                break;
                    104:                        default:                /* ignore */
                    105:                                break;
                    106:                        }
                    107:                tok_ptr++;
                    108:                }
                    109:                if(op_mask) {
                    110:                        get_drive_parameters(op_mask);
                    111:                }
                    112:                if(should_start) {
                    113:                        start_commands();
                    114:                        should_start = false;
                    115:                }
                    116:        }
                    117: }
                    118: 
                    119: 
                    120: /*
                    121: **
                    122: */
                    123: 
                    124: static boolean header_printed = false;
                    125: 
                    126: get_drive_parameters(op_mask)
                    127: int    op_mask;
                    128: {
                    129:        int     c_list[20], i, num_pat;
                    130: 
                    131:        indent();
                    132:        header_printed = false;
                    133:        get_ctlr_list(c_list, op_mask);
                    134:        if(kill_processes == true) {
                    135:                kill_processes = false;
                    136:                c_list[0]= -1;
                    137:        }
                    138:        for(i=0; c_list[i] != -1; i++) {
                    139:                int     d_list[40], j;
                    140: 
                    141:                indent();
                    142:                get_drive_list(c_list[i], d_list, op_mask);
                    143:                if(kill_processes == true) {
                    144:                        kill_processes = false;
                    145:                        break;
                    146:                }
                    147:                indent();
                    148:                if(op_mask & (FORMAT_OP | VERIFY_OP)) {
                    149:                        num_pat = get_num_pat();
                    150:                        if(kill_processes == true) {
                    151:                                kill_processes = false;
                    152:                                break;
                    153:                        }
                    154:                }
                    155:                for(j=0; d_list[j] != -1; j++) {
                    156:                        get_drive_type(c_list[i], d_list[j]);
                    157:                        if(kill_processes == true) {
                    158:                                kill_processes = false;
                    159:                                break;
                    160:                        }
                    161:                        if(op_mask & ~INFO_OP) {
                    162:                                indent();
                    163:                                get_drive_id(c_list[i], d_list[j]);
                    164:                                if(kill_processes == true) {
                    165:                                        kill_processes = false;
                    166:                                        break;
                    167:                                }
                    168:                                exdent(1);
                    169:                        }
                    170:                        ops_to_do[c_list[i]][d_list[j]].op |= op_mask;
                    171:                        if(op_mask & (FORMAT_OP | VERIFY_OP))
                    172:                                ops_to_do[c_list[i]][d_list[j]].numpat=num_pat;
                    173:                }
                    174:                exdent(1);
                    175:        }
                    176:        exdent(2);
                    177: }
                    178: 
                    179: /*
                    180: **
                    181: */
                    182: 
                    183: get_ctlr_list(c_list, op_mask)
                    184: int    *c_list, op_mask;
                    185: {
                    186:        extern int      ctlr_help();
                    187:        register int    i, ctlr;
                    188:        int             table[MAXCTLR+10];
                    189: 
                    190:        i = 0;
                    191:        for(ctlr=0; ctlr<MAXCTLR; ctlr++)
                    192:                if(c_info[ctlr].alive == u_true)
                    193:                        table[i++] = ctlr;
                    194:        table[i] = -1;
                    195:        /* If only one controller is possible don't ask */
                    196:        if(table[1] == -1) {
                    197:                *c_list++ = table[0];
                    198:                *c_list = -1;
                    199:                return;
                    200:        }
                    201:        for(;;) {
                    202:                header_printed = true;
                    203:                print("");  /* Force indent */
                    204:                print_op_list(op_mask);
                    205:                printf(" on which controllers? ");
                    206:                get_digit_list(c_list, table, ctlr_help);
                    207:                if(kill_processes == true)
                    208:                        return;
                    209:                if(*c_list != -1)
                    210:                        break;
                    211:        }
                    212: }
                    213: 
                    214: 
                    215: /*
                    216: **
                    217: */
                    218: 
                    219: ctlr_help()
                    220: {
                    221:        register int    ctlr;
                    222: 
                    223:        indent();
                    224:        print("The following controllers are attached to the system:\n");
                    225:        indent();
                    226:        for(ctlr=0; ctlr<MAXCTLR; ctlr++)
                    227:                if(c_info[ctlr].alive == u_true) {
                    228:                        print("Controller %d, which is a%s %s controller.\n",
                    229:                            ctlr, (c_info[ctlr].name[0] == 'S') ? "n" : "",
                    230:                            c_info[ctlr].name);
                    231:                }
                    232:        print("\n");
                    233:        exdent(2);
                    234: }
                    235: 
                    236: static int     max_drive = 0;
                    237: 
                    238: /*
                    239: **
                    240: */
                    241: 
                    242: get_drive_list(ctlr, d_list, op_mask)
                    243: int    ctlr, *d_list, op_mask;
                    244: {
                    245:        extern int      drive_help();
                    246:        int             table[MAXDRIVE+10];
                    247:        int             i;
                    248: 
                    249:        max_drive = (c_info[ctlr].type == SMDCTLR) ? 4 : 16;
                    250:        for(i=0; i<max_drive; i++)
                    251:                table[i] = i;
                    252:        table[i] = -1;
                    253:        for(;;) {
                    254:                if(header_printed == true)
                    255:                        print("Drives on controller %d? ", ctlr);
                    256:                else {
                    257:                        header_printed = true;
                    258:                        print("");  /* Force indent */
                    259:                        print_op_list(op_mask);
                    260:                        printf(" on which drives? ");
                    261:                }
                    262:                get_digit_list(d_list, table, drive_help);
                    263:                if(kill_processes == true)
                    264:                        return;
                    265:                if(*d_list != -1)
                    266:                        break;
                    267:        }
                    268: }
                    269: 
                    270: 
                    271: /*
                    272: **
                    273: */
                    274: 
                    275: get_drive_type(ctlr, drive)
                    276: int    ctlr, drive;
                    277: {
                    278:        int     tokens[20];
                    279:        int     count;
                    280: 
                    281:        for(;;) {
                    282:                print("Drive type for controller %d, drive %d? ", ctlr, drive);
                    283:                if(d_info[ctlr][drive].info != 0)
                    284:                        printf("(%s) ", d_info[ctlr][drive].info->type_name);
                    285:                if(c_info[ctlr].type == SMDCTLR)
                    286:                        count = get_text_cmd(drive_types+2, tokens);
                    287:                else
                    288:                        count = get_text_cmd(drive_types, tokens);
                    289:                if(kill_processes == true)
                    290:                        return;
                    291:                if(!*tokens && (d_info[ctlr][drive].info != 0) && !count)
                    292:                        break;
                    293:                if(d_info[ctlr][drive].info = (fs_tab *)*tokens)
                    294:                        break;
                    295:        }
                    296: }
                    297: 
                    298: 
                    299: 
                    300: /*
                    301: **
                    302: */
                    303: 
                    304: id_help()
                    305: {
                    306:        indent();
                    307:        print("The following commands are available:\n");
                    308:        indent();
                    309:        print("STATus - Display formatter state.\n");
                    310:        print("QUIT   - Terminate current operation.\n");
                    311:        print("");
                    312:        print("A module serial can be any number greater than zero.\n");
                    313:        exdent(2);
                    314: }
                    315: 
                    316: 
                    317: /*
                    318: **
                    319: */
                    320: 
                    321: get_drive_id(ctlr, drive)
                    322: int    ctlr, drive;
                    323: {
                    324:        int     new_id;
                    325: 
                    326:        for(;;) {
                    327:                print("Module serial number for controller %d, drive %d? ",
                    328:                    ctlr, drive);
                    329:                if(d_info[ctlr][drive].id != -1)
                    330:                        printf("(%d) ", d_info[ctlr][drive].id);
                    331:                new_id = get_digit_cmd(id_help);
                    332:                if(new_id > 0) {
                    333:                        d_info[ctlr][drive].id = new_id;
                    334:                        break;
                    335:                }
                    336:                else if(d_info[ctlr][drive].id != -1) 
                    337:                        break;
                    338:        }
                    339: }
                    340: 
                    341: 
                    342: /*
                    343: **
                    344: */
                    345: 
                    346: drive_help()
                    347: {
                    348:        indent();
                    349:        print("Drive numbers 0 through %d may be entered.\n", max_drive-1);
                    350:        exdent(1);
                    351: }
                    352: 
                    353: 
                    354: /*
                    355: **
                    356: */
                    357: 
                    358: pat_help()
                    359: {
                    360:        indent();
                    361:        print("Between 0 and 16 patterns may be used while verifying.\n");
                    362:        exdent(1);
                    363: }
                    364: 
                    365: 
                    366: /*
                    367: **
                    368: */
                    369: 
                    370: get_num_pat()
                    371: {
                    372:        int     table[17+10];
                    373:        int     results[17+10];
                    374:        int     i;
                    375: 
                    376:        for(i=0; i<=16; i++)
                    377:                table[i] = i;
                    378:        table[i] = -1;
                    379:        for(;;) {
                    380:                print("Number of patterns to use while verifying? ");
                    381:                get_digit_list(results, table, pat_help);
                    382:                if(kill_processes == true)
                    383:                        return 0;
                    384:                if(results[0] != -1)
                    385:                        break;
                    386:        }
                    387:        return results[0];
                    388: }
                    389: 

unix.superglobalmegacorp.com

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