[SCSIPORT] Better error messages when receiving unexpected IOCTLs of mount manager
[reactos.git] / reactos / drivers / storage / scsiport / scsiport.c
index d67d136..0585b0d 100644 (file)
@@ -34,6 +34,7 @@
 #include <scsi.h>
 #include <ntddscsi.h>
 #include <ntdddisk.h>
+#include <mountdev.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -1840,6 +1841,8 @@ ScsiPortLogError(IN PVOID HwDeviceExtension,
   //PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
 
   DPRINT1("ScsiPortLogError() called\n");
+  DPRINT1("PathId: 0x%02x  TargetId: 0x%02x  Lun: 0x%02x  ErrorCode: 0x%08lx  UniqueId: 0x%08lx\n",
+          PathId, TargetId, Lun, ErrorCode, UniqueId);
 
   //DeviceExtension = CONTAINING_RECORD(HwDeviceExtension, SCSI_PORT_DEVICE_EXTENSION, MiniPortDeviceExtension);
 
@@ -2875,8 +2878,20 @@ ScsiPortDeviceControl(IN PDEVICE_OBJECT DeviceObject,
           break;
 
       default:
-          if ('M' == (Stack->Parameters.DeviceIoControl.IoControlCode >> 16)) {
-            DPRINT1("  got ioctl intended for the mount manager: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
+          if (DEVICE_TYPE_FROM_CTL_CODE(Stack->Parameters.DeviceIoControl.IoControlCode) == MOUNTDEVCONTROLTYPE)
+          {
+            switch (Stack->Parameters.DeviceIoControl.IoControlCode)
+            {
+            case IOCTL_MOUNTDEV_QUERY_DEVICE_NAME:
+                DPRINT1("Got unexpected IOCTL_MOUNTDEV_QUERY_DEVICE_NAME\n");
+                break;
+            case IOCTL_MOUNTDEV_QUERY_UNIQUE_ID:
+                DPRINT1("Got unexpected IOCTL_MOUNTDEV_QUERY_UNIQUE_ID\n");
+                break;
+            default:
+                DPRINT1("  got ioctl intended for the mount manager: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
+                break;
+            }
           } else {
             DPRINT1("  unknown ioctl code: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
           }
@@ -3286,7 +3301,7 @@ SpiAdapterControl(PDEVICE_OBJECT DeviceObject,
             break;
 
         ScatterGatherList->Length = Srb->DataTransferLength - TotalLength;
-        ScatterGatherList->PhysicalAddress = IoMapTransfer(NULL,
+        ScatterGatherList->PhysicalAddress = IoMapTransfer(DeviceExtension->AdapterObject,
                                                            Irp->MdlAddress,
                                                            MapRegisterBase,
                                                            DataVA + TotalLength,
@@ -5294,7 +5309,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
                          L"\\Registry\\Machine\\Hardware\\DeviceMap\\Scsi");
   InitializeObjectAttributes(&ObjectAttributes,
                             &KeyName,
-                            OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
+                            OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE,
                             0,
                             NULL);
   Status = ZwCreateKey(&ScsiKey,
@@ -5321,7 +5336,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
                       NameBuffer);
   InitializeObjectAttributes(&ObjectAttributes,
                             &KeyName,
-                            0,
+                            OBJ_KERNEL_HANDLE,
                             ScsiKey,
                             NULL);
   Status = ZwCreateKey(&ScsiPortKey,