Annotation of researchv10dc/cmd/oworm/oscsi/copy.c, revision 1.1.1.1

1.1       root        1: #include       "scsi.h"
                      2: #include       "worm.h"
                      3: 
                      4: s_copy(sdr, sbase, nblocks, ddr, dbase)
                      5: {
                      6:        struct scsi_o o;
                      7:        int bn, c;
                      8:        char buf[256];
                      9:        int lower;
                     10:        int wr, unwr;
                     11:        int n;
                     12:        long nb = nblocks;
                     13:        long t1, t2;
                     14:        long goo;
                     15: #define                TALK            10000
                     16:        extern char *ctime();
                     17: 
                     18:        fprint(1, "copying drive %d[%d-%d] to drive %d[%d-%d]\n", sdr,
                     19:                sbase, sbase+nblocks-1, ddr, dbase, dbase+nblocks-1);
                     20:        time(&t1);
                     21:        goo = sbase/TALK;
                     22:        while(nblocks > 0){
                     23:                if(sbase/TALK != goo){
                     24:                        goo = sbase/TALK;
                     25:                        time(&t2);
                     26:                        print("doing block %ld at %s", goo*TALK, ctime(&t2));
                     27:                }
                     28:                n = min(256, nblocks);
                     29:                wr = s_wsearch(sdr, sbase, n);
                     30:                if(wr < 0)
                     31:                        break;
                     32:                if(wr == n){
                     33:                        sbase += n;
                     34:                        dbase += n;
                     35:                        nblocks -= n;
                     36:                        continue;
                     37:                }
                     38:                sbase += wr;
                     39:                dbase += wr;
                     40:                n -= wr;        /* number of blocks */
                     41:                nblocks -= wr;
                     42:                unwr = s_bsearch(sdr, sbase, n);
                     43:                if(unwr < 0)
                     44:                        break;
                     45:                /*print("writing %d-%d\n", sbase, sbase+unwr-1);/**/
                     46:                if(s_copy1(sdr, sbase, unwr, ddr, dbase))
                     47:                        break;
                     48:                sbase += unwr;
                     49:                dbase += unwr;
                     50:                nblocks -= unwr;
                     51:        }
                     52:        time(&t2);
                     53:        t2 -= t1;
                     54:        if(t2 == 0) t2 = 1;
                     55:        fprint(1, "%ds: ", t2);
                     56:        if(nblocks){
                     57:                fprint(1, "copy buggered up: sbase=%d nblks=%d dbase=%d\n",
                     58:                        sbase, nblocks, dbase);
                     59:                return(1);
                     60:        }
                     61:        fprint(1, "%d blocks at %.1fKB/s\n", nb, nb/(float)t2);
                     62:        return(0);
                     63: }
                     64: 
                     65: s_copy1(sd, sb, n, dd, db)
                     66: {
                     67:        struct scsi_i input;
                     68:        struct scsi_o o;
                     69: 
                     70:        input.bus_id = 1<<scsi_id;
                     71:        input.cmd[0] = 0x18;
                     72:        input.cmd[1] = sd<<5;
                     73:        input.cmd[2] = 0;
                     74:        input.cmd[3] = 0;
                     75:        input.cmd[4] = 20;
                     76:        input.cmd[5] = 0;
                     77:        input.data[0] = 0x10;   /* copy */
                     78:        input.data[1] = 0;
                     79:        input.data[2] = 0;
                     80:        input.data[3] = 0;
                     81:        input.data[4] = (scsi_id<<5)|sd;
                     82:        input.data[5] = (scsi_id<<5)|dd;
                     83:        input.data[6] = 0;
                     84:        input.data[7] = 0;
                     85:        input.data[8] = n>>24;
                     86:        input.data[9] = n>>16;
                     87:        input.data[10] = n>>8;
                     88:        input.data[11] = n;
                     89:        input.data[12] = sb>>24;
                     90:        input.data[13] = sb>>16;
                     91:        input.data[14] = sb>>8;
                     92:        input.data[15] = sb;
                     93:        input.data[16] = db>>24;
                     94:        input.data[17] = db>>16;
                     95:        input.data[18] = db>>8;
                     96:        input.data[19] = db;
                     97:        if(scsiio(&input, &o, 20, "media") < 0)
                     98:                return(1);
                     99:        if(CHECK(o)){
                    100:                scsidump(&o);
                    101:                s_sense(sd, -1);
                    102:                return(1);
                    103:        }
                    104:        return(0);
                    105: }

unix.superglobalmegacorp.com

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