|
|
1.1 ! root 1: #include "vdfmt.h" ! 2: #include "cmd.h" ! 3: ! 4: /* ! 5: ** ! 6: */ ! 7: ! 8: relocate() ! 9: { ! 10: extern boolean is_formatted(); ! 11: ! 12: cur.state = rel; ! 13: print("Adding flaws to bad setor map on "); ! 14: printf("controller %d, drive %d, ", cur.controller, cur.drive); ! 15: printf("type %s.\n",CURRENT->type_name); ! 16: ! 17: indent(); ! 18: if(is_formatted() == true) { ! 19: if(read_bad_sector_map() == true) ! 20: if(bad_map->bs_id != D_INFO.id) { ! 21: print("Drive serial numbers do not match!\n"); ! 22: exdent(1); ! 23: _longjmp(abort_environ, 1); ! 24: } ! 25: get_new_relocations(); ! 26: sync_bad_sector_map(); ! 27: } ! 28: else ! 29: print("Drive must be formatted befor relocations are done.\n"); ! 30: exdent(1); ! 31: } ! 32: ! 33: ! 34: /* ! 35: ** ! 36: */ ! 37: ! 38: rel_help() ! 39: { ! 40: indent(); ! 41: print("Relocation commands are in the following form:\n"); ! 42: indent(); ! 43: print("[a-h] (block) - UNIX file system format.\n"); ! 44: print("SEctor (sector) - Absolute sector number on disk.\n"); ! 45: print("Track (track) - Absolute disk track number.\n"); ! 46: print("(cylinder) (head) (offset) (length) - CDC flaw map format.\n"); ! 47: print("STARt - Starts relocation process.\n\n"); ! 48: exdent(2); ! 49: } ! 50: ! 51: ! 52: /* ! 53: ** ! 54: */ ! 55: ! 56: get_new_relocations() ! 57: { ! 58: char line[256]; ! 59: char *ptr; ! 60: bs_entry entry; ! 61: dskadr dskaddr; ! 62: int max_track; ! 63: ! 64: dskaddr.cylinder = CURRENT->ncyl - 1; ! 65: dskaddr.cylinder = CURRENT->ntrak - 1; ! 66: max_track = to_track(dskaddr); ! 67: for(;;) { ! 68: print("Location? "); ! 69: get_string_cmd(line, rel_help); ! 70: if(kill_processes == true) ! 71: _longjmp(quit_environ, 1); ! 72: if(line[0] == '\0') ! 73: continue; ! 74: ptr = line; ! 75: trim_white(ptr); ! 76: if(!strncmp(ptr, "he", 2) || !strncmp(ptr, "?", 1) || ! 77: !strncmp(ptr, "stat", 4) || !strncmp(ptr, "!", 1)) ! 78: continue; ! 79: indent(); ! 80: if((*ptr >= 'a') && (*ptr <= 'h')) { ! 81: register char par = *(ptr++); ! 82: register int block = get_next_digit(ptr); ! 83: ! 84: dskaddr = *from_unix((unsigned char)par, ! 85: (unsigned int)block); ! 86: if((dskaddr.cylinder == -1) || (block == -1)) { ! 87: print("Invalid UNIX block number!\n"); ! 88: goto next; ! 89: } ! 90: print("Confirm block %d on file-system '%c'",block,par); ! 91: if(get_yes_no("") == true) { ! 92: entry=(*C_INFO.code_pos)(dskaddr,HEADER_ERROR); ! 93: add_user_relocations(&entry); ! 94: } ! 95: } ! 96: else if(*ptr == 't') { ! 97: register int trk = get_next_digit(ptr); ! 98: ! 99: if((trk == -1) || (trk >= max_track)) { ! 100: print("Invalid track number!\n"); ! 101: goto next; ! 102: } ! 103: print("Confirm track %d", trk); ! 104: if(get_yes_no("") == true) { ! 105: dskaddr = *from_track(trk); ! 106: entry=(*C_INFO.code_pos)(dskaddr,HEADER_ERROR); ! 107: add_user_relocations(&entry); ! 108: } ! 109: } ! 110: else if(!strncmp(ptr, "se", 2)) { ! 111: register int sec = get_next_digit(ptr); ! 112: ! 113: if((sec == -1) || ! 114: ((CURRENT->nsec*CURRENT->ntrak*CURRENT->ncyl)<sec)){ ! 115: print("Invalid sector number!\n"); ! 116: goto next; ! 117: } ! 118: print("Confirm sector %d", sec); ! 119: if(get_yes_no("") == true) { ! 120: dskaddr = *from_sector((unsigned int)sec); ! 121: entry = (*C_INFO.code_pos)(dskaddr, DATA_ERROR); ! 122: add_user_relocations(&entry); ! 123: } ! 124: } ! 125: else if(is_digit(*ptr)) { ! 126: entry.bs_cyl = get_next_digit(ptr); ! 127: skipdigits(ptr); ! 128: finddigit(ptr); ! 129: entry.bs_trk = get_next_digit(ptr); ! 130: skipdigits(ptr); ! 131: finddigit(ptr); ! 132: entry.bs_offset = get_next_digit(ptr); ! 133: skipdigits(ptr); ! 134: finddigit(ptr); ! 135: entry.bs_length = get_next_digit(ptr); ! 136: if((entry.bs_trk != -1) && (entry.bs_offset != -1) && ! 137: (entry.bs_length != -1)) { ! 138: if(entry.bs_cyl >= CURRENT->ncyl) ! 139: print("Cylinder number to high!\n"); ! 140: else if(entry.bs_trk >= CURRENT->ntrak) ! 141: print("Head number to high!\n"); ! 142: else if(entry.bs_offset >= CURRENT->nbyte) ! 143: print("Offset too long!\n"); ! 144: else if(entry.bs_length == 0) ! 145: print("Can't have a 0 length error!\n"); ! 146: else { ! 147: print("Confirm Cyl %d, ",entry.bs_cyl); ! 148: printf("Head %d, ", entry.bs_trk); ! 149: printf("offset %d, ", entry.bs_offset); ! 150: printf("length %d", entry.bs_length); ! 151: if(get_yes_no("") == true) ! 152: add_user_relocations(&entry); ! 153: } ! 154: } ! 155: else ! 156: goto bad; ! 157: } ! 158: else if(!strncmp(ptr, "star", 4)) { ! 159: exdent(1); ! 160: break; ! 161: } ! 162: else ! 163: bad: print("What?\n"); ! 164: next: exdent(1); ! 165: } ! 166: } ! 167: ! 168: dskadr check_track_for_relocations(entry, i) ! 169: bs_entry entry; ! 170: register int i; ! 171: { ! 172: register int j = i; ! 173: fmt_err temp, cmp; ! 174: boolean bad_track = false; ! 175: ! 176: cmp = (*C_INFO.decode_pos)(entry); ! 177: /* Check to see if a alternate track is or will be on this track */ ! 178: while((bad_map->list[j].bs_cyl == entry.bs_cyl) && ! 179: (bad_map->list[j].bs_trk == entry.bs_trk)) { ! 180: temp = (*C_INFO.decode_pos)(bad_map->list[j]); ! 181: if(temp.err_stat & HEADER_ERROR) { ! 182: bad_track = true; ! 183: /* if track was mapped out (it can't be us) */ ! 184: if(((bad_map->list[j].bs_alt.cylinder != 0)) || ! 185: (bad_map->list[j].bs_alt.track != 0) || ! 186: (bad_map->list[j].bs_alt.sector != 0)) { ! 187: return cmp.err_adr; ! 188: } ! 189: } ! 190: j++; ! 191: } ! 192: /* ! 193: ** If it was a bad track and it was not the current entry ! 194: ** that produced it then then map it ! 195: ** to itself and forget about it for now since it will be taken ! 196: ** care of later. ! 197: ** ! 198: ** If it was the current entry return zero and the track will be ! 199: ** mapped out correctly. ! 200: */ ! 201: if(bad_track == true) { ! 202: if(cmp.err_stat & HEADER_ERROR) ! 203: return entry.bs_alt; /* better known as zero */ ! 204: else ! 205: return cmp.err_adr; ! 206: } ! 207: /* ! 208: ** if we made it through all the bad track stuff then check for ! 209: ** multiple errors on the same sector that are already mapped! ! 210: */ ! 211: j = i; ! 212: while((bad_map->list[j].bs_cyl == entry.bs_cyl) && ! 213: (bad_map->list[j].bs_trk == entry.bs_trk)) { ! 214: temp = (*C_INFO.decode_pos)(bad_map->list[j]); ! 215: if(temp.err_adr.sector == cmp.err_adr.sector) { ! 216: /* if it is not really the current entry */ ! 217: if((bad_map->list[j].bs_offset != entry.bs_offset) || ! 218: (bad_map->list[j].bs_length != entry.bs_length)) { ! 219: /* if the sector is already mapped out */ ! 220: if(((bad_map->list[j].bs_alt.cylinder != 0)) || ! 221: (bad_map->list[j].bs_alt.track != 0) || ! 222: (bad_map->list[j].bs_alt.sector != 0)) { ! 223: return temp.err_adr; ! 224: } ! 225: } ! 226: } ! 227: j++; ! 228: } ! 229: return entry.bs_alt; ! 230: } ! 231: ! 232: ! 233: /* ! 234: ** ! 235: */ ! 236: ! 237: dskadr is_relocated(entry) ! 238: bs_entry entry; ! 239: { ! 240: register int i; ! 241: ! 242: for(i=0; i<bad_map->bs_count; i++) ! 243: if((bad_map->list[i].bs_cyl == entry.bs_cyl) && ! 244: (bad_map->list[i].bs_trk == entry.bs_trk)) ! 245: return check_track_for_relocations(entry, i); ! 246: return entry.bs_alt; ! 247: } ! 248: ! 249: ! 250: ! 251: /* ! 252: ** ! 253: */ ! 254: ! 255: sync_bad_sector_map() ! 256: { ! 257: register int i; ! 258: dskadr dskaddr; ! 259: ! 260: /* ! 261: ** do all the relocation cylinders first to allocate all flaws in ! 262: ** relocation area. ! 263: */ ! 264: for(i=bad_map->bs_count-1; i>=0; i--) { ! 265: if((bad_map->list[i].bs_cyl >= CURRENT->ncyl-NUMSYS) && ! 266: (bad_map->list[i].bs_cyl < CURRENT->ncyl-NUMMAP-NUMMNT)) { ! 267: if((bad_map->list[i].bs_alt.cylinder == 0) && ! 268: (bad_map->list[i].bs_alt.track == 0) && ! 269: (bad_map->list[i].bs_alt.sector == 0)) { ! 270: bad_map->list[i].bs_alt = ! 271: *new_location(&bad_map->list[i]); ! 272: } ! 273: } ! 274: } ! 275: for(i=bad_map->bs_count-1; i>=0; i--) { ! 276: if((bad_map->list[i].bs_alt.cylinder == 0) && ! 277: (bad_map->list[i].bs_alt.track == 0) && ! 278: (bad_map->list[i].bs_alt.sector == 0)) { ! 279: dskaddr = is_relocated(bad_map->list[i]); ! 280: if((dskaddr.cylinder == 0) && (dskaddr.track == 0) && ! 281: (dskaddr.sector == 0)) { ! 282: bad_map->list[i].bs_alt = ! 283: *new_location(&bad_map->list[i]); ! 284: do_relocation(bad_map->list[i]); ! 285: } ! 286: else ! 287: bad_map->list[i].bs_alt = dskaddr; ! 288: } ! 289: } ! 290: write_bad_sector_map(); ! 291: } ! 292: ! 293: ! 294: ! 295: /* ! 296: ** ! 297: */ ! 298: ! 299: do_relocation(entry) ! 300: bs_entry entry; ! 301: { ! 302: fmt_err temp; ! 303: ! 304: if(entry.bs_cyl >= CURRENT->ncyl-NUMSYS) ! 305: if(entry.bs_cyl != (CURRENT->ncyl - NUMMAP - NUMMNT)) ! 306: return; ! 307: temp = (*C_INFO.decode_pos)(entry); ! 308: if((entry.bs_alt.cylinder == 0) && (entry.bs_alt.track == 0) && ! 309: (entry.bs_alt.sector == 0)) ! 310: print_unix_block(temp.err_adr); ! 311: else if(temp.err_stat & HEADER_ERROR) ! 312: if(C_INFO.type == SMDCTLR) { ! 313: print("Can't relocate tracks on VDDC controllers.\n"); ! 314: print_unix_block(temp.err_adr); ! 315: } ! 316: else ! 317: relocate_track(entry); ! 318: else ! 319: relocate_sector(entry); ! 320: } ! 321: ! 322: ! 323: /* ! 324: ** ! 325: */ ! 326: ! 327: relocate_sector(entry) ! 328: bs_entry entry; ! 329: { ! 330: dskadr phys, reloc; ! 331: fmt_err temp; ! 332: register long status; ! 333: ! 334: temp = (*C_INFO.decode_pos)(entry); ! 335: phys = temp.err_adr; ! 336: reloc = entry.bs_alt; ! 337: format_sectors(&phys, &reloc, RELOC_SECTOR, (long)1); ! 338: ! 339: format_sectors(&reloc, &phys, ALT_SECTOR, (long)1); ! 340: status = access_dsk((char *)save, &temp.err_adr, WD, 1, 1); ! 341: if(!((status & ALTACC) && !(status & (HRDERR |SFTERR)))) { ! 342: print("Sector relocation failed. Status = 0x%x.\n", status); ! 343: print_unix_block(phys); ! 344: } ! 345: } ! 346: ! 347: ! 348: ! 349: /* ! 350: ** ! 351: */ ! 352: ! 353: relocate_track(entry) ! 354: bs_entry entry; ! 355: { ! 356: dskadr phys, reloc; ! 357: fmt_err temp; ! 358: register long status; ! 359: ! 360: temp = (*C_INFO.decode_pos)(entry); ! 361: temp.err_adr.sector = 0; ! 362: phys = temp.err_adr; ! 363: reloc = entry.bs_alt; ! 364: reloc.sector = 0xff; ! 365: format_sectors(&phys, &reloc, RELOC_SECTOR, (long)CURRENT->nsec); ! 366: ! 367: reloc.sector = 0x00; ! 368: format_sectors(&reloc, &phys, ALT_SECTOR, (long)CURRENT->nsec); ! 369: status = access_dsk((char *)save, &temp.err_adr, WD, CURRENT->nsec, 1); ! 370: if(!((status & ALTACC) && !(status & (HRDERR | SFTERR)))) { ! 371: print("Track relocation failed. Status = 0x%x.\n", status); ! 372: print_unix_block(phys); ! 373: } ! 374: } ! 375: ! 376: ! 377:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.