src/sbin/camcontrol/camcontrol.c
/*
 * Returns 1 if the device has the VPD page, 0 if it does not, and -1 on an
 * error.
 */
Returns 1 if the device has the VPD page, 0 if it does not, and -1 on an
error.
Returns 1 if the device has the VPD page 0 if it does not and - 1 on an error .
int
dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count,
		 int timeout, int verbosemode)
{
	union ccb *ccb = NULL;
	struct scsi_vpd_supported_page_list sup_pages;
	int i;
	int retval = 0;
	ccb = cam_getccb(dev);
	if (ccb == NULL) {
		warn("Unable to allocate CCB");
		retval = -1;
		goto bailout;
	}
	CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio);
	bzero(&sup_pages, sizeof(sup_pages));
	scsi_inquiry(&ccb->csio,
		      retry_count,
		      NULL,
		      MSG_SIMPLE_Q_TAG,
		      (u_int8_t *)&sup_pages,
		      sizeof(sup_pages),
		      1,
		      SVPD_SUPPORTED_PAGE_LIST,
		      SSD_FULL_SIZE,
		      timeout ? timeout : 5000);
	ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
	if (retry_count != 0)
		ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER;
	if (cam_send_ccb(dev, ccb) < 0) {
		cam_freeccb(ccb);
		ccb = NULL;
		retval = -1;
		goto bailout;
	}
	if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
		if (verbosemode != 0)
			cam_error_print(dev, ccb, CAM_ESF_ALL,
					CAM_EPF_ALL, stderr);
		retval = -1;
		goto bailout;
	}
	for (i = 0; i < sup_pages.length; i++) {
		if (sup_pages.list[i] == page_id) {
			retval = 1;
			goto bailout;
		}
	}
bailout:
	if (ccb != NULL)
		cam_freeccb(ccb);
	return (retval);
}
int dev_has_vpd_page ( struct cam_device * dev , uint8_t page_id , int retry_count , int timeout , int verbosemode ) { union ccb * ccb = NULL ; struct scsi_vpd_supported_page_list sup_pages ; int i ; int retval = 0 ; ccb = cam_getccb ( dev ) ; if ( ccb == NULL ) { warn ( " " ) ; retval = -1 ; goto bailout ; } CCB_CLEAR_ALL_EXCEPT_HDR ( & ccb -> csio ) ; bzero ( & sup_pages , sizeof ( sup_pages ) ) ; scsi_inquiry ( & ccb -> csio , retry_count , NULL , MSG_SIMPLE_Q_TAG , ( u_int8_t * ) & sup_pages , sizeof ( sup_pages ) , 1 , SVPD_SUPPORTED_PAGE_LIST , SSD_FULL_SIZE , timeout ? timeout : 5000 ) ; ccb -> ccb_h . flags |= CAM_DEV_QFRZDIS ; if ( retry_count != 0 ) ccb -> ccb_h . flags |= CAM_PASS_ERR_RECOVER ; if ( cam_send_ccb ( dev , ccb ) < 0 ) { cam_freeccb ( ccb ) ; ccb = NULL ; retval = -1 ; goto bailout ; } if ( ( ccb -> ccb_h . status & CAM_STATUS_MASK ) != CAM_REQ_CMP ) { if ( verbosemode != 0 ) cam_error_print ( dev , ccb , CAM_ESF_ALL , CAM_EPF_ALL , stderr ) ; retval = -1 ; goto bailout ; } for ( i = 0 ; i < sup_pages . length ; i ++ ) { if ( sup_pages . list [ i ] == page_id ) { retval = 1 ; goto bailout ; } } bailout : if ( ccb != NULL ) cam_freeccb ( ccb ) ; return ( retval ) ; }
Returns 1 if the device has the VPD page, 0 if it does not, and -1 on an
 error.
Returns 1 if the device has the VPD page 0 if it does not and - 1 on an error .
/* cam_getccb cleans up the header, caller has to zero the payload */ /*retries*/ /*cbfcnp*/ /* tag_action */ /* inq_buf */ /* inq_len */ /* evpd */ /* page_code */ /* sense_len */ /* timeout */ /* Disable freezing the device queue */