From 320000e09389a04fc79b14b7f233a85ea4db6f83 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sun, 2 Jul 2006 05:44:27 +0000 Subject: [PATCH] - If the device to be mounted is an attachee, find the base device object - Reference the device object being mounted. - If the file system being mounted is an atachee, find its base device object too, and increase the IRP Stack for each attached FSD. - Fix IRP parameters with this new information. svn path=/trunk/; revision=22762 --- reactos/ntoskrnl/io/iomgr/volume.c | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/volume.c b/reactos/ntoskrnl/io/iomgr/volume.c index 3b70fc0d91d..90e2d23c2b0 100644 --- a/reactos/ntoskrnl/io/iomgr/volume.c +++ b/reactos/ntoskrnl/io/iomgr/volume.c @@ -284,8 +284,10 @@ IopMountVolume(IN PDEVICE_OBJECT DeviceObject, PIO_STACK_LOCATION StackPtr; PLIST_ENTRY FsList, ListEntry; PDEVICE_OBJECT DevObject; + PDEVICE_OBJECT AttachedDeviceObject = DeviceObject; PDEVICE_OBJECT FileSystemDeviceObject; LIST_ENTRY LocalList; + ULONG FsStackOverhead; PAGED_CODE(); /* Check if the device isn't already locked */ @@ -332,6 +334,16 @@ IopMountVolume(IN PDEVICE_OBJECT DeviceObject, /* Initialize the event to wait on */ KeInitializeEvent(&Event, NotificationEvent, FALSE); + /* Get the actual device to mount */ + while (AttachedDeviceObject->AttachedDevice) + { + /* Get the next one */ + AttachedDeviceObject = AttachedDeviceObject->AttachedDevice; + } + + /* Reference it */ + ObReferenceObject(AttachedDeviceObject); + /* Now loop the fs list until one of the file systems accepts us */ Status = STATUS_UNSUCCESSFUL; ListEntry = FsList->Flink; @@ -342,6 +354,20 @@ IopMountVolume(IN PDEVICE_OBJECT DeviceObject, DEVICE_OBJECT, Queue.ListEntry); + /* + * If this file system device is attached to some other device, + * then we must make sure to increase the stack size for the IRP. + * The default is +1, for the FS device itself. + */ + FsStackOverhead = 1; + while (FileSystemDeviceObject->AttachedDevice) + { + /* Get the next attached device and increase overhead */ + FileSystemDeviceObject = FileSystemDeviceObject-> + AttachedDevice; + FsStackOverhead++; + } + /* If we are not allowed to mount this volume as a raw filesystem volume then don't try this */ if (!AllowRawMount && RawFsIsRawFileSystemDeviceObject(FileSystemDeviceObject)) @@ -354,8 +380,8 @@ IopMountVolume(IN PDEVICE_OBJECT DeviceObject, KeClearEvent(&Event); /* Allocate the IRP */ - Irp = IoAllocateIrp(FileSystemDeviceObject->StackSize + - 1, + Irp = IoAllocateIrp(AttachedDeviceObject->StackSize + + FsStackOverhead, TRUE); if (!Irp) { @@ -378,7 +404,7 @@ IopMountVolume(IN PDEVICE_OBJECT DeviceObject, StackPtr->Flags = AllowRawMount; StackPtr->Parameters.MountVolume.Vpb = DeviceObject->Vpb; StackPtr->Parameters.MountVolume.DeviceObject = - DeviceObject; + AttachedDeviceObject; /* Call the driver */ Status = IoCallDriver(FileSystemDeviceObject, Irp);