Annotation of researchv10dc/cmd/worm/scsi/generic/read.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       "../scsi.h"
        !             3: #include       "../scsish.h"
        !             4: #include       "../tcl.h"
        !             5: #include       "fns.h"
        !             6: 
        !             7: int
        !             8: gen_read(ClientData cd, Tcl_Interp *it, int argc, char **argv)
        !             9: {
        !            10:        struct scsi_cmd cmd;
        !            11:        struct scsi_return ret;
        !            12:        int unit, i;
        !            13:        unsigned long ns, ss;
        !            14:        long bs, addr, n;
        !            15:        long t1, t2;
        !            16:        int count;
        !            17:        char *file;
        !            18:        FILE *fp;
        !            19: 
        !            20:        if(argc < 2)
        !            21:                USAGE_RETURN
        !            22:        unit = atoi(argv[1]);
        !            23:        addr = atol(argv[2]);
        !            24:        count = (argc >= 3)? atoi(argv[3]):1;
        !            25:        file = (argc >= 4)? argv[4]:0;
        !            26:        printf("lun=%d addr=%d count=%d file=%s\n", unit, addr, count, file);
        !            27:        if(file){
        !            28:                if((fp = fopen(file, "w")) == NULL){
        !            29:                        pperror(cd->err, file);
        !            30:                        ERR_RETURN
        !            31:                }
        !            32:        } else
        !            33:                fp = 0;
        !            34:        set10(cmd, 0x25, unit<<5, 0, 0, 0, 0, 0, 0, 0, 0);
        !            35:        if(s_io(0, &cmd, 0, &ret, 8, cd->err))
        !            36:                ERR_RETURN
        !            37:        ns = longat(&ret.data[0]);
        !            38:        ss = longat(&ret.data[4]);
        !            39:        bs = ss? sizeof(ret.data)/ss : 1;
        !            40:        printf("read(%d,%d): %d blocks @%d (bs=%dB, %d sectors)\n", s_id, unit, count, addr, bs*ss, bs);
        !            41:        fflush(stdout);
        !            42:        for(i = count, n = bs; i > 0; i -= n){
        !            43:                if(i < n) n = i;
        !            44:                set10(cmd, 0x28, unit<<5, addr>>24, addr>>16, addr>>8, addr,
        !            45:                        0, 0, n, 0);
        !            46:                if(s_io(0, &cmd, 0, &ret, n*ss, cd->err))
        !            47:                        ERR_RETURN
        !            48:                addr += n;
        !            49:                if(fp)
        !            50:                        fwrite(ret.data, ss, n, fp);
        !            51:        }
        !            52:        return(0);
        !            53: }

unix.superglobalmegacorp.com

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