openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/udev/scsi_id/scsi_serial.c
static int do_scsi_page80_inquiry(struct scsi_id_device* dev_scsi, int fd,
                                  char* serial, char* serial_short, int max_len)
{
    int retval;
    int ser_ind;
    int i;
    int len;
    unsigned char buf[SCSI_INQ_BUFF_LEN];

    memzero(buf, SCSI_INQ_BUFF_LEN);
    retval = scsi_inquiry(dev_scsi, fd, 1, PAGE_80, buf, SCSI_INQ_BUFF_LEN);
    if (retval < 0)
        return retval;

    if (buf[1] != PAGE_80)
    {
        log_debug("%s: Invalid page 0x80", dev_scsi->kernel);
        return 1;
    }

    len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf[3];
    if (max_len < len)
    {
        log_debug("%s: length %d too short - need %d", dev_scsi->kernel,
                  max_len, len);
        return 1;
    }
    /*
     * Prepend 'S' to avoid unlikely collision with page 0x83 vendor
     * specific type where we prepend '0' + vendor + model.
     */
    len = buf[3];
    if (serial != NULL)
    {
        serial[0] = 'S';
        ser_ind = prepend_vendor_model(dev_scsi, &serial[1]);
        if (ser_ind < 0)
            return 1;
        ser_ind++; /* for the leading 'S' */
        for (i = 4; i < len + 4; i++, ser_ind++)
            serial[ser_ind] = buf[i];
    }
    if (serial_short != NULL)
    {
        memcpy(serial_short, &buf[4], len);
        serial_short[len] = '\0';
    }
    return 0;
}
/* Get unit serial number VPD page */
Get unit serial number VPD page
Get unit serial number VPD page
static int do_scsi_page80_inquiry(struct scsi_id_device* dev_scsi, int fd,
                                  char* serial, char* serial_short, int max_len)
{
    int retval;
    int ser_ind;
    int i;
    int len;
    unsigned char buf[SCSI_INQ_BUFF_LEN];
    memzero(buf, SCSI_INQ_BUFF_LEN);
    retval = scsi_inquiry(dev_scsi, fd, 1, PAGE_80, buf, SCSI_INQ_BUFF_LEN);
    if (retval < 0)
        return retval;
    if (buf[1] != PAGE_80)
    {
        log_debug("%s: Invalid page 0x80", dev_scsi->kernel);
        return 1;
    }
    len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf[3];
    if (max_len < len)
    {
        log_debug("%s: length %d too short - need %d", dev_scsi->kernel,
                  max_len, len);
        return 1;
    }
    len = buf[3];
    if (serial != NULL)
    {
        serial[0] = 'S';
        ser_ind = prepend_vendor_model(dev_scsi, &serial[1]);
        if (ser_ind < 0)
            return 1;
        ser_ind++; 
        for (i = 4; i < len + 4; i++, ser_ind++)
            serial[ser_ind] = buf[i];
    }
    if (serial_short != NULL)
    {
        memcpy(serial_short, &buf[4], len);
        serial_short[len] = '\0';
    }
    return 0;
}
static int do_scsi_page80_inquiry ( struct scsi_id_device * dev_scsi , int fd , char * serial , char * serial_short , int max_len ) { int retval ; int ser_ind ; int i ; int len ; unsigned char buf [ SCSI_INQ_BUFF_LEN ] ; memzero ( buf , SCSI_INQ_BUFF_LEN ) ; retval = scsi_inquiry ( dev_scsi , fd , 1 , PAGE_80 , buf , SCSI_INQ_BUFF_LEN ) ; if ( retval < 0 ) return retval ; if ( buf [ 1 ] != PAGE_80 ) { log_debug ( " " , dev_scsi -> kernel ) ; return 1 ; } len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf [ 3 ] ; if ( max_len < len ) { log_debug ( " " , dev_scsi -> kernel , max_len , len ) ; return 1 ; } len = buf [ 3 ] ; if ( serial != NULL ) { serial [ 0 ] = ' ' ; ser_ind = prepend_vendor_model ( dev_scsi , & serial [ 1 ] ) ; if ( ser_ind < 0 ) return 1 ; ser_ind ++ ; for ( i = 4 ; i < len + 4 ; i ++ , ser_ind ++ ) serial [ ser_ind ] = buf [ i ] ; } if ( serial_short != NULL ) { memcpy ( serial_short , & buf [ 4 ] , len ) ; serial_short [ len ] = ' \0 ' ; } return 0 ; }
Get unit serial number VPD page
Get unit serial number VPD page
/*
     * Prepend 'S' to avoid unlikely collision with page 0x83 vendor
     * specific type where we prepend '0' + vendor + model.
     */ /* for the leading 'S' */