[NTOSKRNL]
authorPierre Schweitzer <pierre@reactos.org>
Mon, 11 Apr 2016 20:29:35 +0000 (20:29 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 11 Apr 2016 20:29:35 +0000 (20:29 +0000)
In FsRtlAddBaseMcbEntry(), try to detect incompatible LBNs before altering mappings.

This fixes a few tests failures

CORE-11002

svn path=/trunk/; revision=71145

reactos/ntoskrnl/fsrtl/largemcb.c

index 9f2e840..070b24b 100644 (file)
@@ -135,10 +135,12 @@ FsRtlAddBaseMcbEntry(IN PBASE_MCB OpaqueMcb,
                      IN LONGLONG SectorCount)
 {
     BOOLEAN Result = TRUE;
+    BOOLEAN IntResult;
     PBASE_MCB_INTERNAL Mcb = (PBASE_MCB_INTERNAL)OpaqueMcb;
     LARGE_MCB_MAPPING_ENTRY Node, NeedleRun;
     PLARGE_MCB_MAPPING_ENTRY LowerRun, HigherRun;
     BOOLEAN NewElement;
+    LONGLONG IntLbn;
 
     DPRINT("FsRtlAddBaseMcbEntry(%p, %I64d, %I64d, %I64d)\n", OpaqueMcb, Vbn, Lbn, SectorCount);
 
@@ -154,6 +156,16 @@ FsRtlAddBaseMcbEntry(IN PBASE_MCB OpaqueMcb,
         goto quit;
     }
 
+    IntResult = FsRtlLookupBaseMcbEntry(OpaqueMcb, Vbn, &IntLbn, NULL, NULL, NULL, NULL);
+    if (IntResult)
+    {
+        if (IntLbn != -1 && IntLbn != Lbn)
+        {
+            Result = FALSE;
+            goto quit;
+        }
+    }
+
     /* clean any possible previous entries in our range */
     FsRtlRemoveBaseMcbEntry(OpaqueMcb, Vbn, SectorCount);