lib/sg_cmds_extra.c
int
sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
                  int noisy, int verbose)
{
    int k, res, ret, sense_cat;
    unsigned char siiCmdBlk[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD,
                         SET_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;

    siiCmdBlk[6] = (param_len >> 24) & 0xff;
    siiCmdBlk[7] = (param_len >> 16) & 0xff;
    siiCmdBlk[8] = (param_len >> 8) & 0xff;
    siiCmdBlk[9] = param_len & 0xff;
    siiCmdBlk[10] |= (itype << 1) & 0xfe;
    if (verbose) {
        pr2ws("    Set identifying information cdb: ");
        for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k)
            pr2ws("%02x ", siiCmdBlk[k]);
        pr2ws("\n");
        if ((verbose > 1) && paramp && param_len) {
            pr2ws("    Set identifying information parameter list:\n");
            dStrHexErr((const char *)paramp, param_len, -1);
        }
    }

    ptvp = construct_scsi_pt_obj();
    if (NULL == ptvp) {
        pr2ws("Set identifying information: out of memory\n");
        return -1;
    }
    set_scsi_pt_cdb(ptvp, siiCmdBlk, sizeof(siiCmdBlk));
    set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
    set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len);
    res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
    ret = sg_cmds_process_resp(ptvp, "set identifying information", res, 0,
                               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
        ret = 0;

    destruct_scsi_pt_obj(ptvp);
    return ret;
}
/* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was
 * called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
 * various SG_LIB_CAT_* positive values or -1 -> other errors */
Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was
called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
various SG_LIB_CAT_* positive values or -1 -> other errors
Invokes a SCSI SET IDENTIFYING INFORMATION command . This command was called SET DEVICE IDENTIFIER prior to spc4r07 . Return of 0 - > success various SG_LIB_CAT_ * positive values or - 1 - > other errors
int
sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
                  int noisy, int verbose)
{
    int k, res, ret, sense_cat;
    unsigned char siiCmdBlk[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD,
                         SET_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;
    siiCmdBlk[6] = (param_len >> 24) & 0xff;
    siiCmdBlk[7] = (param_len >> 16) & 0xff;
    siiCmdBlk[8] = (param_len >> 8) & 0xff;
    siiCmdBlk[9] = param_len & 0xff;
    siiCmdBlk[10] |= (itype << 1) & 0xfe;
    if (verbose) {
        pr2ws("    Set identifying information cdb: ");
        for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k)
            pr2ws("%02x ", siiCmdBlk[k]);
        pr2ws("\n");
        if ((verbose > 1) && paramp && param_len) {
            pr2ws("    Set identifying information parameter list:\n");
            dStrHexErr((const char *)paramp, param_len, -1);
        }
    }
    ptvp = construct_scsi_pt_obj();
    if (NULL == ptvp) {
        pr2ws("Set identifying information: out of memory\n");
        return -1;
    }
    set_scsi_pt_cdb(ptvp, siiCmdBlk, sizeof(siiCmdBlk));
    set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
    set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len);
    res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
    ret = sg_cmds_process_resp(ptvp, "set identifying information", res, 0,
                               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
        ret = 0;
    destruct_scsi_pt_obj(ptvp);
    return ret;
}
int sg_ll_set_id_info ( int sg_fd , int itype , void * paramp , int param_len , int noisy , int verbose ) { int k , res , ret , sense_cat ; unsigned char siiCmdBlk [ MAINTENANCE_OUT_CMDLEN ] = { MAINTENANCE_OUT_CMD , SET_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 ; siiCmdBlk [ 6 ] = ( param_len >> 24 ) & 0xff ; siiCmdBlk [ 7 ] = ( param_len >> 16 ) & 0xff ; siiCmdBlk [ 8 ] = ( param_len >> 8 ) & 0xff ; siiCmdBlk [ 9 ] = param_len & 0xff ; siiCmdBlk [ 10 ] |= ( itype << 1 ) & 0xfe ; if ( verbose ) { pr2ws ( " " ) ; for ( k = 0 ; k < MAINTENANCE_OUT_CMDLEN ; ++ k ) pr2ws ( " " , siiCmdBlk [ k ] ) ; pr2ws ( " \n " ) ; if ( ( verbose > 1 ) && paramp && param_len ) { pr2ws ( " \n " ) ; dStrHexErr ( ( const char * ) paramp , param_len , -1 ) ; } } ptvp = construct_scsi_pt_obj ( ) ; if ( NULL == ptvp ) { pr2ws ( " \n " ) ; return -1 ; } set_scsi_pt_cdb ( ptvp , siiCmdBlk , sizeof ( siiCmdBlk ) ) ; set_scsi_pt_sense ( ptvp , sense_b , sizeof ( sense_b ) ) ; set_scsi_pt_data_out ( ptvp , ( unsigned char * ) paramp , param_len ) ; res = do_scsi_pt ( ptvp , sg_fd , DEF_PT_TIMEOUT , verbose ) ; ret = sg_cmds_process_resp ( ptvp , " " , res , 0 , 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 ret = 0 ; destruct_scsi_pt_obj ( ptvp ) ; return ret ; }
Invokes a SCSI SET IDENTIFYING INFORMATION command.
Invokes a SCSI SET IDENTIFYING INFORMATION command .