Annotation of researchv10no/cmd/worm/oscsi/wren/wmode.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       "../scsi.h"
        !             3: #include       "../scsish.h"
        !             4: #include       "fns.h"
        !             5: 
        !             6: int
        !             7: wr_modeselect(int niargs, int *iargs, int ncargs, char **cargs, char *err)
        !             8: {
        !             9:        struct scsi_cmd cmd;
        !            10:        struct scsi_return ret;
        !            11:        int n;
        !            12: 
        !            13: #pragma ref niargs
        !            14: #pragma ref ncargs
        !            15: #pragma ref cargs
        !            16: 
        !            17:        printf("changing modes to ");
        !            18:        if((iargs[0] < 256) && (iargs[0] >= 0))
        !            19:                printf("er-param=%d(=#%x), ", iargs[0], iargs[0]);
        !            20:        if((iargs[1] < 256) && (iargs[1] >= 0))
        !            21:                printf("er-retries=%d, ", iargs[1]);
        !            22:        if((iargs[2] < 256) && (iargs[2] >= 0))
        !            23:                printf("read-recon=%d/256, ", iargs[2]);
        !            24:        if((iargs[3] < 256) && (iargs[3] >= 0))
        !            25:                printf("write-recon=%d/256, ", iargs[3]);
        !            26:        if((iargs[4] < 256) && (iargs[4] >= 0))
        !            27:                printf("read cache %sable, ", iargs[4]?"dis":"en");
        !            28:        if((iargs[5] < 256) && (iargs[5] >= 0))
        !            29:                printf("write cache %sable, ", iargs[5]?"en":"dis");
        !            30:        if((iargs[6] < 256) && (iargs[6] >= 0))
        !            31:                printf("cache max prefetch=%d, ", iargs[6]);
        !            32:        if((iargs[7] < 256) && (iargs[7] >= 0))
        !            33:                printf("cache size=%d, ", iargs[7]);
        !            34:        if((iargs[8] < 256) && (iargs[8] >= 0))
        !            35:                printf("cross cyl %sable, ", iargs[8]?"en":"dis");
        !            36:        printf("\nsleep(10); kill me if you disagree\n");
        !            37:        fflush(stdout);
        !            38:        sleep(10);
        !            39:        /* do error recovery */
        !            40:        if(((iargs[0] < 256) && (iargs[0] >= 0)) || ((iargs[1] < 256) && (iargs[1] >= 0))){
        !            41:                set6(cmd, 0x1A, 0, (0<<6)|0x01, 0, 20, 0);
        !            42:                if(n = s_io(0, &cmd, 0, &ret, 20, err))
        !            43:                        return(n);
        !            44:                memcpy(cmd.data, ret.data, 20);
        !            45:                cmd.data[14] &= ~0x10;
        !            46:                if((iargs[0] < 256) && (iargs[0] >= 0))
        !            47:                        cmd.data[14] = iargs[0];
        !            48:                if((iargs[1] < 256) && (iargs[1] >= 0))
        !            49:                        cmd.data[15] = iargs[1];
        !            50:                set6(cmd, 0x15, 0x11, 0, 0, 20, 0);
        !            51:                if(n = s_io(0, &cmd, 20, &ret, 0, err))
        !            52:                        return(n);
        !            53:        }
        !            54:        /* reconnect */
        !            55:        if(((iargs[2] < 256) && (iargs[2] >= 0)) || ((iargs[3] < 256) && (iargs[3] >= 0))){
        !            56:                set6(cmd, 0x1A, 0, (0<<6)|0x02, 0, 24, 0);
        !            57:                if(n = s_io(0, &cmd, 0, &ret, 24, err))
        !            58:                        return(n);
        !            59:                memcpy(cmd.data, ret.data, 24);
        !            60:                if((iargs[2] < 256) && (iargs[2] >= 0))
        !            61:                        cmd.data[14] = iargs[2];
        !            62:                if((iargs[3] < 256) && (iargs[3] >= 0))
        !            63:                        cmd.data[15] = iargs[3];
        !            64:                set6(cmd, 0x15, 0x11, 0, 0, 24, 0);
        !            65:                if(n = s_io(0, &cmd, 24, &ret, 0, err))
        !            66:                        return(n);
        !            67:        }
        !            68:        /* do cache params*/
        !            69:        if(((iargs[4] < 256) && (iargs[4] >= 0))
        !            70:                        || ((iargs[5] < 256) && (iargs[5] >= 0))
        !            71:                        || ((iargs[6] < 65536) && (iargs[6] >= 0))){
        !            72:                set6(cmd, 0x1A, 0, (0<<6)|0x08, 0, 28, 0);
        !            73:                if(n = s_io(0, &cmd, 0, &ret, 24, err))
        !            74:                        return(n);
        !            75:                memcpy(cmd.data, ret.data, 24);
        !            76:                if((iargs[4] < 256) && (iargs[4] >= 0)){
        !            77:                        cmd.data[14] &= ~0x01;
        !            78:                        cmd.data[14] |= iargs[4];
        !            79:                }
        !            80:                if((iargs[5] < 256) && (iargs[5] >= 0)){
        !            81:                        cmd.data[14] &= ~0x04;
        !            82:                        cmd.data[14] |= iargs[5]? 0x04:0;
        !            83:                }
        !            84:                if((iargs[6] < 65536) && (iargs[6] >= 0)){
        !            85:                        cmd.data[20] = iargs[6]>>8;
        !            86:                        cmd.data[21] = iargs[6];
        !            87:                }
        !            88:                set6(cmd, 0x15, 0x11, 0, 0, 24, 0);
        !            89:                if(n = s_io(0, &cmd, 24, &ret, 0, err))
        !            90:                        return(n);
        !            91:        }
        !            92:        /* do cache control */
        !            93:        if(((iargs[8] < 256) && (iargs[8] >= 0))
        !            94:                        || ((iargs[7] < 256) && (iargs[7] >= 0))){
        !            95:                set6(cmd, 0x1A, 0, (0<<6)|0x38, 0, 28, 0);
        !            96:                if(n = s_io(0, &cmd, 0, &ret, 28, err))
        !            97:                        return(n);
        !            98:                memcpy(cmd.data, ret.data, 28);
        !            99:                cmd.data[14] &= ~0x80;
        !           100:                if(iargs[8])
        !           101:                        cmd.data[14] |= 0x80;
        !           102:                if((iargs[7] < 256) && (iargs[7] >= 0)){
        !           103:                        cmd.data[14] &= 0xF0;
        !           104:                        cmd.data[14] |= iargs[7]&0xF;
        !           105:                }
        !           106:                set6(cmd, 0x15, 0x11, 0, 0, 28, 0);
        !           107:                if(n = s_io(0, &cmd, 28, &ret, 0, err))
        !           108:                        return(n);
        !           109:        }
        !           110:        return(0);
        !           111: }

unix.superglobalmegacorp.com

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