Jelajahi Sumber

iSCSI Console v1.3.0

Tal Aloni 8 tahun lalu
induk
melakukan
b51afc1865

+ 2 - 2
ISCSI/Properties/AssemblyInfo.cs

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
 //
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
-[assembly: AssemblyVersion("1.2.9.0")]
-[assembly: AssemblyFileVersion("1.2.9.0")]
+[assembly: AssemblyVersion("1.3.0.0")]
+[assembly: AssemblyFileVersion("1.3.0.0")]

+ 3 - 0
ISCSI/RevisionHistory.txt

@@ -62,3 +62,6 @@ Revision History:
 1.2.8 - Reject improper commands during the login phase.
 
 1.2.9 - Reject improper commands before login is complete.
+
+1.3.0 - Bugfix: Invalid ReadCapacity16 command response was returend.
+		Bugfix: Incorrect ResidualCount value was returned.

+ 14 - 2
ISCSI/Server/SCSITarget.cs

@@ -1,3 +1,9 @@
+/* Copyright (C) 2012-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
+ * 
+ * You can redistribute this program and/or modify it under the terms of
+ * the GNU Lesser Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ */
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -90,7 +96,8 @@ namespace ISCSI.Server
             else if (command.OpCode == SCSIOpCodeName.ServiceActionIn &&
                      command.ServiceAction == ServiceAction.ReadCapacity16)
             {
-                return ReadCapacity16(lun, out response);
+                uint allocationLength = command.TransferLength;
+                return ReadCapacity16(lun, allocationLength, out response);
             }
             else if (command.OpCode == SCSIOpCodeName.ReportLUNs)
             {
@@ -321,7 +328,7 @@ namespace ISCSI.Server
             return SCSIStatusCodeName.Good;
         }
 
-        public SCSIStatusCodeName ReadCapacity16(LUNStructure lun, out byte[] response)
+        public SCSIStatusCodeName ReadCapacity16(LUNStructure lun, uint allocationLength, out byte[] response)
         {
             if (lun >= m_disks.Count)
             {
@@ -331,6 +338,11 @@ namespace ISCSI.Server
 
             ReadCapacity16Parameter parameter = new ReadCapacity16Parameter(m_disks[lun].Size, (uint)m_disks[lun].BytesPerSector);
             response = parameter.GetBytes();
+            // we must not return more bytes than ReadCapacity16.AllocationLength
+            if (response.Length > allocationLength)
+            {
+                response = ByteReader.ReadBytes(response, 0, (int)allocationLength);
+            }
             return SCSIStatusCodeName.Good;
         }
 

+ 2 - 2
ISCSI/Server/TargetResponseHelper.cs

@@ -164,7 +164,7 @@ namespace ISCSI.Server
             if (response.Data.Length > expectedDataTransferLength)
             {
                 response.ResidualOverflow = true;
-                response.ResidualCount = (uint)(expectedDataTransferLength - response.Data.Length);
+                response.ResidualCount = (uint)(response.Data.Length - expectedDataTransferLength);
                 response.Data = ByteReader.ReadBytes(response.Data, 0, (int)expectedDataTransferLength);
             }
             else if (response.Data.Length < expectedDataTransferLength)
@@ -179,7 +179,7 @@ namespace ISCSI.Server
             if (response.Data.Length > expectedDataTransferLength)
             {
                 response.ResidualOverflow = true;
-                response.ResidualCount = (uint)(expectedDataTransferLength - response.Data.Length);
+                response.ResidualCount = (uint)(response.Data.Length - expectedDataTransferLength);
                 response.Data = ByteReader.ReadBytes(response.Data, 0, (int)expectedDataTransferLength);
             }
             else if (response.Data.Length < expectedDataTransferLength)

+ 2 - 2
ISCSIConsole/Properties/AssemblyInfo.cs

@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
 //      Build Number
 //      Revision
 //
-[assembly: AssemblyVersion("1.2.9.0")]
-[assembly: AssemblyFileVersion("1.2.9.0")]
+[assembly: AssemblyVersion("1.3.0.0")]
+[assembly: AssemblyFileVersion("1.3.0.0")]

+ 2 - 0
ISCSIConsole/RevisionHistory.txt

@@ -61,3 +61,5 @@ Revision History:
 1.2.8 - Updates to the ISCSI library.
 
 1.2.9 - Updates to the ISCSI library.
+
+1.3.0 - Updates to the ISCSI library.