[disk/pnp] Use similar removal logic to the dummy device
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 7 Jan 2011 18:02:30 +0000 (13:02 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 7 Jan 2011 18:03:36 +0000 (13:03 -0500)
We remove the node on the first IRP_MN_REMOVE_DEVICE and
invalidate the bus relations.  The PnP manager will see
our missing PDO on the re-enumeration, then will send a
second IRP_MN_REMOVE_DEVICE.  Then we free the disk.

src/include/disk.h
src/winvblock/disk/pnp.c

index c31426b..649edf9 100644 (file)
@@ -106,7 +106,6 @@ struct WV_DISK_T {
     WV_S_DEV_T Dev[1];
     KEVENT SearchEvent;
     KSPIN_LOCK SpinLock;
-    BOOLEAN Unmount;
     WV_E_DISK_MEDIA_TYPE Media;
     WV_S_DISK_OPS disk_ops;
     ULONGLONG LBADiskSize;
index 2cfa2ec..feae37c 100644 (file)
@@ -325,12 +325,13 @@ static NTSTATUS STDCALL disk_pnp__simple_(
           DBG("IRP_MN_REMOVE_DEVICE\n");
           dev->OldState = dev->State;
           dev->State = WvDevStateNotStarted;
-          if (disk->Unmount) {
+          if (!dev->BusNode.Linked) {
               WvDevClose(dev);
               IoDeleteDevice(dev->Self);
               WvDevFree(dev);
               status = STATUS_NO_SUCH_DEVICE;
             } else {
+              WvlBusRemoveNode(&dev->BusNode);
               status = STATUS_SUCCESS;
             }
           break;