Resolved TODO, rascsi guarantees that LUN 0 is always present (#681)

This commit is contained in:
Uwe Seimet 2022-02-18 21:04:07 +01:00 committed by GitHub
parent 2281a7e53b
commit e13cf1ebb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,37 +45,19 @@ void PrimaryDevice::TestUnitReady(SASIDEV *controller)
void PrimaryDevice::Inquiry(SASIDEV *controller) void PrimaryDevice::Inquiry(SASIDEV *controller)
{ {
int lun = controller->GetEffectiveLun(); ctrl->length = Inquiry(ctrl->cmd, ctrl->buffer);
const Device *device = ctrl->unit[lun];
// Find a valid unit
// TODO The code below is probably wrong. It results in the same INQUIRY data being
// used for all LUNs, even though each LUN has its individual set of INQUIRY data.
// In addition, it supports gaps in the LUN list, which is not correct.
if (!device) {
for (int valid_lun = 0; valid_lun < SASIDEV::UnitMax; valid_lun++) {
if (ctrl->unit[valid_lun]) {
device = ctrl->unit[valid_lun];
break;
}
}
}
if (device) {
ctrl->length = Inquiry(ctrl->cmd, ctrl->buffer);
} else {
ctrl->length = 0;
}
if (ctrl->length <= 0) { if (ctrl->length <= 0) {
controller->Error(); controller->Error();
return; return;
} }
int lun = controller->GetEffectiveLun();
// Report if the device does not support the requested LUN // Report if the device does not support the requested LUN
if (!ctrl->unit[lun]) { if (!ctrl->unit[lun]) {
LOGTRACE("Reporting LUN %d for device ID %d as not supported", lun, ctrl->device->GetId()); LOGTRACE("Reporting LUN %d for device ID %d as not supported", lun, ctrl->device->GetId());
// Signal that the requested LUN does not exist
ctrl->buffer[0] |= 0x7f; ctrl->buffer[0] |= 0x7f;
} }