int scsi_req_parse(SCSIRequest *req, uint8_t *buf)

{

    int rc;



    if (req->dev->type == TYPE_TAPE) {

        rc = scsi_req_stream_length(&req->cmd, req->dev, buf);

    } else {

        rc = scsi_req_length(&req->cmd, req->dev, buf);

    }

    if (rc != 0)

        return rc;



    assert(buf == req->cmd.buf);

    scsi_cmd_xfer_mode(&req->cmd);

    req->cmd.lba = scsi_cmd_lba(&req->cmd);

    trace_scsi_req_parsed(req->dev->id, req->lun, req->tag, buf[0],

                          req->cmd.mode, req->cmd.xfer);

    if (req->cmd.lba != -1) {

        trace_scsi_req_parsed_lba(req->dev->id, req->lun, req->tag, buf[0],

                              req->cmd.lba);

    }

    return 0;

}

int scsi_req_parse(SCSIRequest *req, uint8_t *buf)

{

    int rc;



    if (req->dev->type == TYPE_TAPE) {

        rc = scsi_req_stream_length(&req->cmd, req->dev, buf);

    } else {

        rc = scsi_req_length(&req->cmd, req->dev, buf);

    }

    if (rc != 0)

        return rc;



    assert(buf == req->cmd.buf);

    scsi_cmd_xfer_mode(&req->cmd);

    req->cmd.lba = scsi_cmd_lba(&req->cmd);

    trace_scsi_req_parsed(req->dev->id, req->lun, req->tag, buf[0],

                          req->cmd.mode, req->cmd.xfer);

    if (req->cmd.lba != -1) {

        trace_scsi_req_parsed_lba(req->dev->id, req->lun, req->tag, buf[0],

                              req->cmd.lba);

    }

    return 0;

}

int FUNC_0(SCSIRequest *VAR_0, uint8_t *VAR_1)

{

    int VAR_2;



    if (VAR_0->dev->type == TYPE_TAPE) {

        VAR_2 = scsi_req_stream_length(&VAR_0->cmd, VAR_0->dev, VAR_1);

    } else {

        VAR_2 = scsi_req_length(&VAR_0->cmd, VAR_0->dev, VAR_1);

    }

    if (VAR_2 != 0)

        return VAR_2;



    assert(VAR_1 == VAR_0->cmd.VAR_1);

    scsi_cmd_xfer_mode(&VAR_0->cmd);

    VAR_0->cmd.lba = scsi_cmd_lba(&VAR_0->cmd);

    trace_scsi_req_parsed(VAR_0->dev->id, VAR_0->lun, VAR_0->tag, VAR_1[0],

                          VAR_0->cmd.mode, VAR_0->cmd.xfer);

    if (VAR_0->cmd.lba != -1) {

        trace_scsi_req_parsed_lba(VAR_0->dev->id, VAR_0->lun, VAR_0->tag, VAR_1[0],

                              VAR_0->cmd.lba);

    }

    return 0;

}

int FUNC_0(SCSIRequest *VAR_0, uint8_t *VAR_1)
{ int VAR_2; if (VAR_0->dev->type == TYPE_TAPE) { VAR_2 = scsi_req_stream_length(&VAR_0->cmd, VAR_0->dev, VAR_1); } else { VAR_2 = scsi_req_length(&VAR_0->cmd, VAR_0->dev, VAR_1); } if (VAR_2 != 0)
return VAR_2; assert(VAR_1 == VAR_0->cmd.VAR_1); scsi_cmd_xfer_mode(&VAR_0->cmd); VAR_0->cmd.lba = scsi_cmd_lba(&VAR_0->cmd); trace_scsi_req_parsed(VAR_0->dev->id, VAR_0->lun, VAR_0->tag, VAR_1[0],
VAR_0->cmd.mode, VAR_0->cmd.xfer); if (VAR_0->cmd.lba != -1) { trace_scsi_req_parsed_lba(VAR_0->dev->id, VAR_0->lun, VAR_0->tag, VAR_1[0],
VAR_0->cmd.lba); } return 0; }