From 11a686cfd5efc20b252f153356a4342a60938e4d Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 5 Jul 2021 10:54:47 +0200 Subject: [PATCH] Updated invalid LUN handling --- src/raspberrypi/controllers/sasidev_ctrl.cpp | 13 +++++++++++-- src/raspberrypi/controllers/scsidev_ctrl.cpp | 2 +- src/raspberrypi/exceptions.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/raspberrypi/controllers/sasidev_ctrl.cpp b/src/raspberrypi/controllers/sasidev_ctrl.cpp index 203dedf0..02d55025 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.cpp +++ b/src/raspberrypi/controllers/sasidev_ctrl.cpp @@ -986,7 +986,16 @@ void FASTCALL SASIDEV::CmdRequestSense() LOGTRACE( "%s REQUEST SENSE Command ", __PRETTY_FUNCTION__); - DWORD lun = GetLun(); + DWORD lun; + try { + lun = GetLun(); + } + catch(const lunexception& e) { + LOGINFO("%s unsupported LUN %d", __PRETTY_FUNCTION__, (int)e.getlun()); + // LOGICAL UNIT NOT SUPPORTED + Error(0x05, 0x25); + return; + } ctrl.length = ctrl.unit[lun]->RequestSense(ctrl.cmd, ctrl.buffer); ASSERT(ctrl.length > 0); @@ -1641,7 +1650,7 @@ void FASTCALL SASIDEV::ReceiveNext() try { Execute(); } - catch (lunexception& e) { + catch (const lunexception& e) { LOGINFO("%s unsupported LUN %d", __PRETTY_FUNCTION__, (int)e.getlun()); // LOGICAL UNIT NOT SUPPORTED Error(0x05, 0x25); diff --git a/src/raspberrypi/controllers/scsidev_ctrl.cpp b/src/raspberrypi/controllers/scsidev_ctrl.cpp index d0088435..f4c8b3f0 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.cpp +++ b/src/raspberrypi/controllers/scsidev_ctrl.cpp @@ -1630,7 +1630,7 @@ void FASTCALL SCSIDEV::Receive() try { Execute(); } - catch (lunexception& e) { + catch (const lunexception& e) { LOGINFO("%s unsupported LUN %d", __PRETTY_FUNCTION__, (int)e.getlun()); // LOGICAL UNIT NOT SUPPORTED Error(0x05, 0x25); diff --git a/src/raspberrypi/exceptions.h b/src/raspberrypi/exceptions.h index d6d4e874..7d2c6d28 100644 --- a/src/raspberrypi/exceptions.h +++ b/src/raspberrypi/exceptions.h @@ -23,7 +23,7 @@ public: ~lunexception() { } - DWORD getlun() { + DWORD getlun() const { return lun; } };