[bus/dev_ctl,driver] Move IRP_MJ_DEVICE_CONTROL handler
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Tue, 28 Dec 2010 22:35:19 +0000 (17:35 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Tue, 28 Dec 2010 22:35:19 +0000 (17:35 -0500)
A driver using the bus library should implement their own
IRP_MJ_DEVICE_CONTROL handler for a bus instance; these
device controls will be driver-specific.

WinVBlock.dev
src/winvblock/bus/bus.c
src/winvblock/bus/dev_ctl.c [deleted file]
src/winvblock/bus/makelib.bat
src/winvblock/driver.c

index 485716e..a768eab 100644 (file)
@@ -1,7 +1,7 @@
 [Project]\r
 FileName=WinVBlock.dev\r
 Name=WinVBlock\r
-UnitCount=62\r
+UnitCount=61\r
 PchHead=-1\r
 PchSource=-1\r
 Ver=3\r
@@ -84,9 +84,9 @@ CompilerSet=1
 CompilerType=1\r
 \r
 [Unit21]\r
-FileName=src\winvblock\disk\scsi.c\r
+FileName=src\winvblock\ramdisk\grub4dos.c\r
 CompileCpp=1\r
-Folder=WinVBlock/Disk\r
+Folder=WinVBlock/RAMDisk\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -94,7 +94,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit23]\r
-FileName=src\winvblock\ramdisk\memdisk.c\r
+FileName=src\winvblock\ramdisk\ramdisk.c\r
 CompileCpp=1\r
 Folder=WinVBlock/RAMDisk\r
 Compile=1\r
@@ -104,7 +104,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit22]\r
-FileName=src\winvblock\ramdisk\grub4dos.c\r
+FileName=src\winvblock\ramdisk\memdisk.c\r
 CompileCpp=1\r
 Folder=WinVBlock/RAMDisk\r
 Compile=1\r
@@ -114,27 +114,27 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit24]\r
-FileName=src\winvblock\ramdisk\ramdisk.c\r
-Folder=WinVBlock/RAMDisk\r
+FileName=src\winvblock\winvblock.rc\r
+Folder=WinVBlock\r
 Compile=1\r
-Link=1\r
+Link=0\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
 CompileCpp=1\r
 \r
 [Unit25]\r
-FileName=src\winvblock\winvblock.rc\r
+FileName=src\include\aoe.h\r
 CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=Include\r
 Compile=1\r
-Link=0\r
+Link=1\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
 [Unit26]\r
-FileName=src\include\aoe.h\r
+FileName=src\include\bus.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -144,7 +144,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit27]\r
-FileName=src\include\bus.h\r
+FileName=src\include\debug.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -154,7 +154,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit28]\r
-FileName=src\include\debug.h\r
+FileName=src\include\disk.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -164,7 +164,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit30]\r
-FileName=src\include\driver.h\r
+FileName=src\include\filedisk.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -174,7 +174,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit35]\r
-FileName=src\include\memdisk.h\r
+FileName=src\include\mount.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -184,7 +184,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit36]\r
-FileName=src\include\mount.h\r
+FileName=src\include\portable.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -194,7 +194,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit19]\r
-FileName=src\winvblock\disk\disk.c\r
+FileName=src\winvblock\disk\pnp.c\r
 CompileCpp=1\r
 Folder=WinVBlock/Disk\r
 Compile=1\r
@@ -204,7 +204,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit37]\r
-FileName=src\include\portable.h\r
+FileName=src\include\probe.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -214,7 +214,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit38]\r
-FileName=src\include\probe.h\r
+FileName=src\include\protocol.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -224,7 +224,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit39]\r
-FileName=src\include\protocol.h\r
+FileName=src\include\ramdisk.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -234,7 +234,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit40]\r
-FileName=src\include\ramdisk.h\r
+FileName=src\include\registry.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -244,7 +244,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit41]\r
-FileName=src\include\registry.h\r
+FileName=src\include\resource.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -254,7 +254,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit42]\r
-FileName=src\include\resource.h\r
+FileName=src\include\winvblock.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -264,8 +264,8 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit43]\r
-FileName=src\include\winvblock.h\r
-Folder=Include\r
+FileName=src\util\mount.c\r
+Folder=Util\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -274,29 +274,29 @@ BuildCmd=
 CompileCpp=1\r
 \r
 [Unit44]\r
