Bläddra i källkod

scsi: reset lba for this as the stand alone REQUEST SENSE is not in reference to a previous transfer.

Eric Helgeson 6 månader sedan
förälder
incheckning
0c484962db
1 ändrade filer med 9 tillägg och 0 borttagningar
  1. 9 0
      lib/SCSI2SD/src/firmware/scsi.c

+ 9 - 0
lib/SCSI2SD/src/firmware/scsi.c

@@ -555,6 +555,15 @@ static void process_Command()
 			// Newer initiators won't be specifying 0 anyway.
 			if (allocLength == 0) allocLength = 4;
 
+			// If we receive a stand-alone REQUEST SENSE to a bad LUN we still need to respond
+			// with LUN not supported. SCSI-2 Spec 7.5.3.
+			if (scsiDev.lun && scsiDev.lastStatus != CHECK_CONDITION)
+			{
+				scsiDev.target->sense.code = ILLEGAL_REQUEST;
+				scsiDev.target->sense.asc = LOGICAL_UNIT_NOT_SUPPORTED;
+				transfer.lba = 0;
+			}
+
 			memset(scsiDev.data, 0, 256); // Max possible alloc length
 			scsiDev.data[0] = 0xF0;
 			scsiDev.data[2] = scsiDev.target->sense.code & 0x0F;