lib/sg_cmds_extra.c
int
sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
                     int noisy, int verbose)
{
    int k, res, ret, sense_cat;
    unsigned char riiCmdBlk[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD,
                        REPORT_IDENTIFYING_INFORMATION_SA,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    unsigned char sense_b[SENSE_BUFF_LEN];
    struct sg_pt_base * ptvp;

    riiCmdBlk[6] = (max_resp_len >> 24) & 0xff;
    riiCmdBlk[7] = (max_resp_len >> 16) & 0xff;
    riiCmdBlk[8] = (max_resp_len >> 8) & 0xff;
    riiCmdBlk[9] = max_resp_len & 0xff;
    riiCmdBlk[10] |= (itype << 1) & 0xfe;

    if (verbose) {
        pr2ws("    Report identifying information cdb: ");
        for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k)
            pr2ws("%02x ", riiCmdBlk[k]);
        pr2ws("\n");
    }

    ptvp = construct_scsi_pt_obj();
    if (NULL == ptvp) {
        pr2ws("report identifying information: out of memory\n");
        return -1;
    }
    set_scsi_pt_cdb(ptvp, riiCmdBlk, sizeof(riiCmdBlk));
    set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
    set_scsi_pt_data_in(ptvp, (unsigned char *)resp, max_resp_len);
    res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
    ret = sg_cmds_process_resp(ptvp, "report identifying information", res,
                               max_resp_len, sense_b, noisy, verbose,
                               &sense_cat);
    if (-1 == ret)
        ;
    else if (-2 == ret) {
        switch (sense_cat) {
        case SG_LIB_CAT_RECOVERED:
        case SG_LIB_CAT_NO_SENSE:
            ret = 0;
            break;
        default:
            ret = sense_cat;
            break;
        }
    } else {
        if ((verbose > 2) && (ret > 0)) {
            pr2ws("    report identifying information: response%s\n",
                  (ret > 256 ? ", first 256 bytes" : ""));
            dStrHexErr((const char *)resp, (ret > 256 ? 256 : ret), -1);
        }
        ret = 0;
    }
    destruct_scsi_pt_obj(ptvp);
    return ret;
}
/* Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was
 * called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
 * various SG_LIB_CAT_* positive values or -1 -> other errors */
Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was
called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
various SG_LIB_CAT_* positive values or -1 -> other errors
Invokes a SCSI REPORT IDENTIFYING INFORMATION command . This command was called REPORT DEVICE IDENTIFIER prior to spc4r07 . Return of 0 - > success various SG_LIB_CAT_ * positive values or - 1 - > other errors
int
sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
                     int noisy, int verbose)
{
    int k, res, ret, sense_cat;
    unsigned char riiCmdBlk[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD,
                        REPORT_IDENTIFYING_INFORMATION_SA,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    unsigned char sense_b[SENSE_BUFF_LEN];
    struct sg_pt_base * ptvp;
    riiCmdBlk[6] = (max_resp_len >> 24) & 0xff;
    riiCmdBlk[7] = (max_resp_len >> 16) & 0xff;
    riiCmdBlk[8] = (max_resp_len >> 8) & 0xff;
    riiCmdBlk[9] = max_resp_len & 0xff;
    riiCmdBlk[10] |= (itype << 1) & 0xfe;
    if (verbose) {
        pr2ws("    Report identifying information cdb: ");
        for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k)
            pr2ws("%02x ", riiCmdBlk[k]);
        pr2ws("\n");
    }
    ptvp = construct_scsi_pt_obj();
    if (NULL == ptvp) {
        pr2ws("report identifying information: out of memory\n");
        return -1;
    }
    set_scsi_pt_cdb(ptvp, riiCmdBlk, sizeof(riiCmdBlk));
    set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
    set_scsi_pt_data_in(ptvp, (unsigned char *)resp, max_resp_len);
    res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
    ret = sg_cmds_process_resp(ptvp, "report identifying information", res,
                               max_resp_len, sense_b, noisy, verbose,
                               &sense_cat);
    if (-1 == ret)
        ;
    else if (-2 == ret) {
        switch (sense_cat) {
        case SG_LIB_CAT_RECOVERED:
        case SG_LIB_CAT_NO_SENSE:
            ret = 0;
            break;
        default:
            ret = sense_cat;
            break;
        }
    } else {
        if ((verbose > 2) && (ret > 0)) {
            pr2ws("    report identifying information: response%s\n",
                  (ret > 256 ? ", first 256 bytes" : ""));
            dStrHexErr((const char *)resp, (ret > 256 ? 256 : ret), -1);
        }
        ret = 0;
    }
    destruct_scsi_pt_obj(ptvp);
    return ret;
}
int sg_ll_report_id_info ( int sg_fd , int itype , void * resp , int max_resp_len , int noisy , int verbose ) { int k , res , ret , sense_cat ; unsigned char riiCmdBlk [ MAINTENANCE_IN_CMDLEN ] = { MAINTENANCE_IN_CMD , REPORT_IDENTIFYING_INFORMATION_SA , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; unsigned char sense_b [ SENSE_BUFF_LEN ] ; struct sg_pt_base * ptvp ; riiCmdBlk [ 6 ] = ( max_resp_len >> 24 ) & 0xff ; riiCmdBlk [ 7 ] = ( max_resp_len >> 16 ) & 0xff ; riiCmdBlk [ 8 ] = ( max_resp_len >> 8 ) & 0xff ; riiCmdBlk [ 9 ] = max_resp_len & 0xff ; riiCmdBlk [ 10 ] |= ( itype << 1 ) & 0xfe ; if ( verbose ) { pr2ws ( " " ) ; for ( k = 0 ; k < MAINTENANCE_IN_CMDLEN ; ++ k ) pr2ws ( " " , riiCmdBlk [ k ] ) ; pr2ws ( " \n " ) ; } ptvp = construct_scsi_pt_obj ( ) ; if ( NULL == ptvp ) { pr2ws ( " \n " ) ; return -1 ; } set_scsi_pt_cdb ( ptvp , riiCmdBlk , sizeof ( riiCmdBlk ) ) ; set_scsi_pt_sense ( ptvp , sense_b , sizeof ( sense_b ) ) ; set_scsi_pt_data_in ( ptvp , ( unsigned char * ) resp , max_resp_len ) ; res = do_scsi_pt ( ptvp , sg_fd , DEF_PT_TIMEOUT , verbose ) ; ret = sg_cmds_process_resp ( ptvp , " " , res , max_resp_len , sense_b , noisy , verbose , & sense_cat ) ; if ( -1 == ret ) ; else if ( -2 == ret ) { switch ( sense_cat ) { case SG_LIB_CAT_RECOVERED : case SG_LIB_CAT_NO_SENSE : ret = 0 ; break ; default : ret = sense_cat ; break ; } } else { if ( ( verbose > 2 ) && ( ret > 0 ) ) { pr2ws ( " \n " , ( ret > 256 ? " " : " " ) ) ; dStrHexErr ( ( const char * ) resp , ( ret > 256 ? 256 : ret ) , -1 ) ; } ret = 0 ; } destruct_scsi_pt_obj ( ptvp ) ; return ret ; }
Invokes a SCSI REPORT IDENTIFYING INFORMATION command.
Invokes a SCSI REPORT IDENTIFYING INFORMATION command .