-FileName=src\util\mount.c\r
+FileName=src\aoe\aoe.rc\r
 CompileCpp=1\r
-Folder=Util\r
+Folder=AoE\r
 Compile=1\r
-Link=1\r
+Link=0\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
 [Unit45]\r
-FileName=src\aoe\aoe.rc\r
+FileName=src\include\device.h\r
 CompileCpp=1\r
-Folder=AoE\r
+Folder=Include\r
 Compile=1\r
-Link=0\r
+Link=1\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
 [Unit46]\r
-FileName=src\include\device.h\r
+FileName=src\winvblock\device.c\r
 CompileCpp=1\r
-Folder=Include\r
+Folder=WinVBlock\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -304,8 +304,8 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit47]\r
-FileName=src\winvblock\device.c\r
-Folder=WinVBlock\r
+FileName=src\winvblock\filedisk\filedisk.c\r
+Folder=WinVBlock/FileDisk\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -314,7 +314,7 @@ BuildCmd=
 CompileCpp=1\r
 \r
 [Unit48]\r
-FileName=src\winvblock\filedisk\filedisk.c\r
+FileName=src\winvblock\filedisk\grub4dos.c\r
 CompileCpp=1\r
 Folder=WinVBlock/FileDisk\r
 Compile=1\r
@@ -324,9 +324,9 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit49]\r
-FileName=src\winvblock\filedisk\grub4dos.c\r
+FileName=src\include\byte.h\r
 CompileCpp=1\r
-Folder=WinVBlock/FileDisk\r
+Folder=Include\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -334,7 +334,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit50]\r
-FileName=src\include\byte.h\r
+FileName=src\include\msvhd.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -344,21 +344,21 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit51]\r
-FileName=src\include\msvhd.h\r
-Folder=Include\r
+FileName=src\util\winvblock.rc\r
+Folder=Util\r
 Compile=1\r
-Link=1\r
+Link=0\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
 CompileCpp=1\r
 \r
 [Unit52]\r
-FileName=src\util\winvblock.rc\r
+FileName=src\include\wv_stdlib.h\r
 CompileCpp=1\r
-Folder=Util\r
+Folder=Include\r
 Compile=1\r
-Link=0\r
+Link=1\r
 Priority=1000\r
 OverrideBuildCmd=0\r
 BuildCmd=\r
@@ -501,20 +501,10 @@ Priority=1000
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
-[Unit16]\r
-FileName=src\winvblock\bus\dev_ctl.c\r
-CompileCpp=1\r
-Folder=WinVBlock/Bus\r
-Compile=1\r
-Link=1\r
-Priority=1000\r
-OverrideBuildCmd=0\r
-BuildCmd=\r
-\r
 [Unit17]\r
-FileName=src\winvblock\bus\pnp.c\r
+FileName=src\winvblock\disk\dev_ctl.c\r
 CompileCpp=1\r
-Folder=WinVBlock/Bus\r
+Folder=WinVBlock/Disk\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -522,7 +512,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit18]\r
-FileName=src\winvblock\disk\dev_ctl.c\r
+FileName=src\winvblock\disk\disk.c\r
 CompileCpp=1\r
 Folder=WinVBlock/Disk\r
 Compile=1\r
@@ -532,7 +522,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit20]\r
-FileName=src\winvblock\disk\pnp.c\r
+FileName=src\winvblock\disk\scsi.c\r
 CompileCpp=1\r
 Folder=WinVBlock/Disk\r
 Compile=1\r
@@ -542,8 +532,8 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit53]\r
-FileName=src\include\wv_stdlib.h\r
-Folder=Include\r
+FileName=src\winvblock\wv_stdlib.c\r
+Folder=WinVBlock\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -552,9 +542,9 @@ BuildCmd=
 CompileCpp=1\r
 \r
 [Unit54]\r
-FileName=src\winvblock\wv_stdlib.c\r
+FileName=src\include\wv_stddef.h\r
 CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=Include\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -562,9 +552,9 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit55]\r
