From 2ab78f6784a3ba5da01b8b0d6b1f9b6beb77299a Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Tue, 23 Jan 2024 21:18:09 +0100 Subject: [PATCH] Update LUN handling --- cpp/controllers/generic_controller.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/controllers/generic_controller.cpp b/cpp/controllers/generic_controller.cpp index 60f3635d..2dd6799f 100644 --- a/cpp/controllers/generic_controller.cpp +++ b/cpp/controllers/generic_controller.cpp @@ -144,18 +144,19 @@ void GenericController::Execute() ResetOffset(); SetBlocks(1); - int lun = GetEffectiveLun(); // Discard pending sense data from the previous command if the current command is not REQUEST SENSE if (GetOpcode() != scsi_command::cmd_request_sense) { SetStatus(status::good); + int lun = GetEffectiveLun(); if (!HasDeviceForLun(lun)) { lun = 0; } GetDeviceForLun(lun)->SetStatusCode(0); } + int lun = GetEffectiveLun(); if (!HasDeviceForLun(lun)) { if (GetOpcode() != scsi_command::cmd_inquiry && GetOpcode() != scsi_command::cmd_request_sense) { LogTrace(fmt::format("Invalid LUN {}", lun));