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
1 changed files with 4 additions and 22 deletions

View File

@ -45,37 +45,19 @@ void PrimaryDevice::TestUnitReady(SASIDEV *controller)
void PrimaryDevice::Inquiry(SASIDEV *controller)
{
int lun = controller->GetEffectiveLun();
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;
}
ctrl->length = Inquiry(ctrl->cmd, ctrl->buffer);
if (ctrl->length <= 0) {
controller->Error();
return;
}
int lun = controller->GetEffectiveLun();
// Report if the device does not support the requested LUN
if (!ctrl->unit[lun]) {
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;
}