-FileName=src\include\wv_stddef.h\r
+FileName=src\aoe\wv_stdlib.c\r
 CompileCpp=1\r
-Folder=Include\r
+Folder=AoE\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -572,9 +562,9 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit56]\r
-FileName=src\aoe\wv_stdlib.c\r
+FileName=src\include\wv_string.h\r
 CompileCpp=1\r
-Folder=AoE\r
+Folder=Include\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -582,9 +572,9 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit57]\r
-FileName=src\include\wv_string.h\r
+FileName=src\winvblock\wv_string.c\r
 CompileCpp=1\r
-Folder=Include\r
+Folder=WinVBlock\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -592,9 +582,9 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit58]\r
-FileName=src\winvblock\wv_string.c\r
+FileName=src\include\wv_stdbool.h\r
 CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=Include\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -602,8 +592,8 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit59]\r
-FileName=src\include\wv_stdbool.h\r
-Folder=Include\r
+FileName=src\aoe\wv_string.c\r
+Folder=AoE\r
 Compile=1\r
 Link=1\r
 Priority=1000\r
@@ -612,7 +602,7 @@ BuildCmd=
 CompileCpp=1\r
 \r
 [Unit61]\r
-FileName=src\aoe\bus.c\r
+FileName=src\aoe\registry.c\r
 CompileCpp=1\r
 Folder=AoE\r
 Compile=1\r
@@ -622,7 +612,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit60]\r
-FileName=src\aoe\wv_string.c\r
+FileName=src\aoe\bus.c\r
 CompileCpp=1\r
 Folder=AoE\r
 Compile=1\r
@@ -702,7 +692,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit32]\r
-FileName=src\include\grub4dos.h\r
+FileName=src\include\httpdisk.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -712,7 +702,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit33]\r
-FileName=src\include\httpdisk.h\r
+FileName=src\include\mdi.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -722,7 +712,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit29]\r
-FileName=src\include\disk.h\r
+FileName=src\include\driver.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -732,7 +722,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit31]\r
-FileName=src\include\filedisk.h\r
+FileName=src\include\grub4dos.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -752,7 +742,7 @@ OverrideBuildCmd=0
 BuildCmd=\r
 \r
 [Unit34]\r
-FileName=src\include\mdi.h\r
+FileName=src\include\memdisk.h\r
 CompileCpp=1\r
 Folder=Include\r
 Compile=1\r
@@ -771,3 +761,13 @@ Priority=1000
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
+[Unit16]\r
+FileName=src\winvblock\bus\pnp.c\r
+CompileCpp=1\r
+Folder=WinVBlock/Bus\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
index 41fdbd8..cc6bbbc 100644 (file)
@@ -35,9 +35,6 @@
 #include "bus.h"
 #include "debug.h"
 
