Annotation of researchv10dc/cmd/worm/oscsi/sony/sense.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: sony_sense(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:        char buf[4096];
        !            13: 
        !            14: #pragma ref ncargs
        !            15: #pragma ref cargs
        !            16: 
        !            17:        if(niargs == 0)
        !            18:                iargs[0] = 0;
        !            19:        set6(cmd, 0x03, iargs[0]<<5, 0, 0, 32, 0);
        !            20:        if(n = s_io(0, &cmd, 0, &ret, -32, err))
        !            21:                return(n);
        !            22:        printf("sense(%d,%d): ", s_id, iargs[0]);
        !            23:        sony_extsense(ret.data, buf, sizeof buf);
        !            24:        printf("%s\n", buf);
        !            25:        return(0);
        !            26: }
        !            27: 
        !            28: static char *exstab[16] =
        !            29: {
        !            30:        "no sense",
        !            31:        "recovered error",
        !            32:        "not ready",
        !            33:        "medium error",
        !            34:        "hardware error",
        !            35:        "illegal request",
        !            36:        "unit attention",
        !            37:        "data protect",
        !            38:        "blank check",
        !            39:        "key #9",
        !            40:        "copy aborted",
        !            41:        "aborted command",
        !            42:        "key #c",
        !            43:        "volume overflow",
        !            44:        "miscompare",
        !            45:        "key #f",
        !            46: };
        !            47: 
        !            48: void
        !            49: sony_extsense(uchar *data, char *dest, int ndata)
        !            50: {
        !            51:        char buf[4096];
        !            52:        extern char *nesd[];
        !            53: 
        !            54:        dest[0] = 0;
        !            55:        switch(data[2])
        !            56:        {
        !            57:        case 0:
        !            58:                sprintf(dest, "no error");
        !            59:                break;
        !            60:        case 0x1:       /* recovered error */
        !            61:                sprintf(dest, "recovered error");
        !            62:                break;
        !            63:        case 0xA:       /* recovered error */
        !            64:                sprintf(dest, "recovered error");
        !            65:                break;
        !            66:        default:
        !            67:                if(data[7] != 4)
        !            68:                        sprintf((char *)data, "warning: extra data is %d, not 4! ", data[7]);
        !            69:                sprintf(buf, "sense: %s", nesd[data[8]&0x7f]);
        !            70:                strcat(dest, buf);
        !            71:                if(data[8]&0x80){
        !            72:                        sprintf(buf, " at addr #%x", data[11]+256L*data[10]+256L*256*data[9]);
        !            73:                        strcat(dest, buf);
        !            74:                }
        !            75:                sprintf(buf, ", ext sense: %s", exstab[data[2]]);
        !            76:                strcat(dest, buf);
        !            77:                if(data[0]&0x80){
        !            78:                        sprintf(buf, " info=#%x", data[6]+256L*data[5]+256L*256L*data[4]+256L*256L*256L*data[3]);
        !            79:                        strcat(dest, buf);
        !            80:                }
        !            81:                break;
        !            82:        }
        !            83: }

unix.superglobalmegacorp.com

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