2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fsrtl/largemcb.c
5 * PURPOSE: Mapping Control Block (MCB) support for File System Drivers
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
15 /* PUBLIC FUNCTIONS **********************************************************/
22 FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb
,
25 IN LONGLONG SectorCount
)
27 KeBugCheck(FILE_SYSTEM
);
36 FsRtlAddMcbEntry(IN PMCB Mcb
,
41 /* Call the newer function */
42 return FsRtlAddLargeMcbEntry(&Mcb
->
43 DummyFieldThatSizesThisStructureCorrectly
,
46 (LONGLONG
)SectorCount
);
54 FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb
,
58 OUT PLONGLONG SectorCount
)
60 KeBugCheck(FILE_SYSTEM
);
72 FsRtlGetNextMcbEntry(IN PMCB Mcb
,
76 OUT PULONG SectorCount
)
78 BOOLEAN Return
= FALSE
;
81 LONGLONG llSectorCount
;
83 /* Call the Large version */
84 Return
= FsRtlGetNextLargeMcbEntry(
85 &Mcb
->DummyFieldThatSizesThisStructureCorrectly
,
91 /* Return the lower 32 bits */
94 *SectorCount
= (ULONG
)llSectorCount
;
96 /* And return the original value */
105 FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb
,
106 IN POOL_TYPE PoolType
)
108 KeBugCheck(FILE_SYSTEM
);
116 FsRtlInitializeMcb(IN PMCB Mcb
,
117 IN POOL_TYPE PoolType
)
119 /* Call the newer function */
120 FsRtlInitializeLargeMcb(&Mcb
->DummyFieldThatSizesThisStructureCorrectly
,
129 FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb
,
131 OUT PLONGLONG Lbn OPTIONAL
,
132 OUT PLONGLONG SectorCountFromLbn OPTIONAL
,
133 OUT PLONGLONG StartingLbn OPTIONAL
,
134 OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL
,
135 OUT PULONG Index OPTIONAL
)
137 KeBugCheck(FILE_SYSTEM
);
139 *SectorCountFromLbn
= 0;
148 FsRtlLookupLastLargeMcbEntryAndIndex(IN PLARGE_MCB OpaqueMcb
,
149 OUT PLONGLONG LargeVbn
,
150 OUT PLONGLONG LargeLbn
,
153 KeBugCheck(FILE_SYSTEM
);
165 FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb
,
169 KeBugCheck(FILE_SYSTEM
);
178 FsRtlLookupLastMcbEntry(IN PMCB Mcb
,
182 BOOLEAN Return
= FALSE
;
186 /* Call the Large version */
187 Return
= FsRtlLookupLastLargeMcbEntry(
188 &Mcb
->DummyFieldThatSizesThisStructureCorrectly
,
192 /* Return the lower 32-bits */
196 /* And return the original value */
205 FsRtlLookupMcbEntry(IN PMCB Mcb
,
208 OUT PULONG SectorCount OPTIONAL
,
211 BOOLEAN Return
= FALSE
;
213 LONGLONG llSectorCount
;
215 /* Call the Large version */
216 Return
= FsRtlLookupLargeMcbEntry(&Mcb
->
217 DummyFieldThatSizesThisStructureCorrectly
,
225 /* Return the lower 32-bits */
227 if (SectorCount
) *SectorCount
= (ULONG
)llSectorCount
;
229 /* And return the original value */
238 FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb
)
242 /* Read the number of runs while holding the MCB lock */
243 KeAcquireGuardedMutex(Mcb
->GuardedMutex
);
244 NumberOfRuns
= Mcb
->BaseMcb
.PairCount
;
245 KeReleaseGuardedMutex(Mcb
->GuardedMutex
);
247 /* Return the count */
256 FsRtlNumberOfRunsInMcb (IN PMCB Mcb
)
258 /* Call the newer function */
259 return FsRtlNumberOfRunsInLargeMcb(
260 &Mcb
->DummyFieldThatSizesThisStructureCorrectly
);
268 FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb
,
270 IN LONGLONG SectorCount
)
272 KeBugCheck(FILE_SYSTEM
);
280 FsRtlRemoveMcbEntry(IN PMCB Mcb
,
282 IN ULONG SectorCount
)
284 /* Call the large function */
285 FsRtlRemoveLargeMcbEntry(&Mcb
->DummyFieldThatSizesThisStructureCorrectly
,
287 (LONGLONG
)SectorCount
);
295 FsRtlResetLargeMcb(IN PLARGE_MCB Mcb
,
296 IN BOOLEAN SelfSynchronized
)
298 KeBugCheck(FILE_SYSTEM
);
306 FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb
,
310 KeBugCheck(FILE_SYSTEM
);
319 FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb
,
322 KeBugCheck(FILE_SYSTEM
);
330 FsRtlTruncateMcb (IN PMCB Mcb
,
333 /* Call the newer function */
334 FsRtlTruncateLargeMcb(&Mcb
->DummyFieldThatSizesThisStructureCorrectly
,
343 FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb
)
345 KeBugCheck(FILE_SYSTEM
);
353 FsRtlUninitializeMcb(IN PMCB Mcb
)
355 /* Call the newer function */
356 FsRtlUninitializeLargeMcb(&Mcb
->DummyFieldThatSizesThisStructureCorrectly
);