-/* IRP_MJ_DEVICE_CONTROL dispatcher from bus/dev_ctl.c */
-extern WV_F_DEV_CTL WvBusDevCtlDispatch;
-
 /* Types. */
 typedef enum WV_BUS_WORK_ITEM_CMD_ {
     WvBusWorkItemCmdAddPdo_,
@@ -67,7 +64,7 @@ static WV_SP_BUS_WORK_ITEM_ WvBusGetWorkItem_(WV_SP_BUS_T);
 WV_S_DEV_IRP_MJ WvBusIrpMj_ = {
     (WV_FP_DEV_DISPATCH) 0,
     (WV_FP_DEV_DISPATCH) 0,
-    WvBusDevCtlDispatch,
+    (WV_FP_DEV_CTL) 0,
     (WV_FP_DEV_SCSI) 0,
     (WV_FP_DEV_PNP) 0,
   };
diff --git a/src/winvblock/bus/dev_ctl.c b/src/winvblock/bus/dev_ctl.c
deleted file mode 100644 (file)
index 2ea8da2..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
- * Copyright 2006-2008, V.
- * For WinAoE contact information, see http://winaoe.org/
- *
- * This file is part of WinVBlock, derived from WinAoE.
- *
- * WinVBlock is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * WinVBlock is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinVBlock.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file
- *
- * Bus Device Control IRP handling.
- */
-
-#include <ntddk.h>
-
-#include "winvblock.h"
-#include "portable.h"
-#include "driver.h"
-#include "device.h"
-#include "disk.h"
-#include "mount.h"
-#include "bus.h"
-#include "debug.h"
-#include "filedisk.h"
-
-/* Forward declarations. */
-static WV_F_DEV_DISPATCH WvBusDevCtlDiskDetach_;
-
-static NTSTATUS STDCALL WvBusDevCtlDiskDetach_(
-    IN WV_SP_DEV_T dev,
-    IN PIRP irp
-  ) {
-    winvblock__uint8_ptr buffer = irp->AssociatedIrp.SystemBuffer;
-    winvblock__uint32 disk_num = *(winvblock__uint32_ptr) buffer;
-    WV_SP_DEV_T dev_walker;
-    WV_SP_DISK_T disk_walker = NULL, prev_disk_walker;
-    WV_SP_BUS_T bus;
-
-    DBG("Request to detach disk: %d\n", disk_num);
-    bus = WvBusFromDev(dev);
-    dev_walker = bus->first_child;
-    if (dev_walker != NULL)
-      disk_walker = disk__get_ptr(dev_walker);
-    prev_disk_walker = disk_walker;
-    while ((disk_walker != NULL) && (dev_walker->DevNum != disk_num)) {
-        prev_disk_walker = disk_walker;
-        dev_walker = dev_walker->next_sibling_ptr;
-        if (dev_walker != NULL)
-          disk_walker = disk__get_ptr(dev_walker);
-      }
-    if (disk_walker != NULL) {
-        if (disk_walker->BootDrive) {
-            DBG("Cannot unmount a boot drive.\n");
-            irp->IoStatus.Information = 0;
-            return STATUS_INVALID_DEVICE_REQUEST;
-          }
-        DBG("Deleting disk %d\n", dev_walker->DevNum);
-        if (disk_walker == disk__get_ptr(bus->first_child))
-          bus->first_child = dev_walker->next_sibling_ptr;
-          else {
-            prev_disk_walker->Dev->next_sibling_ptr =
-              dev_walker->next_sibling_ptr;
-          }
-        disk_walker->Unmount = TRUE;
-        dev_walker->next_sibling_ptr = NULL;
-        if (bus->PhysicalDeviceObject != NULL)
-          IoInvalidateDeviceRelations(bus->PhysicalDeviceObject, BusRelations);
-      }
-    bus->Children--;
-    irp->IoStatus.Information = 0;
-    return STATUS_SUCCESS;
-  }
-
-NTSTATUS STDCALL WvBusDevCtlDispatch(
-    IN WV_SP_DEV_T dev,
-    IN PIRP irp,
-    IN ULONG POINTER_ALIGNMENT code
-  ) {
-    NTSTATUS status;
-
-    switch (code) {
-        case IOCTL_FILE_ATTACH:
-          status = filedisk__attach(dev, irp);
-          break;
-
-        case IOCTL_FILE_DETACH:
-          status = WvBusDevCtlDiskDetach_(dev, irp);
-          break;
-
-        default:
-          irp->IoStatus.Information = 0;
-          status = STATUS_INVALID_DEVICE_REQUEST;
-      }
-
-    irp->IoStatus.Status = status;
-    IoCompleteRequest(irp, IO_NO_INCREMENT);
-    return status;
-  }
index 7c16d9b..17b18d6 100644 (file)
@@ -2,7 +2,7 @@
 \r
 set libname=bus\r
 \r
-set c=bus.c dev_ctl.c pnp.c\r
+set c=bus.c pnp.c\r
 \r
 echo !INCLUDE $(NTMAKEENV)\makefile.def        > makefile\r
 \r
index d054bb3..441f293 100644 (file)
@@ -80,6 +80,7 @@ static driver__dispatch_func driver__dispatch_scsi_;
 static driver__dispatch_func driver__dispatch_pnp_;
 static void STDCALL driver__unload_(IN PDRIVER_OBJECT);
 static WV_F_DEV_DISPATCH WvDriverBusSysCtl_;
+static WV_F_DEV_CTL WvDriverBusDevCtl_;
 static WV_F_DEV_DISPATCH WvDriverBusPower_;
 static WV_F_DEV_PNP WvDriverBusPnp_;
 
@@ -185,6 +186,7 @@ static NTSTATUS STDCALL driver__attach_fdo_(
     WvDriverBus_.Dev.Self = WvDriverBus_.Fdo = fdo;
     WvDriverBus_.Dev.IsBus = TRUE;
     WvDriverBus_.Dev.IrpMj->SysCtl = WvDriverBusSysCtl_;
+    WvDriverBus_.Dev.IrpMj->DevCtl = WvDriverBusDevCtl_;
     WvDriverBus_.Dev.IrpMj->Power = WvDriverBusPower_;
     WvDriverBus_.Dev.IrpMj->Pnp = WvDriverBusPnp_;
     WvDriverBus_.PhysicalDeviceObject = PhysicalDeviceObject;
@@ -640,3 +642,74 @@ winvblock__lib_func winvblock__bool STDCALL WvDriverBusAddDev(
     DBG("Exit\n");
     return TRUE;
   }
+
+static NTSTATUS STDCALL WvDriverBusDevCtlDiskDetach_(
+    IN WV_SP_DEV_T dev,
+    IN PIRP irp
+  ) {
+    winvblock__uint8_ptr buffer = irp->AssociatedIrp.SystemBuffer;
+    winvblock__uint32 disk_num = *(winvblock__uint32_ptr) buffer;
+    WV_SP_DEV_T dev_walker;
+    WV_SP_DISK_T disk_walker = NULL, prev_disk_walker;
+    WV_SP_BUS_T bus;
+
+    DBG("Request to detach disk: %d\n", disk_num);
+    bus = WvBusFromDev(dev);
+    dev_walker = bus->first_child;
+    if (dev_walker != NULL)
+      disk_walker = disk__get_ptr(dev_walker);
+    prev_disk_walker = disk_walker;
+    while ((disk_walker != NULL) && (dev_walker->DevNum != disk_num)) {
+        prev_disk_walker = disk_walker;
+        dev_walker = dev_walker->next_sibling_ptr;
+        if (dev_walker != NULL)
+          disk_walker = disk__get_ptr(dev_walker);
+      }
+    if (disk_walker != NULL) {
+        if (disk_walker->BootDrive) {
+            DBG("Cannot unmount a boot drive.\n");
+            irp->IoStatus.Information = 0;
+            return STATUS_INVALID_DEVICE_REQUEST;
+          }
+        DBG("Deleting disk %d\n", dev_walker->DevNum);
+        if (disk_walker == disk__get_ptr(bus->first_child))
+          bus->first_child = dev_walker->next_sibling_ptr;
+          else {
+            prev_disk_walker->Dev->next_sibling_ptr =
+              dev_walker->next_sibling_ptr;
+          }
+        disk_walker->Unmount = TRUE;
+        dev_walker->next_sibling_ptr = NULL;
+        if (bus->PhysicalDeviceObject != NULL)
+          IoInvalidateDeviceRelations(bus->PhysicalDeviceObject, BusRelations);
+      }
+    bus->Children--;
+    irp->IoStatus.Information = 0;
+    return STATUS_SUCCESS;
+  }
+
+NTSTATUS STDCALL WvDriverBusDevCtl_(
+    IN WV_SP_DEV_T dev,
+    IN PIRP irp,
+    IN ULONG POINTER_ALIGNMENT code
+  ) {
+    NTSTATUS status;
+
+    switch (code) {
+        case IOCTL_FILE_ATTACH:
+          status = filedisk__attach(dev, irp);
+          break;
+
+        case IOCTL_FILE_DETACH:
+          status = WvDriverBusDevCtlDiskDetach_(dev, irp);
+          break;
+
+        default:
+          irp->IoStatus.Information = 0;
+          status = STATUS_INVALID_DEVICE_REQUEST;
+      }
+
+    irp->IoStatus.Status = status;
+    IoCompleteRequest(irp, IO_NO_INCREMENT);
+    return status;
+  }