|
|
1.1 ! root 1: #include "scsi.h" ! 2: ! 3: static ! 4: swrite(drive, block, nblock, input) ! 5: struct scsi_i *input; ! 6: { ! 7: struct scsi_o output; ! 8: ! 9: input->bus_id = 1<<scsi_id; ! 10: input->cmd[0] = 0x2A; ! 11: input->cmd[1] = drive<<5; ! 12: input->cmd[2] = block>>24; ! 13: input->cmd[3] = block>>16; ! 14: input->cmd[4] = block>>8; ! 15: input->cmd[5] = block; ! 16: input->cmd[6] = 0; ! 17: input->cmd[7] = nblock>>8; ! 18: input->cmd[8] = nblock; ! 19: input->cmd[9] = 0; ! 20: if(scsiio(input, &output, nblock*1024, "write") < 0) ! 21: return(1); ! 22: if(CHECK(output)){ ! 23: scsidump(&output); ! 24: return(1); ! 25: } ! 26: return(0); ! 27: } ! 28: ! 29: s_write(drive, block, nblock) ! 30: { ! 31: struct scsi_o output; ! 32: struct scsi_i input; ! 33: register long *j, i; ! 34: int nb = 3; ! 35: if((drive < 0) || (drive > 7)){ ! 36: fprint(2, "bad drive number %d\n", drive); ! 37: return(1); ! 38: } ! 39: fprint(1, "writing %d blocks [%d-%d] on drive %d: ", nblock, block, block+nblock-1, drive); ! 40: while(nblock > 0){ ! 41: if(nblock < nb) ! 42: nb = nblock; ! 43: for(j = (long *)input.data, i = nb*256-1; i >= 0; i--) ! 44: *j++ = block; ! 45: if(swrite(drive, block, nb, &input)) ! 46: return(1); ! 47: nblock -= nb; ! 48: block += nb; ! 49: } ! 50: fprint(1, "done\n"); ! 51: return(0); ! 52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.