[FLOPPY] Implement IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
[reactos.git] / drivers / storage / floppy / ioctl.c
index 976e02e..74a3517 100644 (file)
@@ -74,6 +74,7 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
     PVOID OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
     ULONG Code = Stack->Parameters.DeviceIoControl.IoControlCode;
     BOOLEAN DiskChanged;
+    PMOUNTDEV_NAME Name;
 
     TRACE_(FLOPPY, "DeviceIoctl called\n");
     Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -255,6 +256,29 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
         Irp->IoStatus.Information = 0;
         break;
 
+    case IOCTL_MOUNTDEV_QUERY_DEVICE_NAME:
+        if (OutputLength < sizeof(MOUNTDEV_NAME)) {
+            Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+            Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
+            break;
+        }
+
+        Name = Irp->AssociatedIrp.SystemBuffer;
+        Name->NameLength = wcslen(&DriveInfo->SymLinkBuffer[0]) * sizeof(WCHAR);
+
+        if (OutputLength < sizeof(USHORT) + Name->NameLength) {
+            Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+            Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
+            break;
+        }
+
+        RtlCopyMemory(Name->Name, &DriveInfo->SymLinkBuffer[0],
+                      Name->NameLength);
+
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = sizeof(USHORT) + Name->NameLength;
+        break;
+
     default:
         ERR_(FLOPPY, "UNKNOWN IOCTL CODE: 0x%x\n", Code);
         Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;