ReactOS  0.4.15-dev-1206-g731eddf
FsRtlMcb.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Kernel-Mode Test Suite FsRtl Test
5  * PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
6  */
7 
8 #include <kmt_test.h>
9 
10 #define NDEBUG
11 #include <debug.h>
12 
14 {
15 }
16 
18 {
19  ULONG i;
21 
22  trace("MCB %p:\n", Mcb);
23 
24  for (i = 0; FsRtlGetNextLargeMcbEntry(Mcb, i, &Vbn, &Lbn, &Count); i++)
25  {
26  // print out vbn, lbn, and count
27  trace("\t[%I64d,%I64d,%I64d]\n", Vbn, Lbn, Count);
28  }
29  trace("\n");
30 }
31 
33 {
34  LARGE_MCB LargeMcb;
35  ULONG NbRuns, Index;
36  LONGLONG Vbn, Lbn, SectorCount, StartingLbn, CountFromStartingLbn;
37 
39 
40  ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == FALSE, "expected FALSE, got TRUE\n");
41  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == FALSE, "expected FALSE, got TRUE\n");
42 
43  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
44  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
45  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
46  DumpAllRuns(&LargeMcb); // [0,-1,1][1,1,1024] [vbn,lbn,sc]
47  ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
48  ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
49  ok(Lbn == 1024, "Expected Lbn 1024, got: %I64d\n", Lbn);
50  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
51  ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
52  ok(Lbn == 1024, "Expected Lbn 1024, got: %I64d\n", Lbn);
53  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
54 
55  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 2048, 2, 1024) == TRUE, "expected TRUE, got FALSE\n");
56  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
57  ok(NbRuns == 4, "Expected 4 runs, got: %lu\n", NbRuns);
58  DumpAllRuns(&LargeMcb); // [0,-1,1][1,1,1024][1025,-1,1023][2048,2,1024] ======= [(0,1) hole] [(1,1025)=>(1,1025)] [(1025, 2048) hole] [(2048,3072)=>(2,1026)]
59  ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
60  ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
61  ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
62  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
63  ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
64  ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
65  ok(Index == 3, "Expected Index 3, got: %lu\n", Index);
66 
67  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
68  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
69  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
70  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
71 
72  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
73  ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn);
74  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
75  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
76 
77  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
78  ok(Vbn == 1025, "Expected Vbn 1025, got: %I64d\n", Vbn);
79  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
80  ok(SectorCount == 1023, "Expected SectorCount 1023, got: %I64d\n", SectorCount);
81 
82  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
83  ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
84  ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
85  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
86 
87  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == FALSE, "expected FALSE, got TRUE\n");
88 
89  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 1, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
90  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
91  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
92  ok(StartingLbn == 1, "Expected StartingLbn 1, got: %I64d\n", StartingLbn);
93  ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
94  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
95 
96  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 2048, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
97  ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
98  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
99  ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
100  ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
101  ok(Index == 3, "Expected Index 3, got: %lu\n", Index);
102 
103  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 3073, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == FALSE, "expected FALSE, got TRUE\n");
104 
105  FsRtlRemoveLargeMcbEntry(&LargeMcb, 1, 1024);
106  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
107  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
108  DumpAllRuns(&LargeMcb); // [0,-1,2048][2048,2,1024]
109  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 512, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
110  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
111  ok(SectorCount == 1536, "Expected SectorCount 1536, got: %I64d\n", SectorCount);
112  ok(StartingLbn == -1, "Expected StartingLbn -1, got: %I64d\n", StartingLbn);
113  ok(CountFromStartingLbn == 2048, "Expected CountFromStartingLbn 2048, got: %I64d\n", CountFromStartingLbn);
114  ok(Index == 0, "Expected Index 0, got: %lu\n", Index);
115  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
116  ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
117  ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
118  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
119 
120  ok(FsRtlSplitLargeMcb(&LargeMcb, 2048, 1024) == TRUE, "expected TRUE, got FALSE\n");
121  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
122  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
123  DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,1024]
124  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
125  ok(Vbn == 4095, "Expected Vbn 4095, got: %I64d\n", Vbn);
126  ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
127  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
128  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 2048, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
129  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
130  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
131  ok(StartingLbn == -1, "Expected StartingLbn -1, got: %I64d\n", StartingLbn);
132  ok(CountFromStartingLbn == 3072, "Expected CountFromStartingLbn 3072, got: %I64d\n", CountFromStartingLbn);
133  ok(Index == 0, "Expected Index 0, got: %lu\n", Index);
134  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 3072, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
135  ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
136  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
137  ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
138  ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
139  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
140 
141  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 3584, 3, 1024) == FALSE, "expected FALSE, got TRUE\n");
142 
143  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 4095, 1025, 1024) == TRUE, "expected TRUE, got FALSE\n");
144  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
145  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
146  DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,2047]
147  ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
148  ok(Vbn == 5118, "Expected Vbn 5118, got: %I64d\n", Vbn);
149  ok(Lbn == 2048, "Expected Lbn 2048, got: %I64d\n", Lbn);
150  ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
151  ok(Vbn == 5118, "Expected Vbn 5118, got: %I64d\n", Vbn);
152  ok(Lbn == 2048, "Expected Lbn 2048, got: %I64d\n", Lbn);
153  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
154 
155  FsRtlTruncateLargeMcb(&LargeMcb, 4607);
156  DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,1535]
157  ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 4095, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
158  ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
159  ok(SectorCount == 512, "Expected SectorCount 512, got: %I64d\n", SectorCount);
160  ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
161  ok(CountFromStartingLbn == 1535, "Expected CountFromStartingLbn 1535, got: %I64d\n", CountFromStartingLbn);
162  ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
163 
164  FsRtlUninitializeLargeMcb(&LargeMcb);
165 
167  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
168  ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns);
169 
170  /* Create a mapping with three holes between each mapping
171  * It looks like that:
172  * ----//////-----/////-----///////
173  */
174  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1024, 1025, 1024) == TRUE, "expected TRUE, got FALSE\n");
175  DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024]
176  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 3072, 3072, 1024) == TRUE, "expected TRUE, got FALSE\n");
177  DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024][2048,-1,1024][3072,3072,1024]
178  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 5120, 5120, 1024) == TRUE, "expected TRUE, got FALSE\n");
179  DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024][2048,-1,1024][3072,3072,1024][4096,-1,1024][5120,5120,1024]
180 
181  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
182  ok(NbRuns == 6, "Expected 6 runs, got: %lu\n", NbRuns);
183 
184  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
185  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
186  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
187  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
188 
189  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
190  ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
191  ok(Lbn == 1025, "Expected Lbn 1024, got: %I64d\n", Lbn);
192  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
193 
194  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
195  ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
196  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
197  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
198 
199  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
200  ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
201  ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
202  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
203 
204  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
205  ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
206  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
207  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
208 
209  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 5, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
210  ok(Vbn == 5120, "Expected Vbn 5120, got: %I64d\n", Vbn);
211  ok(Lbn == 5120, "Expected Lbn 5120, got: %I64d\n", Lbn);
212  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
213 
214  /* Fill first hole */
215  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
216  DumpAllRuns(&LargeMcb); // [0,1,2048][2048,-1,1024][3072,3072,1024][4096,-1,1024][5120,5120,1024]
217 
218  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
219  ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
220 
221  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
222  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
223  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
224  ok(SectorCount == 2048, "Expected SectorCount 2048, got: %I64d\n", SectorCount);
225 
226  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
227  ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
228  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
229  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
230 
231  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
232  ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
233  ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
234  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
235 
236  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
237  ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
238  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
239  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
240 
241  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
242  ok(Vbn == 5120, "Expected Vbn 5120, got: %I64d\n", Vbn);
243  ok(Lbn == 5120, "Expected Lbn 5120, got: %I64d\n", Lbn);
244  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
245 
246  /* Fill half of the last hole and overlap */
247  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 4608, 4608, 1024) == TRUE, "expected TRUE, got FALSE\n");
248  DumpAllRuns(&LargeMcb); // [0,1,2048][2048,-1,1024][3072,3072,1024][4096,-1,512][4608,4608,1536]
249 
250  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
251  ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
252 
253  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
254  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
255  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
256  ok(SectorCount == 2048, "Expected SectorCount 2048, got: %I64d\n", SectorCount);
257 
258  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
259  ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
260  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
261  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
262 
263  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
264  ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
265  ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
266  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
267 
268  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
269  ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
270  ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
271  ok(SectorCount == 512, "Expected SectorCount 512, got: %I64d\n", SectorCount);
272 
273  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
274  ok(Vbn == 4608, "Expected Vbn 4608, got: %I64d\n", Vbn);
275  ok(Lbn == 4608, "Expected Lbn 4608, got: %I64d\n", Lbn);
276  ok(SectorCount == 1536, "Expected SectorCount 1536, got: %I64d\n", SectorCount);
277 
278  FsRtlUninitializeLargeMcb(&LargeMcb);
279 
281  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
282  ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns);
283 
284  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
285  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
286  ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
287  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
288  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
289  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
290  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
291  DumpAllRuns(&LargeMcb);
292 
293  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 2, 1024) == FALSE, "expected FALSE, got TRUE\n");
294  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
295  ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
296  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
297  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
298  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
299  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
300  DumpAllRuns(&LargeMcb);
301 
302  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 0, 1024) == FALSE, "expected FALSE, got TRUE\n");
303  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
304  ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
305  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
306  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
307  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
308  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
309  DumpAllRuns(&LargeMcb);
310 
311  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 2, 1023) == TRUE, "expected TRUE, got FALSE\n");
312  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
313  ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
314  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
315  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
316  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
317  ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
318  DumpAllRuns(&LargeMcb);
319 
320  FsRtlUninitializeLargeMcb(&LargeMcb);
321 
323  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
324  ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns);
325 
326  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1) == TRUE, "expected TRUE, got FALSE\n");
327  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
328  ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
329  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
330  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
331  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
332  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
333  DumpAllRuns(&LargeMcb);
334 
335 
336  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 10, 1) == TRUE, "expected TRUE, got FALSE\n");
337  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
338  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
339  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
340  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
341  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
342  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
343  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
344  ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn);
345  ok(Lbn == 10, "Expected Lbn 10, got: %I64d\n", Lbn);
346  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
347  DumpAllRuns(&LargeMcb);
348 
349  ok(FsRtlAddLargeMcbEntry(&LargeMcb, 2, 20, 1) == TRUE, "expected TRUE, got FALSE\n");
350  NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
351  ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns);
352  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
353  ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
354  ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
355  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
356  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
357  ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn);
358  ok(Lbn == 10, "Expected Lbn 10, got: %I64d\n", Lbn);
359  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
360  ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
361  ok(Vbn == 2, "Expected Vbn 2, got: %I64d\n", Vbn);
362  ok(Lbn == 20, "Expected Lbn 20, got: %I64d\n", Lbn);
363  ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
364  DumpAllRuns(&LargeMcb);
365 
366  FsRtlUninitializeLargeMcb(&LargeMcb);
367 }
368 
370 {
371  LARGE_MCB FirstMcb, SecondMcb;
373  ULONG Index, NbRuns;
374  BOOLEAN Result;
375 
378 
379  FsRtlTruncateLargeMcb(&FirstMcb, 0);
381 
383  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
384 
385  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 1, 198657, 1);
386  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
387 
388  DumpAllRuns(&FirstMcb);
389 
390  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
391  ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
392 
394  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
395  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
396  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
397  ok(StartingLbn == 198657LL, "Expected StartingLbn 198657, got: %I64d\n", StartingLbn);
398  ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
399  ok(Index == 1, "Expected Index 1, got: %d\n", Index);
400 
402  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
403 
404  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 2, 199169, 11);
405  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
406 
407  DumpAllRuns(&FirstMcb);
408 
409  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
410  ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns);
411 
413  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
414  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
415  ok(SectorCountFromLbn == 11LL, "Expected SectorCountFromLbn 11, got: %I64d\n", SectorCountFromLbn);
416  ok(StartingLbn == 199169LL, "Expected StartingLbn 199169, got: %I64d\n", StartingLbn);
417  ok(SectorCountFromStartingLbn == 11LL, "Expected SectorCountFromStartingLbn 11, got: %I64d\n", SectorCountFromStartingLbn);
418  ok(Index == 2, "Expected Index 2, got: %d\n", Index);
419 
420  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
421  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
422  ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
423  ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
424  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
425 
426  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
427  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
428  ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
429  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
430  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
431 
432  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
433  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
434  ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
435  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
436  ok(SectorCount == 11LL, "Expected SectorCount 11, got: %I64d\n", SectorCount);
437 
438  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
439  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
440 
441  Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
442  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
443 
445  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
446  ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
447  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
448  ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
449  ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
450  ok(Index == 1, "Expected Index 1, got: %d\n", Index);
451 
453  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
454 
455  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 13, 199180, 4);
456  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
457 
458  DumpAllRuns(&FirstMcb);
459 
460  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
461  ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns);
462 
464  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
465  ok(Lbn == 199180LL, "Expected Lbn 199180, got: %I64d\n", Lbn);
466  ok(SectorCountFromLbn == 4LL, "Expected SectorCountFromLbn 4, got: %I64d\n", SectorCountFromLbn);
467  ok(StartingLbn == 199169LL, "Expected StartingLbn 199169, got: %I64d\n", StartingLbn);
468  ok(SectorCountFromStartingLbn == 15LL, "Expected SectorCountFromStartingLbn 15, got: %I64d\n", SectorCountFromStartingLbn);
469  ok(Index == 2, "Expected Index 2, got: %d\n", Index);
470 
471  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
472  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
473  ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
474  ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
475  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
476 
477  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
478  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
479  ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
480  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
481  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
482 
483  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
484  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
485  ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
486  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
487  ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
488 
489  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
490  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
491 
492  Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
493  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
494 
496  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
497  ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
498  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
499  ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
500  ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
501  ok(Index == 1, "Expected Index 1, got: %d\n", Index);
502 
504  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
505 
506  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 17, 1105, 16);
507  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
508 
509  DumpAllRuns(&FirstMcb);
510 
511  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
512  ok(NbRuns == 4, "Expected 4 runs, got: %lu\n", NbRuns);
513 
515  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
516  ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
517  ok(SectorCountFromLbn == 16LL, "Expected SectorCountFromLbn 16, got: %I64d\n", SectorCountFromLbn);
518  ok(StartingLbn == 1105LL, "Expected StartingLbn 1105, got: %I64d\n", StartingLbn);
519  ok(SectorCountFromStartingLbn == 16LL, "Expected SectorCountFromStartingLbn 16, got: %I64d\n", SectorCountFromStartingLbn);
520  ok(Index == 3, "Expected Index 3, got: %d\n", Index);
521 
522  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
523  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
524  ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
525  ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
526  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
527 
528  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
529  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
530  ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
531  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
532  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
533 
534  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
535  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
536  ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
537  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
538  ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
539 
540  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
541  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
542  ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
543  ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
544  ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
545 
546  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
547  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
548 
549  Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
550  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
551 
553  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
554  ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
555  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
556  ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
557  ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
558  ok(Index == 1, "Expected Index 1, got: %d\n", Index);
559 
561  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
562 
563  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 33, 1185, 32);
564  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
565 
566  DumpAllRuns(&FirstMcb);
567 
568  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
569  ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
570 
572  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
573  ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
574  ok(SectorCountFromLbn == 32LL, "Expected SectorCountFromLbn 32, got: %I64d\n", SectorCountFromLbn);
575  ok(StartingLbn == 1185LL, "Expected StartingLbn 1185, got: %I64d\n", StartingLbn);
576  ok(SectorCountFromStartingLbn == 32LL, "Expected SectorCountFromStartingLbn 32, got: %I64d\n", SectorCountFromStartingLbn);
577  ok(Index == 4, "Expected Index 4, got: %d\n", Index);
578 
579  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
580  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
581  ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
582  ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
583  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
584 
585  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
586  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
587  ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
588  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
589  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
590 
591  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
592  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
593  ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
594  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
595  ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
596 
597  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
598  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
599  ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
600  ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
601  ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
602 
603  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
604  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
605  ok(Vbn == 33LL, "Expected Vbn 33, got: %I64d\n", Vbn);
606  ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
607  ok(SectorCount == 32LL, "Expected SectorCount 32, got: %I64d\n", SectorCount);
608 
609  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 5, &Vbn, &Lbn, &SectorCount);
610  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
611 
612  Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
613  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
614 
616  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
617  ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
618  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
619  ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
620  ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
621  ok(Index == 1, "Expected Index 1, got: %d\n", Index);
622 
624  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
625 
626  Result = FsRtlAddLargeMcbEntry(&FirstMcb, 65, 1249, 44);
627  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
628 
629  DumpAllRuns(&FirstMcb);
630 
631  NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
632  ok(NbRuns == 6, "Expected 6 runs, got: %lu\n", NbRuns);
633 
635  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
636  ok(Lbn == 1249LL, "Expected Lbn 1249, got: %I64d\n", Lbn);
637  ok(SectorCountFromLbn == 44LL, "Expected SectorCountFromLbn 44, got: %I64d\n", SectorCountFromLbn);
638  ok(StartingLbn == 1249LL, "Expected StartingLbn 1249, got: %I64d\n", StartingLbn);
639  ok(SectorCountFromStartingLbn == 44LL, "Expected SectorCountFromStartingLbn 44, got: %I64d\n", SectorCountFromStartingLbn);
640  ok(Index == 5, "Expected Index 1, got: %d\n", Index);
641 
642  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
643  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
644  ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
645  ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
646  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
647 
648  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
649  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
650  ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
651  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
652  ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
653 
654  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
655  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
656  ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
657  ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
658  ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
659 
660  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
661  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
662  ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
663  ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
664  ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
665 
666  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
667  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
668  ok(Vbn == 33LL, "Expected Vbn 33, got: %I64d\n", Vbn);
669  ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
670  ok(SectorCount == 32LL, "Expected SectorCount 32, got: %I64d\n", SectorCount);
671 
672  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 5, &Vbn, &Lbn, &SectorCount);
673  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
674  ok(Vbn == 65LL, "Expected Vbn 65, got: %I64d\n", Vbn);
675  ok(Lbn == 1249LL, "Expected Lbn 1249, got: %I64d\n", Lbn);
676  ok(SectorCount == 44LL, "Expected SectorCount 44, got: %I64d\n", SectorCount);
677 
678  Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 6, &Vbn, &Lbn, &SectorCount);
679  ok(Result == FALSE, "Expected FALSE, got TRUE\n");
680 
682  ok(Result == TRUE, "Expected TRUE, got FALSE\n");
683  ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
684  ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 108, got: %I64d\n", SectorCountFromLbn);
685 
687  FsRtlUninitializeLargeMcb(&FirstMcb);
688 }
689 
691 {
692  LARGE_MCB FirstMcb;
694  ULONG Index;
695  BOOLEAN Result;
696 
698 
699  Lbn = -1;
700  SectorCount = -1;
701  Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 8388607LL, &Lbn, &SectorCount, NULL, NULL, NULL);
702  ok_bool_false(Result, "FsRtlLookupLargeMcbEntry returned");
703  ok_eq_longlong(Lbn, -1);
705 
706  Vbn = -1;
707  Lbn = -1;
708  Index = (ULONG) -1;
710  ok_bool_false(Result, "FsRtlLookupLastLargeMcbEntryAndIndex returned");
711  ok_eq_longlong(Vbn, -1);
712  ok_eq_longlong(Lbn, -1);
713  ok_eq_ulong(Index, (ULONG) -1);
714 
715  FsRtlUninitializeLargeMcb(&FirstMcb);
716 }
717 
718 START_TEST(FsRtlMcb)
719 {
720  FsRtlMcbTest();
724 }
#define ok_eq_ulong(value, expected)
static VOID FsRtlLargeMcbTest()
Definition: FsRtlMcb.c:32
#define LL
Definition: tui.h:84
#define ok_eq_longlong(value, expected)
Definition: kmt_test.h:242
#define TRUE
Definition: types.h:120
VOID NTAPI FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG SectorCount)
Definition: largemcb.c:862
IN PVCB IN OUT PLARGE_MCB IN PLARGE_MCB SecondMcb
Definition: fatprocs.h:373
_In_ LONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG SectorCountFromLbn
Definition: fsrtlfuncs.h:498
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:479
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:769
VOID NTAPI FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, IN LONGLONG Vbn)
Definition: largemcb.c:1016
static VOID FsRtlMcbTest()
Definition: FsRtlMcb.c:13
#define ok_bool_false(value, desc)
Definition: kmt_test.h:257
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:391
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType)
Definition: largemcb.c:450
static VOID FsRtlLargeMcbTestsExt2()
Definition: FsRtlMcb.c:369
unsigned char BOOLEAN
BOOLEAN NTAPI FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn)
Definition: largemcb.c:722
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
_In_ LONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG StartingLbn
Definition: fsrtlfuncs.h:498
int64_t LONGLONG
Definition: typedefs.h:68
#define trace
Definition: atltest.h:70
static VOID DumpAllRuns(PLARGE_MCB Mcb)
Definition: FsRtlMcb.c:17
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:282
ULONG SectorCount
Definition: part_xbox.c:31
BOOLEAN NTAPI FsRtlLookupLastLargeMcbEntryAndIndex(IN PLARGE_MCB OpaqueMcb, OUT PLONGLONG LargeVbn, OUT PLONGLONG LargeLbn, OUT PULONG Index)
Definition: largemcb.c:675
_In_ LONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG _Out_opt_ PLONGLONG SectorCountFromStartingLbn
Definition: fsrtlfuncs.h:498
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:564
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:343
#define ok(value,...)
Definition: atltest.h:57
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1053
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
unsigned int ULONG
Definition: retypes.h:1
static VOID FsRtlLargeMcbTestsFastFat()
Definition: FsRtlMcb.c:690
START_TEST(FsRtlMcb)
Definition: FsRtlMcb.c:718
BOOLEAN NTAPI FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Amount)
Definition: largemcb.c:979