int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)

{

    int rc;



    cmd->lba = -1;

    cmd->len = scsi_cdb_length(buf);



    switch (dev->type) {

    case TYPE_TAPE:

        rc = scsi_req_stream_xfer(cmd, dev, buf);

        break;

    case TYPE_MEDIUM_CHANGER:

        rc = scsi_req_medium_changer_xfer(cmd, dev, buf);

        break;

    default:

        rc = scsi_req_xfer(cmd, dev, buf);

        break;

    }



    if (rc != 0)

        return rc;



    memcpy(cmd->buf, buf, cmd->len);

    scsi_cmd_xfer_mode(cmd);

    cmd->lba = scsi_cmd_lba(cmd);

    return 0;

}

int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)

{

    int rc;



    cmd->lba = -1;

    cmd->len = scsi_cdb_length(buf);



    switch (dev->type) {

    case TYPE_TAPE:

        rc = scsi_req_stream_xfer(cmd, dev, buf);

        break;

    case TYPE_MEDIUM_CHANGER:

        rc = scsi_req_medium_changer_xfer(cmd, dev, buf);

        break;

    default:

        rc = scsi_req_xfer(cmd, dev, buf);

        break;

    }



    if (rc != 0)

        return rc;



    memcpy(cmd->buf, buf, cmd->len);

    scsi_cmd_xfer_mode(cmd);

    cmd->lba = scsi_cmd_lba(cmd);

    return 0;

}

    cmd->len = scsi_cdb_length(buf);
int FUNC_0(SCSIDevice *VAR_0, SCSICommand *VAR_1, uint8_t *VAR_2)

{

    int VAR_3;



    VAR_1->lba = -1;

    VAR_1->len = scsi_cdb_length(VAR_2);



    switch (VAR_0->type) {

    case TYPE_TAPE:

        VAR_3 = scsi_req_stream_xfer(VAR_1, VAR_0, VAR_2);

        break;

    case TYPE_MEDIUM_CHANGER:

        VAR_3 = scsi_req_medium_changer_xfer(VAR_1, VAR_0, VAR_2);

        break;

    default:

        VAR_3 = scsi_req_xfer(VAR_1, VAR_0, VAR_2);

        break;

    }



    if (VAR_3 != 0)

        return VAR_3;



    memcpy(VAR_1->VAR_2, VAR_2, VAR_1->len);

    scsi_cmd_xfer_mode(VAR_1);

    VAR_1->lba = scsi_cmd_lba(VAR_1);

    return 0;

}

int FUNC_0(SCSIDevice *VAR_0, SCSICommand *VAR_1, uint8_t *VAR_2)
{ int VAR_3; VAR_1->lba = -1; VAR_1->len = scsi_cdb_length(VAR_2); switch (VAR_0->type) { case TYPE_TAPE:
VAR_3 = scsi_req_stream_xfer(VAR_1, VAR_0, VAR_2); break; case TYPE_MEDIUM_CHANGER:
VAR_3 = scsi_req_medium_changer_xfer(VAR_1, VAR_0, VAR_2); break; default:
VAR_3 = scsi_req_xfer(VAR_1, VAR_0, VAR_2); break; } if (VAR_3 != 0)
return VAR_3; memcpy(VAR_1->VAR_2, VAR_2, VAR_1->len); scsi_cmd_xfer_mode(VAR_1); VAR_1->lba = scsi_cmd_lba(VAR_1); return 0; }