-
-// Call scsi_pass_through and check sense.
-// TODO: Provide as member function of class scsi_device (?)
-static bool scsi_pass_through_and_check(scsi_device * scsidev, scsi_cmnd_io * iop,
- const char * msg = "")
-{
- // Provide sense buffer
- unsigned char sense[32] = {0, };
- iop->sensep = sense;
- iop->max_sense_len = sizeof(sense);
- iop->timeout = SCSI_TIMEOUT_DEFAULT;
-
- // Run cmd
- if (!scsidev->scsi_pass_through(iop)) {
- if (scsi_debugmode > 0)
- pout("%sscsi_pass_through() failed, errno=%d [%s]\n",
- msg, scsidev->get_errno(), scsidev->get_errmsg());
- return false;
- }
-
- // Check sense
- scsi_sense_disect sinfo;
- scsi_do_sense_disect(iop, &sinfo);
- int err = scsiSimpleSenseFilter(&sinfo);
- if (err) {
- if (scsi_debugmode > 0)
- pout("%sscsi error: %s\n", msg, scsiErrString(err));
- return scsidev->set_err(EIO, "scsi error %s", scsiErrString(err));
- }
-
- return true;
-}
-
-