From 4a0167c18b5fab79b3ee766b25929d7d48dfb5dc Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Sun, 13 Jul 2008 07:16:24 +0000 Subject: [PATCH] - Remove incorrect check in RamdiskPnp -- we should only early-quit if the device is removed, not uninitialized, otherwise we'll never get initialized. - Add support for IRP_MN_SURPRISE_REMOVAL. - Handle IRP_MN_QUERY_ID for FDO (it is the first IRP we receive). - Handle IRP completion for FDOs and forward if necessary. svn path=/trunk/; revision=34451 --- .../drivers/storage/class/ramdisk/ramdisk.c | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/storage/class/ramdisk/ramdisk.c b/reactos/drivers/storage/class/ramdisk/ramdisk.c index 272aa88bcf0..36dff708f16 100644 --- a/reactos/drivers/storage/class/ramdisk/ramdisk.c +++ b/reactos/drivers/storage/class/ramdisk/ramdisk.c @@ -36,8 +36,10 @@ typedef enum _RAMDISK_DEVICE_STATE { RamdiskStateUninitialized, RamdiskStateStarted, + RamdiskStatePaused, RamdiskStateStopped, - RamdiskStateRemoved + RamdiskStateRemoved, + RamdiskStateBusRemoved, } RAMDISK_DEVICE_STATE; DEFINE_GUID(RamdiskBusInterface, @@ -281,9 +283,9 @@ RamdiskPnp(IN PDEVICE_OBJECT DeviceObject, Minor = IoStackLocation->MinorFunction; // - // Check if the device is initialized + // Check if the bus is removed // - if (DeviceExtension->State == RamdiskStateUninitialized) + if (DeviceExtension->State == RamdiskStateBusRemoved) { // // Only remove-device and query-id are allowed @@ -361,13 +363,25 @@ RamdiskPnp(IN PDEVICE_OBJECT DeviceObject, DPRINT1("PnP IRP: %lx\n", Minor); while (TRUE); break; - - case IRP_MN_QUERY_ID: + + case IRP_MN_SURPRISE_REMOVAL: DPRINT1("PnP IRP: %lx\n", Minor); while (TRUE); break; + case IRP_MN_QUERY_ID: + + // + // Are we a PDO? + // + if (DeviceExtension->Type == RamdiskPdo) + { + DPRINT1("PnP IRP: %lx\n", Minor); + while (TRUE); + } + break; + case IRP_MN_QUERY_BUS_INFORMATION: DPRINT1("PnP IRP: %lx\n", Minor); @@ -404,11 +418,28 @@ RamdiskPnp(IN PDEVICE_OBJECT DeviceObject, break; } + // + // Are we an FDO? + // + if (DeviceExtension->Type == RamdiskFdo) + { + // + // Do we have an attached device? + // + if (DeviceExtension->AttachedDevice) + { + // + // Forward the IRP + // + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + } + // // Release the lock and return status // IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); - while (TRUE); return Status; }