lib/sg_lib.c
int
sg_get_sense_info_fld(const unsigned char * sensep, int sb_len,
                      uint64_t * info_outp)
{
    int j;
    const unsigned char * ucp;
    uint64_t ull;

    if (info_outp)
        *info_outp = 0;
    if (sb_len < 7)
        return 0;
    switch (sensep[0] & 0x7f) {
    case 0x70:
    case 0x71:
        if (info_outp)
            *info_outp = ((unsigned int)sensep[3] << 24) + (sensep[4] << 16) +
                         (sensep[5] << 8) + sensep[6];
        return (sensep[0] & 0x80) ? 1 : 0;
    case 0x72:
    case 0x73:
        ucp = sg_scsi_sense_desc_find(sensep, sb_len, 0 /* info desc */);
        if (ucp && (0xa == ucp[1])) {
            ull = 0;
            for (j = 0; j < 8; ++j) {
                if (j > 0)
                    ull <<= 8;
                ull |= ucp[4 + j];
            }
            if (info_outp)
                *info_outp = ull;
            return !!(ucp[2] & 0x80);   /* since spc3r23 should be set */
        } else
            return 0;
    default:
        return 0;
    }
}
/* Returns 1 if valid bit set, 0 if valid bit clear. Irrespective the
 * information field is written out via 'info_outp' (except when it is
 * NULL). Handles both fixed and descriptor sense formats. */
Returns 1 if valid bit set, 0 if valid bit clear. Irrespective the
information field is written out via 'info_outp' (except when it is
NULL). Handles both fixed and descriptor sense formats.
Returns 1 if valid bit set 0 if valid bit clear . Irrespective the information field is written out via ' info_outp ' ( except when it is NULL ) . Handles both fixed and descriptor sense formats .
int
sg_get_sense_info_fld(const unsigned char * sensep, int sb_len,
                      uint64_t * info_outp)
{
    int j;
    const unsigned char * ucp;
    uint64_t ull;
    if (info_outp)
        *info_outp = 0;
    if (sb_len < 7)
        return 0;
    switch (sensep[0] & 0x7f) {
    case 0x70:
    case 0x71:
        if (info_outp)
            *info_outp = ((unsigned int)sensep[3] << 24) + (sensep[4] << 16) +
                         (sensep[5] << 8) + sensep[6];
        return (sensep[0] & 0x80) ? 1 : 0;
    case 0x72:
    case 0x73:
        ucp = sg_scsi_sense_desc_find(sensep, sb_len, 0 );
        if (ucp && (0xa == ucp[1])) {
            ull = 0;
            for (j = 0; j < 8; ++j) {
                if (j > 0)
                    ull <<= 8;
                ull |= ucp[4 + j];
            }
            if (info_outp)
                *info_outp = ull;
            return !!(ucp[2] & 0x80);   
        } else
            return 0;
    default:
        return 0;
    }
}
int sg_get_sense_info_fld ( const unsigned char * sensep , int sb_len , uint64_t * info_outp ) { int j ; const unsigned char * ucp ; uint64_t ull ; if ( info_outp ) * info_outp = 0 ; if ( sb_len < 7 ) return 0 ; switch ( sensep [ 0 ] & 0x7f ) { case 0x70 : case 0x71 : if ( info_outp ) * info_outp = ( ( unsigned int ) sensep [ 3 ] << 24 ) + ( sensep [ 4 ] << 16 ) + ( sensep [ 5 ] << 8 ) + sensep [ 6 ] ; return ( sensep [ 0 ] & 0x80 ) ? 1 : 0 ; case 0x72 : case 0x73 : ucp = sg_scsi_sense_desc_find ( sensep , sb_len , 0 ) ; if ( ucp && ( 0xa == ucp [ 1 ] ) ) { ull = 0 ; for ( j = 0 ; j < 8 ; ++ j ) { if ( j > 0 ) ull <<= 8 ; ull |= ucp [ 4 + j ] ; } if ( info_outp ) * info_outp = ull ; return ! ! ( ucp [ 2 ] & 0x80 ) ; } else return 0 ; default : return 0 ; } }
Returns 1 if valid bit set, 0 if valid bit clear.
Returns 1 if valid bit set 0 if valid bit clear .
/* info desc */ /* since spc3r23 should be set */