[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Tue, 23 Feb 2016 22:19:38 +0000 (22:19 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 23 Feb 2016 22:19:38 +0000 (22:19 +0000)
Even more locking

svn path=/trunk/; revision=70779

reactos/drivers/filesystems/ntfs/dirctl.c
reactos/drivers/filesystems/ntfs/volinfo.c

index 53e70ba..86f8716 100644 (file)
@@ -305,6 +305,12 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
         return STATUS_NOT_IMPLEMENTED;
     }
 
         return STATUS_NOT_IMPLEMENTED;
     }
 
+    if (!ExAcquireResourceSharedLite(&Fcb->MainResource,
+                                     BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
+    {
+        return STATUS_PENDING;
+    }
+
     if (SearchPattern != NULL)
     {
         if (!Ccb->DirectorySearchPattern)
     if (SearchPattern != NULL)
     {
         if (!Ccb->DirectorySearchPattern)
@@ -316,6 +322,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
                 ExAllocatePoolWithTag(NonPagedPool, Pattern.MaximumLength, TAG_NTFS);
             if (!Ccb->DirectorySearchPattern)
             {
                 ExAllocatePoolWithTag(NonPagedPool, Pattern.MaximumLength, TAG_NTFS);
             if (!Ccb->DirectorySearchPattern)
             {
+                ExReleaseResourceLite(&Fcb->MainResource);
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
                 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)
         {
         Ccb->DirectorySearchPattern = ExAllocatePoolWithTag(NonPagedPool, 2 * sizeof(WCHAR), TAG_NTFS);
         if (!Ccb->DirectorySearchPattern)
         {
+            ExReleaseResourceLite(&Fcb->MainResource);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
@@ -461,6 +469,8 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
         Buffer0->NextEntryOffset = 0;
     }
 
         Buffer0->NextEntryOffset = 0;
     }
 
+    ExReleaseResourceLite(&Fcb->MainResource);
+
     if (FileIndex > 0)
     {
         Status = STATUS_SUCCESS;
     if (FileIndex > 0)
     {
         Status = STATUS_SUCCESS;
index 804aca3..023e9af 100644 (file)
@@ -246,6 +246,7 @@ NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext)
     NTSTATUS Status = STATUS_SUCCESS;
     PVOID SystemBuffer;
     ULONG BufferLength;
     NTSTATUS Status = STATUS_SUCCESS;
     PVOID SystemBuffer;
     ULONG BufferLength;
+    PDEVICE_EXTENSION DeviceExt;
 
     DPRINT("NtfsQueryVolumeInformation() called\n");
 
 
     DPRINT("NtfsQueryVolumeInformation() called\n");
 
@@ -253,7 +254,15 @@ NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext)
 
     Irp = IrpContext->Irp;
     DeviceObject = IrpContext->DeviceObject;
 
     Irp = IrpContext->Irp;
     DeviceObject = IrpContext->DeviceObject;
+    DeviceExt = DeviceObject->DeviceExtension;
     Stack = IrpContext->Stack;
     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;
     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;
     }
 
             Status = STATUS_NOT_SUPPORTED;
     }
 
+    ExReleaseResourceLite(&DeviceExt->DirResource);
+
     if (NT_SUCCESS(Status))
         Irp->IoStatus.Information =
             Stack->Parameters.QueryVolume.Length - BufferLength;
     if (NT_SUCCESS(Status))
         Irp->IoStatus.Information =
             Stack->Parameters.QueryVolume.Length - BufferLength;