/**************************************************************** ** ** Tape IO fuctions for tar ** ** Must execute TAPEDVR.PRG first to install the tape driver ** */ #include #include #include void bzero(ptr, cnt) char *ptr; int cnt; { while(cnt--) *ptr++ = '\0'; } main(argc, argv) int argc; char *argv[]; { if(argc != 2) { printf("mt {rewind | erase | retension}\n"); exit(1); } if (!(strcmp(argv[1], "rewind"))) (void) Tunload(0L); else if(!(strcmp(argv[1], "retension"))) Retension(); else if(!(strcmp(argv[1], "erase"))) Erase_Tape(); } Ready_Tape() { int stat, x; char bufr[512]; for(x = 10; x > 0 && stat; x--) { stat = Tready(); if(stat == 2) Reques_Sense(); if(stat) sleep(1); } if(stat) { printf("\nTape drive is Not ready\n"); return(stat); } bzero(bufr, 16); stat = Tinquir(bufr, 64L); if(stat) { printf("\nTape error during Inquiry\n"); if(stat == 2) Reques_Sense(); return(stat); } if(bufr[0] != 1) { printf("\tDevice is NOT a TAPE DRIVE! Reported: %d\n", (int)(bufr[0])); return(1); } for(x = 512; x > 0; x--); return(0); } Retension() { if(Ready_Tape() == 0) { Tload(1L); sleep(1); Tunload(0L); } } Erase_Tape() { int x, stat; if(Ready_Tape() == 0) stat = Tload(0L); /* Load tape NO RETENSION */ for(x = 512; x > 0; x--); stat = Terase(); /* Load tape NO RETENSION */ if(stat) { printf("\nTape error during Erase\n"); if(stat == 2) Reques_Sense(); return(stat); } (void)Tunload(0L); } int Reques_Sense() { int stat, i; char sense[512]; bzero(sense, 32); stat = Trsense(&sense[0], 64L); printf("\nSense Data: "); for(i = 0; i < 11; i++) printf(" %02x", (int)(sense[i]) & 0xFF); printf("\n"); return(stat); }