Skip to content

Commit

Permalink
Improve SCSG status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Jan 7, 2025
1 parent 446171b commit 14171db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
12 changes: 4 additions & 8 deletions cpp/devices/scsi_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,10 @@ void ScsiGeneric::EvaluateStatus(int status, span<uint8_t> buf, span<const uint8
status = static_cast<int>(StatusCode::GOOD);
}

if (!status) {
status = static_cast<int>(sense_data[2]) & 0x0f;

if (static_cast<ScsiCommand>(local_cdb[0]) == ScsiCommand::INQUIRY && GetController()
&& GetController()->GetEffectiveLun()) {
// SCSI-2 section 8.2.5.1: Incorrect logical unit handling
buf[0] = 0x7f;
}
if (!status && static_cast<ScsiCommand>(local_cdb[0]) == ScsiCommand::INQUIRY && GetController()
&& GetController()->GetEffectiveLun()) {
// SCSI-2 section 8.2.5.1: Incorrect logical unit handling
buf[0] = 0x7f;
}

if (status) {
Expand Down
11 changes: 3 additions & 8 deletions cpp/shared/sg_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,9 @@ SgAdapter::SgResult SgAdapter::SendCommandInternal(span<uint8_t> cdb, span<uint8
status = static_cast<int>(StatusCode::GOOD);
}

// If the command was successful, use the sense key as status
if (!status) {
status = static_cast<int>(sense_data[2]) & 0x0f;

if (cdb[0] == static_cast<uint8_t>(ScsiCommand::INQUIRY) && (static_cast<int>(cdb[1]) & 0b11100000)) {
// SCSI-2 section 8.2.5.1: Incorrect logical unit handling
buf[0] = 0x7f;
}
if (!status && cdb[0] == static_cast<uint8_t>(ScsiCommand::INQUIRY) && (static_cast<int>(cdb[1]) & 0b11100000)) {
// SCSI-2 section 8.2.5.1: Incorrect logical unit handling
buf[0] = 0x7f;
}

if (status) {
Expand Down

0 comments on commit 14171db

Please sign in to comment.