SCSI Pass-Through Programmer's Guide
for (i=0; i < sizeof (struct sctl_io); i=i+4) {
printf ("%08x ", *j++);
} /* for loop */
printf ("\n");
}
void check_diag_command ( struct sctl_io command )
{
int i;
struct inquiry_2 *inq; /* ptr to some inquiry data, location tbd */
printf ("\n");
if (command.cdb_status != S_GOOD) {
fprintf(stderr, "SCSI command returned status 0x%02x\n",
command.cdb_status);
if (command.cdb_status == S_CHECK_CONDITION) {
if (command.sense_status != S_GOOD) { /* request sense failed? */
fprintf(stderr, "REQUEST SENSE returned status 0x%02x\n",
command.sense_status);
}
else { /* request sense worked, print details */
/* CHANGE TO "&sense_data" from "sense_data" */
memcpy(&sense_data, &(command.sense), command.sense_xfer);
fprintf(stderr, "Sense error code: 0x%02x\n", sense_data.error_code);
fprintf(stderr, "Sense key: 0x%02x\n", sense_data.key);
fprintf(stderr, "Sense code: 0x%02x\n", sense_data.code);
fprintf(stderr, "Sense qualifier: 0x%02x\n", sense_data.qualifier);
} /* else sense_status = S_GOOD */
} /* if we have a check condition, print details */
} /* if command status != S_GOOD */
else {
printf ("Good status, %d bytes returned (in hex): \n", command.data_xfer );
for (i=0; i<command.data_xfer; i++ ) {
printf ("%02x", buf [i]);
} /* for loop */
printf ("\n");
if (command.cdb[0] == 0x12) {
/* inq is declared as a pointer to a "struct inquiry_2" above */
/* point it at buf[] which should contain our inquiry data */
inq = (struct inquiry_2 *) &buf;
/* display the device type */
switch (inq->dev_type) {
case SCSI_DIRECT_ACCESS:
printf ("SCSI Direct Access (Disk) \n");
break;
case SCSI_SEQUENTIAL_ACCESS:
printf ("SCSI Sequential Access (Tape) \n");
break;
case SCSI_UNKNOWN_DEV_TYPE:
printf ("Unknown or No Device Type \n");
break;
default:
printf ("Device type not programmed: %02x \n", inq->dev_type );
break;
} /* end of switch */
- 18 -