FreeBSD/usr.sbin/camdd/camdd.c
/*
 * Simplistic translation of CCB status to our local status.
 */
Simplistic translation of CCB status to our local status.
Simplistic translation of CCB status to our local status .
camdd_buf_status
camdd_ccb_status(union ccb *ccb)
{
	camdd_buf_status status = CAMDD_STATUS_NONE;
	cam_status ccb_status;
	ccb_status = ccb->ccb_h.status & CAM_STATUS_MASK;
	switch (ccb_status) {
	case CAM_REQ_CMP: {
		if (ccb->csio.resid == 0) {
			status = CAMDD_STATUS_OK;
		} else if (ccb->csio.dxfer_len > ccb->csio.resid) {
			status = CAMDD_STATUS_SHORT_IO;
		} else {
			status = CAMDD_STATUS_EOF;
		}
		break;
	}
	case CAM_SCSI_STATUS_ERROR: {
		switch (ccb->csio.scsi_status) {
		case SCSI_STATUS_OK:
		case SCSI_STATUS_COND_MET:
		case SCSI_STATUS_INTERMED:
		case SCSI_STATUS_INTERMED_COND_MET:
			status = CAMDD_STATUS_OK;
			break;
		case SCSI_STATUS_CMD_TERMINATED:
		case SCSI_STATUS_CHECK_COND:
		case SCSI_STATUS_QUEUE_FULL:
		case SCSI_STATUS_BUSY:
		case SCSI_STATUS_RESERV_CONFLICT:
		default:
			status = CAMDD_STATUS_ERROR;
			break;
		}
		break;
	}
	default:
		status = CAMDD_STATUS_ERROR;
		break;
	}
	return (status);
}
camdd_buf_status camdd_ccb_status ( union ccb * ccb ) { camdd_buf_status status = CAMDD_STATUS_NONE ; cam_status ccb_status ; ccb_status = ccb -> ccb_h . status & CAM_STATUS_MASK ; switch ( ccb_status ) { case CAM_REQ_CMP : { if ( ccb -> csio . resid == 0 ) { status = CAMDD_STATUS_OK ; } else if ( ccb -> csio . dxfer_len > ccb -> csio . resid ) { status = CAMDD_STATUS_SHORT_IO ; } else { status = CAMDD_STATUS_EOF ; } break ; } case CAM_SCSI_STATUS_ERROR : { switch ( ccb -> csio . scsi_status ) { case SCSI_STATUS_OK : case SCSI_STATUS_COND_MET : case SCSI_STATUS_INTERMED : case SCSI_STATUS_INTERMED_COND_MET : status = CAMDD_STATUS_OK ; break ; case SCSI_STATUS_CMD_TERMINATED : case SCSI_STATUS_CHECK_COND : case SCSI_STATUS_QUEUE_FULL : case SCSI_STATUS_BUSY : case SCSI_STATUS_RESERV_CONFLICT : default : status = CAMDD_STATUS_ERROR ; break ; } break ; } default : status = CAMDD_STATUS_ERROR ; break ; } return ( status ) ; }
Simplistic translation of CCB status to our local status.
Simplistic translation of CCB status to our local status .