if (scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), 2, 20000, NULL, flags | SCSI_DATA_IN) != 0) { sc_print_addr(sc_link); printf("could not get size\n");
error = scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), 2, 20000, NULL, flags | SCSI_DATA_IN); if (error) { SC_DEBUG(sc_link, SDEV_DB1, ("READ CAPACITY error (%#x)\n", error));
scsi_size(sc_link, flags, blksize)	struct scsi_link *sc_link;	int flags;	u_int32_t *blksize;{	struct scsi_read_capacity scsi_cmd;	struct scsi_read_cap_data rdcap;	u_long max_addr;	if (blksize)		*blksize = 0;	/*	 * make up a scsi command and ask the scsi driver to do	 * it for you.	 */	bzero(&scsi_cmd, sizeof(scsi_cmd));	scsi_cmd.opcode = READ_CAPACITY;	/*	 * If the command works, interpret the result as a 4 byte	 * number of blocks	 */	if (scsi_scsi_cmd(sc_link, (struct scsi_generic *)&scsi_cmd,			  sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap),			  2, 20000, NULL, flags | SCSI_DATA_IN) != 0) {		sc_print_addr(sc_link);		printf("could not get size\n");		return (0);	}	max_addr = _4btol(rdcap.addr);	if (blksize)		*blksize = _4btol(rdcap.length);	if (max_addr == 0xffffffffUL) {		/*		 * The device is reporting it has more than 2^32-1 sectors. The		 * 16-byte READ CAPACITY command must be issued to get full		 * capacity.		 */		sc_print_addr(sc_link);		printf("only the first 4,294,967,295 sectors will be used.\n");		return (0xffffffffUL);	}		return (max_addr + 1);}