From 58764219132dac140c52d0be655330484b5923ed Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 23 Feb 2016 22:19:38 +0000 Subject: [PATCH] [NTFS] Even more locking svn path=/trunk/; revision=70779 --- reactos/drivers/filesystems/ntfs/dirctl.c | 10 ++++++++++ reactos/drivers/filesystems/ntfs/volinfo.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/reactos/drivers/filesystems/ntfs/dirctl.c b/reactos/drivers/filesystems/ntfs/dirctl.c index 53e70ba8f8f..86f8716de58 100644 --- a/reactos/drivers/filesystems/ntfs/dirctl.c +++ b/reactos/drivers/filesystems/ntfs/dirctl.c @@ -305,6 +305,12 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext) return STATUS_NOT_IMPLEMENTED; } + if (!ExAcquireResourceSharedLite(&Fcb->MainResource, + BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))) + { + return STATUS_PENDING; + } + if (SearchPattern != NULL) { if (!Ccb->DirectorySearchPattern) @@ -316,6 +322,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext) ExAllocatePoolWithTag(NonPagedPool, Pattern.MaximumLength, TAG_NTFS); if (!Ccb->DirectorySearchPattern) { + ExReleaseResourceLite(&Fcb->MainResource); return STATUS_INSUFFICIENT_RESOURCES; } @@ -329,6 +336,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext) Ccb->DirectorySearchPattern = ExAllocatePoolWithTag(NonPagedPool, 2 * sizeof(WCHAR), TAG_NTFS); if (!Ccb->DirectorySearchPattern) { + ExReleaseResourceLite(&Fcb->MainResource); return STATUS_INSUFFICIENT_RESOURCES; } @@ -461,6 +469,8 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext) Buffer0->NextEntryOffset = 0; } + ExReleaseResourceLite(&Fcb->MainResource); + if (FileIndex > 0) { Status = STATUS_SUCCESS; diff --git a/reactos/drivers/filesystems/ntfs/volinfo.c b/reactos/drivers/filesystems/ntfs/volinfo.c index 804aca32ddf..023e9af3828 100644 --- a/reactos/drivers/filesystems/ntfs/volinfo.c +++ b/reactos/drivers/filesystems/ntfs/volinfo.c @@ -246,6 +246,7 @@ NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext) NTSTATUS Status = STATUS_SUCCESS; PVOID SystemBuffer; ULONG BufferLength; + PDEVICE_EXTENSION DeviceExt; DPRINT("NtfsQueryVolumeInformation() called\n"); @@ -253,7 +254,15 @@ NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext) Irp = IrpContext->Irp; DeviceObject = IrpContext->DeviceObject; + DeviceExt = DeviceObject->DeviceExtension; Stack = IrpContext->Stack; + + if (!ExAcquireResourceSharedLite(&DeviceExt->DirResource, + BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))) + { + return NtfsMarkIrpContextForQueue(IrpContext); + } + FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass; BufferLength = Stack->Parameters.QueryVolume.Length; SystemBuffer = Irp->AssociatedIrp.SystemBuffer; @@ -292,6 +301,8 @@ NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext) Status = STATUS_NOT_SUPPORTED; } + ExReleaseResourceLite(&DeviceExt->DirResource); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = Stack->Parameters.QueryVolume.Length - BufferLength;