1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
|
/*
* COPYRIGHT: See COPYRIGHT.TXT
* PROJECT: Ext2 File System Driver for WinNT/2K/XP
* FILE: Ext2fs.h
* PURPOSE: Header file: ext2 structures
* PROGRAMMER: Matt Wu <mattwu@163.com>
* HOMEPAGE: http://ext2.yeah.net
* UPDATE HISTORY:
*/
#ifndef _EXT2_HEADER_
#define _EXT2_HEADER_
/* INCLUDES *************************************************************/
#include <linux/module.h>
#include <ntdddisk.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <linux/ext2_fs.h>
#include <linux/ext3_fs.h>
#include <linux/ext3_fs_i.h>
#include <linux/ext4.h>
/* DEBUG ****************************************************************/
#if DBG
# define EXT2_DEBUG 1
#else
# define EXT2_DEBUG 0
#endif
#if EXT2_DEBUG
#if _X86_
#define DbgBreak() __asm int 3
#else
#define DbgBreak() KdBreakPoint()
#endif
#else
#define DbgBreak()
#endif
/* STRUCTS & CONSTS******************************************************/
#define EXT2FSD_VERSION "0.62"
//
// Ext2Fsd build options
//
// To support driver dynamics unload
#define EXT2_UNLOAD FALSE
// To support inode size expansion (fallocate)
#define EXT2_PRE_ALLOCATION_SUPPORT TRUE
//
// Constants
//
#define EXT2_MAX_NESTED_LINKS (8)
#define EXT2_LINKLEN_IN_INODE (60)
#define EXT2_BLOCK_TYPES (0x04)
#define MAXIMUM_RECORD_LENGTH (0x10000)
#define SECTOR_BITS (Vcb->SectorBits)
#define SECTOR_SIZE (Vcb->DiskGeometry.BytesPerSector)
#define DEFAULT_SECTOR_SIZE (0x200)
#define SUPER_BLOCK_OFFSET (0x400)
#define SUPER_BLOCK_SIZE (0x400)
#define READ_AHEAD_GRANULARITY (0x10000)
#define SUPER_BLOCK (Vcb->SuperBlock)
#define INODE_SIZE (Vcb->InodeSize)
#define BLOCK_SIZE (Vcb->BlockSize)
#define BLOCK_BITS (SUPER_BLOCK->s_log_block_size + 10)
#define GROUP_DESC_SIZE (Vcb->sbi.s_desc_size)
#define INODES_COUNT (Vcb->SuperBlock->s_inodes_count)
#define INODES_PER_GROUP (SUPER_BLOCK->s_inodes_per_group)
#define BLOCKS_PER_GROUP (SUPER_BLOCK->s_blocks_per_group)
#define TOTAL_BLOCKS (ext3_blocks_count(SUPER_BLOCK))
#define EXT2_FIRST_DATA_BLOCK (SUPER_BLOCK->s_first_data_block)
typedef struct ext3_super_block EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
typedef struct ext3_inode EXT2_INODE, *PEXT2_INODE;
typedef struct ext4_group_desc EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
typedef struct ext3_dir_entry EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY2, *PEXT2_DIR_ENTRY2;
#define CEILING_ALIGNED(T, A, B) (((A) + (B) - 1) & (~((T)(B) - 1)))
#define COCKLOFT_ALIGNED(T, A, B) (((A) + (B)) & (~((T)(B) - 1)))
/* File System Releated *************************************************/
#define DRIVER_NAME "Ext2Fsd"
#define DEVICE_NAME L"\\Ext2Fsd"
#define CDROM_NAME L"\\Ext2CdFsd"
// Registry
#define PARAMETERS_KEY L"\\Parameters"
#define VOLUMES_KEY L"\\Volumes"
#define READING_ONLY L"Readonly"
#define WRITING_SUPPORT L"WritingSupport"
#define CHECKING_BITMAP L"CheckingBitmap"
#define EXT3_FORCEWRITING L"Ext3ForceWriting"
#define CODEPAGE_NAME L"CodePage"
#define HIDING_PREFIX L"HidingPrefix"
#define HIDING_SUFFIX L"HidingSuffix"
#define AUTO_MOUNT L"AutoMount"
#define MOUNT_POINT L"MountPoint"
#define DOS_DEVICE_NAME L"\\DosDevices\\Ext2Fsd"
// To support ext2fsd unload routine
#if EXT2_UNLOAD
//
// Private IOCTL to make the driver ready to unload
//
#define IOCTL_PREPARE_TO_UNLOAD \
CTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_NEITHER, FILE_WRITE_ACCESS)
#endif // EXT2_UNLOAD
#include "common.h"
#ifndef _GNU_NTIFS_
typedef IO_STACK_LOCATION EXTENDED_IO_STACK_LOCATION, *PEXTENDED_IO_STACK_LOCATION;
#endif
#define IsFlagOn(a,b) ((BOOLEAN)(FlagOn(a,b) == b))
#ifndef FlagOn
#define FlagOn(_F,_SF) ((_F) & (_SF))
#endif
#ifndef BooleanFlagOn
#define BooleanFlagOn(F,SF) ((BOOLEAN)(((F) & (SF)) != 0))
#endif
#ifndef SetFlag
#define SetFlag(_F,_SF) ((_F) |= (_SF))
#endif
#ifndef ClearFlag
#define ClearFlag(_F,_SF) ((_F) &= ~(_SF))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifdef _WIN2K_TARGET_
#define InterlockedOr _InterlockedOr
LONG
_InterlockedAnd (
IN OUT LONG volatile *Target,
IN LONG Set
);
#pragma intrinsic (_InterlockedAnd)
#define InterlockedAnd _InterlockedAnd
LONG
_InterlockedXor (
IN OUT LONG volatile *Target,
IN LONG Set
);
#pragma intrinsic (_InterlockedXor)
#define InterlockedXor _InterlockedXor
#endif /* only for win2k */
#if EXT2_DEBUG
#define SetLongFlag(_F,_SF) Ext2SetFlag(&(_F), (ULONG)(_SF))
#define ClearLongFlag(_F,_SF) Ext2ClearFlag(&(_F), (ULONG)(_SF))
__inline
VOID
Ext2SetFlag(PULONG Flags, ULONG FlagBit)
{
ULONG _ret = InterlockedOr(Flags, FlagBit);
ASSERT(*Flags == (_ret | FlagBit));
}
__inline
VOID
Ext2ClearFlag(PULONG Flags, ULONG FlagBit)
{
ULONG _ret = InterlockedAnd(Flags, ~FlagBit);
ASSERT(*Flags == (_ret & (~FlagBit)));
}
#else
#define SetLongFlag(_F,_SF) InterlockedOr(&(_F), (ULONG)(_SF))
#define ClearLongFlag(_F,_SF) InterlockedAnd(&(_F), ~((ULONG)(_SF)))
#endif /* release */
#define Ext2RaiseStatus(IRPCONTEXT,STATUS) { \
(IRPCONTEXT)->ExceptionCode = (STATUS); \
ExRaiseStatus((STATUS)); \
}
#define Ext2NormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
(IRPCONTEXT)->ExceptionCode = STATUS; \
if ((STATUS) == STATUS_VERIFY_REQUIRED) { ExRaiseStatus((STATUS)); } \
ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
}
//
// Define IsWritingToEof for write (append) operations
//
#define FILE_WRITE_TO_END_OF_FILE 0xffffffff
#define IsWritingToEof(Pos) (((Pos).LowPart == FILE_WRITE_TO_END_OF_FILE) && \
((Pos).HighPart == -1 ))
#define IsDirectory(Fcb) IsMcbDirectory((Fcb)->Mcb)
#define IsSpecialFile(Fcb) IsMcbSpecialFile((Fcb)->Mcb)
#define IsSymLink(Fcb) IsMcbSymLink((Fcb)->Mcb)
#define IsInodeSymLink(I) S_ISLNK((I)->i_mode)
#define IsRoot(Fcb) IsMcbRoot((Fcb)->Mcb)
//
// Pool Tags
//
#define TAG_VPB ' bpV'
#define VPB_SIZE sizeof(VPB)
#define EXT2_DATA_MAGIC 'BD2E'
#define EXT2_INAME_MAGIC 'NI2E'
#define EXT2_FNAME_MAGIC 'NF2E'
#define EXT2_VNAME_MAGIC 'NV2E'
#define EXT2_DENTRY_MAGIC 'ED2E'
#define EXT2_DIRSP_MAGIC 'SD2E'
#define EXT2_SB_MAGIC 'BS2E'
#define EXT2_GD_MAGIC 'DG2E'
#define EXT2_FLIST_MAGIC 'LF2E'
#define EXT2_PARAM_MAGIC 'PP2E'
#define EXT2_RWC_MAGIC 'WR2E'
//
// Bug Check Codes Definitions
//
#define EXT2_FILE_SYSTEM (FILE_SYSTEM)
#define EXT2_BUGCHK_BLOCK (0x00010000)
#define EXT2_BUGCHK_CLEANUP (0x00020000)
#define EXT2_BUGCHK_CLOSE (0x00030000)
#define EXT2_BUGCHK_CMCB (0x00040000)
#define EXT2_BUGCHK_CREATE (0x00050000)
#define EXT2_BUGCHK_DEBUG (0x00060000)
#define EXT2_BUGCHK_DEVCTL (0x00070000)
#define EXT2_BUGCHK_DIRCTL (0x00080000)
#define EXT2_BUGCHK_DISPATCH (0x00090000)
#define EXT2_BUGCHK_EXCEPT (0x000A0000)
#define EXT2_BUGCHK_EXT2 (0x000B0000)
#define EXT2_BUGCHK_FASTIO (0x000C0000)
#define EXT2_BUGCHK_FILEINFO (0x000D0000)
#define EXT2_BUGCHK_FLUSH (0x000E0000)
#define EXT2_BUGCHK_FSCTL (0x000F0000)
#define EXT2_BUGCHK_INIT (0x00100000)
#define EXT2_BUGCHK_LOCK (0x0011000)
#define EXT2_BUGCHK_MEMORY (0x0012000)
#define EXT2_BUGCHK_MISC (0x0013000)
#define EXT2_BUGCHK_READ (0x00140000)
#define EXT2_BUGCHK_SHUTDOWN (0x00150000)
#define EXT2_BUGCHK_VOLINFO (0x00160000)
#define EXT2_BUGCHK_WRITE (0x00170000)
#define EXT2_BUGCHK_LAST (0x00170000)
#define Ext2BugCheck(A,B,C,D) { KeBugCheckEx(EXT2_FILE_SYSTEM, A | __LINE__, B, C, D ); }
/* Ext2 file system definions *******************************************/
//
// The second extended file system magic number
//
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT2_MIN_BLOCK 1024
#define EXT2_MIN_FRAG 1024
#define EXT2_MAX_USER_BLKSIZE 65536
//
// Inode flags (Linux uses octad number, but why ? strange!!!)
//
#define S_IFMT 0x0F000 /* 017 0000 */
#define S_IFSOCK 0x0C000 /* 014 0000 */
#define S_IFLNK 0x0A000 /* 012 0000 */
#define S_IFREG 0x08000 /* 010 0000 */
#define S_IFBLK 0x06000 /* 006 0000 */
#define S_IFDIR 0x04000 /* 004 0000 */
#define S_IFCHR 0x02000 /* 002 0000 */
#define S_IFIFO 0x01000 /* 001 0000 */
#define S_ISUID 0x00800 /* 000 4000 */
#define S_ISGID 0x00400 /* 000 2000 */
#define S_ISVTX 0x00200 /* 000 1000 */
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISFIL(m) (((m) & S_IFMT) == S_IFFIL)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_IPERMISSION_MASK 0x1FF /* */
#define S_IRWXU 0x1C0 /* 0 0700 */
#define S_IRWNU 0x180 /* 0 0600 */
#define S_IRUSR 0x100 /* 0 0400 */
#define S_IWUSR 0x080 /* 0 0200 */
#define S_IXUSR 0x040 /* 0 0100 */
#define S_IRWXG 0x038 /* 0 0070 */
#define S_IRWNG 0x030 /* 0 0060 */
#define S_IRGRP 0x020 /* 0 0040 */
#define S_IWGRP 0x010 /* 0 0020 */
#define S_IXGRP 0x008 /* 0 0010 */
#define S_IRWXO 0x007 /* 0 0007 */
#define S_IRWNO 0x006 /* 0 0006 */
#define S_IROTH 0x004 /* 0 0004 */
#define S_IWOTH 0x002 /* 0 0002 */
#define S_IXOTH 0x001 /* 0 0001 */
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
#define S_IFATTR (S_IRWNU|S_IRWNG|S_IRWNO)
#define S_ISREADABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IRUSR | S_IRGRP | S_IROTH))
#define S_ISWRITABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IWUSR | S_IWGRP | S_IWOTH))
#define Ext2SetReadable(m) do {(m) = (m) | (S_IRUSR | S_IRGRP | S_IROTH);} while(0)
#define Ext2SetWritable(m) do {(m) = (m) | (S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
#define Ext2SetOwnerWritable(m) do {(m) |= S_IWUSR;} while(0)
#define Ext2SetOwnerReadOnly(m) do {(m) &= ~S_IWUSR;} while(0)
#define Ext2IsOwnerWritable(m) (((m) & S_IWUSR) == S_IWUSR)
#define Ext2IsOwnerReadOnly(m) (!(Ext2IsOwnerWritable(m)))
#define Ext2SetReadOnly(m) do {(m) &= ~(S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
/*
* We need 8-bytes aligned for all the sturctures
* It's a must for all ERESOURCE allocations
*/
//
// Ext2Fsd Driver Definitions
//
//
// EXT2_IDENTIFIER_TYPE
//
// Identifiers used to mark the structures
//
typedef enum _EXT2_IDENTIFIER_TYPE {
#ifdef _MSC_VER
EXT2FGD = ':DGF',
EXT2VCB = ':BCV',
EXT2FCB = ':BCF',
EXT2CCB = ':BCC',
EXT2ICX = ':XCI',
EXT2FSD = ':DSF',
EXT2MCB = ':BCM'
#else
EXT2FGD = 0xE2FD0001,
EXT2VCB = 0xE2FD0002,
EXT2FCB = 0xE2FD0003,
EXT2CCB = 0xE2FD0004,
EXT2ICX = 0xE2FD0005,
EXT2FSD = 0xE2FD0006,
EXT2MCB = 0xE2FD0007
#endif
} EXT2_IDENTIFIER_TYPE;
//
// EXT2_IDENTIFIER
//
// Header used to mark the structures
//
typedef struct _EXT2_IDENTIFIER {
EXT2_IDENTIFIER_TYPE Type;
ULONG Size;
} EXT2_IDENTIFIER, *PEXT2_IDENTIFIER;
#define NodeType(Ptr) (*((EXT2_IDENTIFIER_TYPE *)(Ptr)))
typedef struct _EXT2_MCB EXT2_MCB, *PEXT2_MCB;
typedef PVOID PBCB;
//
//
// EXT2_GLOBAL_DATA
//
// Data that is not specific to a mounted volume
//
typedef struct _EXT2_GLOBAL {
/* Identifier for this structure */
EXT2_IDENTIFIER Identifier;
/* Syncronization primitive for this structure */
ERESOURCE Resource;
/* Global flags for the driver: I put it since
FastIoDispatch isn't 8bytes aligned. */
ULONG Flags;
/* Table of pointers to the fast I/O entry points */
FAST_IO_DISPATCH FastIoDispatch;
/* Table of pointers to the Cache Manager callbacks */
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
/* Pointer to the driver object */
PDRIVER_OBJECT DriverObject;
/* Pointer to the disk device object */
PDEVICE_OBJECT DiskdevObject;
/* Pointer to the cdrom device object */
PDEVICE_OBJECT CdromdevObject;
/* List of mounted volumes */
LIST_ENTRY VcbList;
/* Cleaning thread related: resource cleaner */
struct {
KEVENT Engine;
KEVENT Wait;
} Reaper;
/* Look Aside table of IRP_CONTEXT, FCB, MCB, CCB */
NPAGED_LOOKASIDE_LIST Ext2IrpContextLookasideList;
NPAGED_LOOKASIDE_LIST Ext2FcbLookasideList;
NPAGED_LOOKASIDE_LIST Ext2CcbLookasideList;
NPAGED_LOOKASIDE_LIST Ext2McbLookasideList;
NPAGED_LOOKASIDE_LIST Ext2ExtLookasideList;
NPAGED_LOOKASIDE_LIST Ext2DentryLookasideList;
USHORT MaxDepth;
/* User specified global codepage name */
struct {
UCHAR AnsiName[CODEPAGE_MAXLEN];
struct nls_table * PageTable;
} Codepage;
/* global hiding patterns */
BOOLEAN bHidingPrefix;
CHAR sHidingPrefix[HIDINGPAT_LEN];
BOOLEAN bHidingSuffix;
CHAR sHidingSuffix[HIDINGPAT_LEN];
/* Registery path */
UNICODE_STRING RegistryPath;
/* global memory and i/o statistics and memory allocations
of various sturctures */
EXT2_PERF_STATISTICS_V2 PerfStat;
} EXT2_GLOBAL, *PEXT2_GLOBAL;
//
// Flags for EXT2_GLOBAL_DATA
//
#define EXT2_UNLOAD_PENDING 0x00000001
#define EXT2_SUPPORT_WRITING 0x00000002
#define EXT3_FORCE_WRITING 0x00000004
#define EXT2_CHECKING_BITMAP 0x00000008
#define EXT2_AUTO_MOUNT 0x00000010
//
// Glboal Ext2Fsd Memory Block
//
extern PEXT2_GLOBAL Ext2Global;
//
// memory allocation statistics
//
#define INC_MEM_COUNT(_i, _p, _s) do { ASSERT(_p); Ext2TraceMemory(TRUE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
#define DEC_MEM_COUNT(_i, _p, _s) do { ASSERT(_p); Ext2TraceMemory(FALSE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
#define INC_IRP_COUNT(IrpContext) Ext2TraceIrpContext(TRUE, (IrpContext))
#define DEC_IRP_COUNT(IrpContext) Ext2TraceIrpContext(FALSE, (IrpContext))
//
// Driver Extension define
//
#define IsExt2FsDevice(DO) ((DO == Ext2Global->DiskdevObject) || \
(DO == Ext2Global->CdromdevObject) )
#ifdef _WIN2K_TARGET_
#define FSRTL_ADVANCED_FCB_HEADER FSRTL_COMMON_FCB_HEADER
#endif
typedef struct _EXT2_FCBVCB {
// Command header for Vcb and Fcb
FSRTL_ADVANCED_FCB_HEADER Header;
#ifndef _WIN2K_TARGET_
FAST_MUTEX Mutex;
#endif
// Ext2Fsd identifier
EXT2_IDENTIFIER Identifier;
// Locking resources
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
} EXT2_FCBVCB, *PEXT2_FCBVCB;
//
// EXT2_VCB Volume Control Block
//
// Data that represents a mounted logical volume
// It is allocated as the device extension of the volume device object
//
typedef struct _EXT2_VCB {
/* Common header */
EXT2_FCBVCB;
// Resource for metadata (super block, tables)
ERESOURCE MetaLock;
// Resource for Mcb (Meta data control block)
ERESOURCE McbLock;
// Entry of Mcb Tree (Root Node)
PEXT2_MCB McbTree;
// Mcb list
LIST_ENTRY McbList;
ULONG NumOfMcb;
// Link list to Global
LIST_ENTRY Next;
// Section objects
SECTION_OBJECT_POINTERS SectionObject;
// Dirty Mcbs of modifications for volume stream
LARGE_MCB Extents;
// List of FCBs for open files on this volume
ULONG FcbCount;
LIST_ENTRY FcbList;
KSPIN_LOCK FcbLock;
// Share Access for the file object
SHARE_ACCESS ShareAccess;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
// for both files on this volume and open instances of the
// volume itself.
ULONG ReferenceCount; /* total ref count */
ULONG OpenHandleCount; /* all handles */
ULONG OpenVolumeCount; /* volume handle */
// Disk change count
ULONG ChangeCount;
// Pointer to the VPB in the target device object
PVPB Vpb;
PVPB Vpb2;
// The FileObject of Volume used to lock the volume
PFILE_OBJECT LockFile;
// List of IRPs pending on directory change notify requests
LIST_ENTRY NotifyList;
// Pointer to syncronization primitive for this list
PNOTIFY_SYNC NotifySync;
// This volumes device object
PDEVICE_OBJECT DeviceObject;
// The physical device object (the disk)
PDEVICE_OBJECT TargetDeviceObject;
// The physical device object (the disk)
PDEVICE_OBJECT RealDevice;
// Information about the physical device object
DISK_GEOMETRY DiskGeometry;
PARTITION_INFORMATION PartitionInformation;
BOOLEAN IsExt3fs;
PEXT2_SUPER_BLOCK SuperBlock;
/*
// Bitmap Block per group
PRTL_BITMAP BlockBitMaps;
PRTL_BITMAP InodeBitMaps;
*/
// Block / Cluster size
ULONG BlockSize;
// Sector size in bits
ULONG SectorBits;
// Aligned size (Page or Block)
ULONGLONG IoUnitSize;
// Bits of aligned size
ULONG IoUnitBits;
// Inode size
ULONG InodeSize;
// Inode lookaside list
NPAGED_LOOKASIDE_LIST InodeLookasideList;
// Flags for the volume
ULONG Flags;
// Streaming File Object
PFILE_OBJECT Volume;
// User specified codepage name per volume
struct {
UCHAR AnsiName[CODEPAGE_MAXLEN];
struct nls_table * PageTable;
} Codepage;
/* patterns to hiding files */
BOOLEAN bHidingPrefix;
CHAR sHidingPrefix[HIDINGPAT_LEN];
BOOLEAN bHidingSuffix;
CHAR sHidingSuffix[HIDINGPAT_LEN];
/* mountpoint: symlink to DesDevices */
UCHAR DrvLetter;
struct block_device bd;
struct super_block sb;
struct ext3_sb_info sbi;
/* Maximum file size in blocks ... */
ULONG max_blocks_per_layer[EXT2_BLOCK_TYPES];
ULONG max_data_blocks;
loff_t max_bitmap_bytes;
loff_t max_bytes;
} EXT2_VCB, *PEXT2_VCB;
//
// Flags for EXT2_VCB
//
#define VCB_INITIALIZED 0x00000001
#define VCB_VOLUME_LOCKED 0x00000002
#define VCB_MOUNTED 0x00000004
#define VCB_DISMOUNT_PENDING 0x00000008
#define VCB_NEW_VPB 0x00000010
#define VCB_BEING_CLOSED 0x00000020
#define VCB_FORCE_WRITING 0x00004000
#define VCB_DEVICE_REMOVED 0x00008000
#define VCB_JOURNAL_RECOVER 0x00080000
#define VCB_ARRIVAL_NOTIFIED 0x00800000
#define VCB_READ_ONLY 0x08000000
#define VCB_WRITE_PROTECTED 0x10000000
#define VCB_FLOPPY_DISK 0x20000000
#define VCB_REMOVAL_PREVENTED 0x40000000
#define VCB_REMOVABLE_MEDIA 0x80000000
#define IsVcbInited(Vcb) (IsFlagOn((Vcb)->Flags, VCB_INITIALIZED))
#define IsMounted(Vcb) (IsFlagOn((Vcb)->Flags, VCB_MOUNTED))
#define IsDispending(Vcb) (IsFlagOn((Vcb)->Flags, VCB_DISMOUNT_PENDING))
#define IsVcbReadOnly(Vcb) (IsFlagOn((Vcb)->Flags, VCB_READ_ONLY) || \
IsFlagOn((Vcb)->Flags, VCB_WRITE_PROTECTED))
#define IsExt3ForceWrite() (IsFlagOn(Ext2Global->Flags, EXT3_FORCE_WRITING))
#define IsVcbForceWrite(Vcb) (IsFlagOn((Vcb)->Flags, VCB_FORCE_WRITING))
#define CanIWrite(Vcb) (IsExt3ForceWrite() || (!IsVcbReadOnly(Vcb) && IsVcbForceWrite(Vcb)))
#define IsLazyWriter(Fcb) ((Fcb)->LazyWriterThread == PsGetCurrentThread())
//
// EXT2_FCB File Control Block
//
// Data that represents an open file
// There is a single instance of the FCB for every open file
//
typedef struct _EXT2_FCB {
/* Common header */
EXT2_FCBVCB;
// List of FCBs for this volume
LIST_ENTRY Next;
SECTION_OBJECT_POINTERS SectionObject;
// Share Access for the file object
SHARE_ACCESS ShareAccess;
// List of byte-range locks for this file
FILE_LOCK FileLockAnchor;
// oplock information management structure
OPLOCK Oplock;
// Lazy writer thread context
PETHREAD LazyWriterThread;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
ULONG OpenHandleCount;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
ULONG ReferenceCount;
// Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
// But only for Files with FO_NO_INTERMEDIATE_BUFFERING flag
ULONG NonCachedOpenCount;
// Flags for the FCB
ULONG Flags;
// Pointer to the inode
struct inode *Inode;
// Vcb
PEXT2_VCB Vcb;
// Mcb Node ...
PEXT2_MCB Mcb;
} EXT2_FCB, *PEXT2_FCB;
//
// Flags for EXT2_FCB
//
#define FCB_FROM_POOL 0x00000001
#define FCB_PAGE_FILE 0x00000002
#define FCB_FILE_MODIFIED 0x00000020
#define FCB_STATE_BUSY 0x00000040
#define FCB_ALLOC_IN_CREATE 0x00000080
#define FCB_ALLOC_IN_WRITE 0x00000100
#define FCB_ALLOC_IN_SETINFO 0x00000200
#define FCB_DELETE_PENDING 0x80000000
//
// Mcb Node
//
struct _EXT2_MCB {
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
// Flags
ULONG Flags;
// Link List Info
PEXT2_MCB Parent; // Parent
PEXT2_MCB Next; // Siblings
union {
PEXT2_MCB Child; // Children Mcb nodes
PEXT2_MCB Target; // Target Mcb of symlink
};
// Mcb Node Info
// -> Fcb
PEXT2_FCB Fcb;
// Short name
UNICODE_STRING ShortName;
// Full name with path
UNICODE_STRING FullName;
// File attribute
ULONG FileAttr;
// reference count
ULONG Refercount;
// Extents zone
LARGE_MCB Extents;
// Metablocks
LARGE_MCB MetaExts;
// Time stamps
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
LARGE_INTEGER LastAccessTime;
// List Link to Vcb->McbList
LIST_ENTRY Link;
struct inode Inode;
struct dentry *de;
};
//
// Flags for MCB
//
#define MCB_FROM_POOL 0x00000001
#define MCB_VCB_LINK 0x00000002
#define MCB_ENTRY_TREE 0x00000004
#define MCB_FILE_DELETED 0x00000008
#define MCB_ZONE_INITED 0x20000000
#define MCB_TYPE_SPECIAL 0x40000000 /* unresolved symlink + device node */
#define MCB_TYPE_SYMLINK 0x80000000
#define IsMcbUsed(Mcb) ((Mcb)->Refercount > 0)
#define IsMcbSymLink(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SYMLINK)
#define IsZoneInited(Mcb) IsFlagOn((Mcb)->Flags, MCB_ZONE_INITED)
#define IsMcbSpecialFile(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SPECIAL)
#define IsMcbRoot(Mcb) ((Mcb)->Inode.i_ino == EXT2_ROOT_INO)
#define IsMcbReadonly(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_READONLY)
#define IsMcbDirectory(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_DIRECTORY)
#define IsFileDeleted(Mcb) IsFlagOn((Mcb)->Flags, MCB_FILE_DELETED)
#define IsLinkInvalid(Mcb) (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target))
/*
* routines for reference count management
*/
#define Ext2ReferXcb(_C) InterlockedIncrement(_C)
#define Ext2DerefXcb(_C) DEC_OBJ_CNT(_C)
__inline ULONG DEC_OBJ_CNT(PULONG _C) {
if (*_C > 0) {
return InterlockedDecrement(_C);
} else {
DbgBreak();
}
return 0;
}
#if EXT2_DEBUG
VOID
Ext2TraceMcb(PCHAR fn, USHORT lc, USHORT add, PEXT2_MCB Mcb);
#define Ext2ReferMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, TRUE, Mcb)
#define Ext2DerefMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, FALSE, Mcb)
#else
#define Ext2ReferMcb(Mcb) Ext2ReferXcb(&Mcb->Refercount)
#define Ext2DerefMcb(Mcb) Ext2DerefXcb(&Mcb->Refercount)
#endif
//
// EXT2_CCB Context Control Block
//
// Data that represents one instance of an open file
// There is one instance of the CCB for every instance of an open file
//
typedef struct _EXT2_CCB {
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
// Flags
ULONG Flags;
// Mcb of it's symbol link
PEXT2_MCB SymLink;
// State that may need to be maintained
UNICODE_STRING DirectorySearchPattern;
/* Open handle control block */
struct file filp;
} EXT2_CCB, *PEXT2_CCB;
//
// Flags for CCB
//
#define CCB_FROM_POOL 0x00000001
#define CCB_VOLUME_DASD_PURGE 0x00000002
#define CCB_LAST_WRITE_UPDATED 0x00000004
#define CCB_OPEN_REPARSE_POINT 0x00000008
#define CCB_DELETE_ON_CLOSE 0x00000010
#define CCB_ALLOW_EXTENDED_DASD_IO 0x80000000
//
// EXT2_IRP_CONTEXT
//
// Used to pass information about a request between the drivers functions
//
typedef struct ext2_icb {
// Identifier for this structure
EXT2_IDENTIFIER Identifier;
// Pointer to the IRP this request describes
PIRP Irp;
// Flags
ULONG Flags;
// The major and minor function code for the request
UCHAR MajorFunction;
UCHAR MinorFunction;
// The device object
PDEVICE_OBJECT DeviceObject;
// The real device object
PDEVICE_OBJECT RealDevice;
// The file object
PFILE_OBJECT FileObject;
PEXT2_FCB Fcb;
PEXT2_CCB Ccb;
// If the request is top level
BOOLEAN IsTopLevel;
// Used if the request needs to be queued for later processing
WORK_QUEUE_ITEM WorkQueueItem;
// If an exception is currently in progress
BOOLEAN ExceptionInProgress;
// The exception code when an exception is in progress
NTSTATUS ExceptionCode;
} EXT2_IRP_CONTEXT, *PEXT2_IRP_CONTEXT;
#define IRP_CONTEXT_FLAG_FROM_POOL (0x00000001)
#define IRP_CONTEXT_FLAG_WAIT (0x00000002)
#define IRP_CONTEXT_FLAG_WRITE_THROUGH (0x00000004)
#define IRP_CONTEXT_FLAG_FLOPPY (0x00000008)
#define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000020)
#define IRP_CONTEXT_FLAG_DEFERRED (0x00000040)
#define IRP_CONTEXT_FLAG_VERIFY_READ (0x00000080)
#define IRP_CONTEXT_STACK_IO_CONTEXT (0x00000100)
#define IRP_CONTEXT_FLAG_REQUEUED (0x00000200)
#define IRP_CONTEXT_FLAG_USER_IO (0x00000400)
#define IRP_CONTEXT_FLAG_DELAY_CLOSE (0x00000800)
#define IRP_CONTEXT_FLAG_FILE_BUSY (0x00001000)
#define Ext2CanIWait() (!IrpContext || IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT))
//
// EXT2_ALLOC_HEADER
//
// In the checked version of the driver this header is put in the beginning of
// every memory allocation
//
typedef struct _EXT2_ALLOC_HEADER {
EXT2_IDENTIFIER Identifier;
} EXT2_ALLOC_HEADER, *PEXT2_ALLOC_HEADER;
typedef struct _FCB_LIST_ENTRY {
PEXT2_FCB Fcb;
LIST_ENTRY Next;
} FCB_LIST_ENTRY, *PFCB_LIST_ENTRY;
// Block Description List
typedef struct _EXT2_EXTENT {
LONGLONG Lba;
ULONG Offset;
ULONG Length;
PIRP Irp;
struct _EXT2_EXTENT * Next;
} EXT2_EXTENT, *PEXT2_EXTENT;
/* FUNCTIONS DECLARATION *****************************************************/
// Include this so we don't need the latest WDK to build the driver.
#ifndef FSCTL_GET_RETRIEVAL_POINTER_BASE
#define FSCTL_GET_RETRIEVAL_POINTER_BASE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS) // RETRIEVAL_POINTER_BASE
#endif
//
// The following macro is used to determine if an FSD thread can block
// for I/O or wait for a resource. It returns TRUE if the thread can
// block and FALSE otherwise. This attribute can then be used to call
// the FSD & FSP common work routine with the proper wait value.
//
#define CanExt2Wait(IRP) IoIsOperationSynchronous(Irp)
//
// memory allocation statistics
//
__inline
VOID
Ext2TraceMemory(BOOLEAN _n, int _i, PVOID _p, LONG _s)
{
if (_n) {
InterlockedIncrement(&Ext2Global->PerfStat.Current.Slot[_i]);
InterlockedIncrement(&Ext2Global->PerfStat.Total.Slot[_i]);
InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], _s);
} else {
InterlockedDecrement(&Ext2Global->PerfStat.Current.Slot[_i]);
InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], -1 * _s);
}
}
__inline
VOID
Ext2TraceIrpContext(BOOLEAN _n, PEXT2_IRP_CONTEXT IrpContext)
{
if (_n) {
INC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
InterlockedIncrement(&(Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current));
} else {
DEC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
InterlockedIncrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Processed);
InterlockedDecrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current);
}
}
typedef struct _EXT2_FILLDIR_CONTEXT {
PEXT2_IRP_CONTEXT efc_irp;
PUCHAR efc_buf;
ULONG efc_size;
ULONG efc_start;
ULONG efc_prev;
NTSTATUS efc_status;
FILE_INFORMATION_CLASS efc_fi;
BOOLEAN efc_single;
} EXT2_FILLDIR_CONTEXT, *PEXT2_FILLDIR_CONTEXT;
//
// Block.c
//
PMDL
Ext2CreateMdl (
IN PVOID Buffer,
IN BOOLEAN bPaged,
IN ULONG Length,
IN LOCK_OPERATION Operation
);
VOID
Ext2DestroyMdl (IN PMDL Mdl);
NTSTATUS
Ext2LockUserBuffer (
IN PIRP Irp,
IN ULONG Length,
IN LOCK_OPERATION Operation);
PVOID
Ext2GetUserBuffer (IN PIRP Irp);
NTSTATUS
Ext2ReadWriteBlocks(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_EXTENT Extent,
IN ULONG Length
);
NTSTATUS
Ext2ReadSync(
IN PEXT2_VCB Vcb,
IN ULONGLONG Offset,
IN ULONG Length,
OUT PVOID Buffer,
IN BOOLEAN bVerify );
NTSTATUS
Ext2ReadDisk(
IN PEXT2_VCB Vcb,
IN ULONGLONG Offset,
IN ULONG Size,
IN PVOID Buffer,
IN BOOLEAN bVerify );
NTSTATUS
Ext2DiskIoControl (
IN PDEVICE_OBJECT DeviceOjbect,
IN ULONG IoctlCode,
IN PVOID InputBuffer,
IN ULONG InputBufferSize,
IN OUT PVOID OutputBuffer,
IN OUT PULONG OutputBufferSize );
VOID
Ext2MediaEjectControl (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN BOOLEAN bPrevent );
NTSTATUS
Ext2DiskShutDown(PEXT2_VCB Vcb);
//
// Cleanup.c
//
NTSTATUS
Ext2Cleanup (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Close.c
//
NTSTATUS
Ext2Close (IN PEXT2_IRP_CONTEXT IrpContext);
VOID
Ext2QueueCloseRequest (IN PEXT2_IRP_CONTEXT IrpContext);
VOID
Ext2DeQueueCloseRequest (IN PVOID Context);
//
// Cmcb.c
//
BOOLEAN
Ext2AcquireForLazyWrite (
IN PVOID Context,
IN BOOLEAN Wait );
VOID
Ext2ReleaseFromLazyWrite (IN PVOID Context);
BOOLEAN
Ext2AcquireForReadAhead (
IN PVOID Context,
IN BOOLEAN Wait );
VOID
Ext2ReleaseFromReadAhead (IN PVOID Context);
BOOLEAN
Ext2NoOpAcquire (
IN PVOID Fcb,
IN BOOLEAN Wait );
VOID
Ext2NoOpRelease (IN PVOID Fcb);
VOID
Ext2AcquireForCreateSection (
IN PFILE_OBJECT FileObject
);
VOID
Ext2ReleaseForCreateSection (
IN PFILE_OBJECT FileObject
);
NTSTATUS
Ext2AcquireFileForModWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER EndingOffset,
OUT PERESOURCE *ResourceToRelease,
IN PDEVICE_OBJECT DeviceObject
);
NTSTATUS
Ext2ReleaseFileForModWrite (
IN PFILE_OBJECT FileObject,
IN PERESOURCE ResourceToRelease,
IN PDEVICE_OBJECT DeviceObject
);
NTSTATUS
Ext2AcquireFileForCcFlush (
IN PFILE_OBJECT FileObject,
IN PDEVICE_OBJECT DeviceObject
);
NTSTATUS
Ext2ReleaseFileForCcFlush (
IN PFILE_OBJECT FileObject,
IN PDEVICE_OBJECT DeviceObject
);
//
// Create.c
//
BOOLEAN
Ext2IsNameValid(PUNICODE_STRING FileName);
NTSTATUS
Ext2FollowLink (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Parent,
IN PEXT2_MCB Mcb,
IN ULONG Linkdep
);
NTSTATUS
Ext2ScanDir (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Parent,
IN PUNICODE_STRING FileName,
OUT PULONG Inode,
struct dentry **dentry
);
BOOLEAN
Ext2IsSpecialSystemFile(
IN PUNICODE_STRING FileName,
IN BOOLEAN bDirectory
);
#define EXT2_LOOKUP_FLAG_MASK (0xFF00000)
#define EXT2_LOOKUP_NOT_FOLLOW (0x8000000)
NTSTATUS
Ext2LookupFile (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PUNICODE_STRING FullName,
IN PEXT2_MCB Parent,
OUT PEXT2_MCB * Ext2Mcb,
IN ULONG Linkdep
);
NTSTATUS
Ext2CreateFile(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
OUT PBOOLEAN OpPostIrp
);
NTSTATUS
Ext2CreateVolume(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb );
NTSTATUS
Ext2Create (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2CreateInode(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB pParentFcb,
IN ULONG Type,
IN ULONG FileAttr,
IN PUNICODE_STRING FileName);
NTSTATUS
Ext2SupersedeOrOverWriteFile(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PFILE_OBJECT FileObject,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Fcb,
IN PLARGE_INTEGER AllocationSize,
IN ULONG Disposition
);
//
// Debug.c
//
/* debug levels */
#define DL_NVR 0
#define DL_VIT 0x00000001
#define DL_ERR 0x00000002
#define DL_DBG 0x00000004
#define DL_INF 0x00000008
#define DL_FUN 0x00000010
#define DL_LOW 0x00000020
#define DL_REN 0x00000040 /* renaming operation */
#define DL_RES 0x00000080 /* entry reference managment */
#define DL_BLK 0x00000100 /* data block allocation / free */
#define DL_CP 0x00000200 /* code pages (create, querydir) */
#define DL_EXT 0x00000400 /* mcb extents */
#define DL_MAP 0x00000800 /* retrieval points */
#define DL_JNL 0x00001000 /* dump journal operations */
#define DL_HTI 0x00002000 /* htree index */
#define DL_WRN 0x00004000 /* warning */
#define DL_BH 0x00008000 /* buffer head */
#define DL_PNP 0x00010000 /* pnp */
#define DL_IO 0x00020000 /* file i/o */
#define DL_DEFAULT (DL_ERR|DL_VIT)
#if EXT2_DEBUG
extern ULONG DebugFilter;
VOID
__cdecl
Ext2NiPrintf(
PCHAR DebugMessage,
...
);
#define DEBUG(_DL, arg) do {if ((_DL) & DebugFilter) Ext2Printf arg;} while(0)
#define DEBUGNI(_DL, arg) do {if ((_DL) & DebugFilter) Ext2NiPrintf arg;} while(0)
#define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
Ext2DbgPrintComplete(Irp, bPrint); \
IoCompleteRequest(Irp, PriorityBoost)
#else
#define DEBUG(_DL, arg) do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)
#define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
IoCompleteRequest(Irp, PriorityBoost)
#endif // EXT2_DEBUG
VOID
__cdecl
Ext2Printf(
PCHAR DebugMessage,
...
);
extern ULONG ProcessNameOffset;
#define Ext2GetCurrentProcessName() ( \
(PUCHAR) PsGetCurrentProcess() + ProcessNameOffset \
)
ULONG
Ext2GetProcessNameOffset (VOID);
VOID
Ext2DbgPrintCall (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp );
VOID
Ext2DbgPrintComplete (
IN PIRP Irp,
IN BOOLEAN bPrint
);
PUCHAR
Ext2NtStatusToString (IN NTSTATUS Status );
PVOID Ext2AllocatePool(
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes,
IN ULONG Tag
);
VOID
Ext2FreePool(
IN PVOID P,
IN ULONG Tag
);
//
// Devctl.c
//
NTSTATUS
Ext2ProcessGlobalProperty(
IN PDEVICE_OBJECT DeviceObject,
IN PEXT2_VOLUME_PROPERTY2 Property,
IN ULONG Length
);
NTSTATUS
Ext2ProcessVolumeProperty(
IN PEXT2_VCB Vcb,
IN PEXT2_VOLUME_PROPERTY2 Property,
IN ULONG Length
);
NTSTATUS
Ext2ProcessUserProperty(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VOLUME_PROPERTY2 Property,
IN ULONG Length
);
NTSTATUS
Ex2ProcessUserPerfStat(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_QUERY_PERFSTAT QueryPerf,
IN ULONG Length
);
NTSTATUS
Ex2ProcessMountPoint(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_MOUNT_POINT MountPoint,
IN ULONG Length
);
NTSTATUS
Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2PrepareToUnload (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Dirctl.c
//
ULONG
Ext2GetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass);
NTSTATUS
Ext2ProcessEntry(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Dcb,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN ULONG in,
IN PVOID Buffer,
IN ULONG UsedLength,
IN ULONG Length,
IN ULONG FileIndex,
IN PUNICODE_STRING pName,
OUT PULONG EntrySize,
IN BOOLEAN Single
);
BOOLEAN
Ext2IsWearingCloak(
IN PEXT2_VCB Vcb,
IN POEM_STRING OeName
);
NTSTATUS Ext2QueryDirectory (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2NotifyChangeDirectory (
IN PEXT2_IRP_CONTEXT IrpContext
);
VOID
Ext2NotifyReportChange (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Filter,
IN ULONG Action
);
NTSTATUS
Ext2DirectoryControl (IN PEXT2_IRP_CONTEXT IrpContext);
BOOLEAN
Ext2IsDirectoryEmpty (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb
);
//
// Dispatch.c
//
VOID
Ext2OplockComplete (
IN PVOID Context,
IN PIRP Irp
);
VOID
Ext2LockIrp (
IN PVOID Context,
IN PIRP Irp
);
NTSTATUS
Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext);
VOID
Ext2DeQueueRequest (IN PVOID Context);
NTSTATUS
Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2BuildRequest (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
//
// Except.c
//
NTSTATUS
Ext2ExceptionFilter (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXCEPTION_POINTERS ExceptionPointer
);
NTSTATUS
Ext2ExceptionHandler (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Extents.c
//
NTSTATUS
Ext2MapExtent(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Index,
IN BOOLEAN Alloc,
OUT PULONG Block,
OUT PULONG Number
);
NTSTATUS
Ext2ExpandExtent(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
ULONG Start,
ULONG End,
PLARGE_INTEGER Size
);
NTSTATUS
Ext2TruncateExtent(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
PLARGE_INTEGER Size
);
//
// generic.c
//
static inline ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
{
return ((ext3_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
le32_to_cpu(es->s_blocks_count);
}
static inline ext3_fsblk_t ext3_r_blocks_count(struct ext3_super_block *es)
{
return ((ext3_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
le32_to_cpu(es->s_r_blocks_count);
}
static inline ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
{
return ((ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
le32_to_cpu(es->s_free_blocks_count);
}
static inline void ext3_blocks_count_set(struct ext3_super_block *es,
ext3_fsblk_t blk)
{
es->s_blocks_count = cpu_to_le32((u32)blk);
es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
}
static inline void ext3_free_blocks_count_set(struct ext3_super_block *es,
ext3_fsblk_t blk)
{
es->s_free_blocks_count = cpu_to_le32((u32)blk);
es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
}
static inline void ext3_r_blocks_count_set(struct ext3_super_block *es,
ext3_fsblk_t blk)
{
es->s_r_blocks_count = cpu_to_le32((u32)blk);
es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
}
blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode,
struct inode *inode);
int ext3_inode_blocks_set(struct ext3_inode *raw_inode,
struct inode * inode);
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
struct ext4_group_desc *bg);
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
struct ext4_group_desc *bg);
ext4_fsblk_t ext4_inode_table(struct super_block *sb,
struct ext4_group_desc *bg);
__u32 ext4_free_blks_count(struct super_block *sb,
struct ext4_group_desc *bg);
__u32 ext4_free_inodes_count(struct super_block *sb,
struct ext4_group_desc *bg);
__u32 ext4_used_dirs_count(struct super_block *sb,
struct ext4_group_desc *bg);
__u32 ext4_itable_unused_count(struct super_block *sb,
struct ext4_group_desc *bg);
void ext4_block_bitmap_set(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk);
void ext4_inode_bitmap_set(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk);
void ext4_inode_table_set(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk);
void ext4_free_blks_set(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count);
void ext4_free_inodes_set(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count);
void ext4_used_dirs_set(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count);
void ext4_itable_unused_set(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count);
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group);
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group);
unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
ext4_group_t block_group,
struct ext4_group_desc *gdp);
unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
ext4_group_t block_group, struct ext4_group_desc *gdp);
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
ext4_group_t block_group, struct buffer_head **bh);
ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb);
unsigned long ext4_count_free_inodes(struct super_block *sb);
int ext4_check_descriptors(struct super_block *sb);
NTSTATUS
Ext2LoadSuper(
IN PEXT2_VCB Vcb,
IN BOOLEAN bVerify,
OUT PEXT2_SUPER_BLOCK * Sb
);
BOOLEAN
Ext2SaveSuper(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb
);
BOOLEAN
Ext2RefreshSuper(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb
);
BOOLEAN
Ext2LoadGroup(IN PEXT2_VCB Vcb);
VOID
Ext2PutGroup(IN PEXT2_VCB Vcb);
BOOLEAN
Ext2SaveGroup(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG Group
);
BOOLEAN
Ext2RefreshGroup(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb
);
BOOLEAN
Ext2GetInodeLba (
IN PEXT2_VCB Vcb,
IN ULONG inode,
OUT PLONGLONG offset
);
BOOLEAN
Ext2LoadInode (
IN PEXT2_VCB Vcb,
IN struct inode *Inode
);
BOOLEAN
Ext2ClearInode (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG inode
);
BOOLEAN
Ext2SaveInode (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN struct inode *Inode
);
BOOLEAN
Ext2LoadBlock (
IN PEXT2_VCB Vcb,
IN ULONG dwBlk,
IN PVOID Buffer
);
BOOLEAN
Ext2SaveBlock (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG dwBlk,
IN PVOID Buf
);
BOOLEAN
Ext2ZeroBuffer(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN LONGLONG Offset,
IN ULONG Size
);
BOOLEAN
Ext2SaveBuffer(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN LONGLONG Offset,
IN ULONG Size,
IN PVOID Buf
);
NTSTATUS
Ext2GetBlock(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Base,
IN ULONG Layer,
IN ULONG Start,
IN ULONG SizeArray,
IN PULONG BlockArray,
IN BOOLEAN bAlloc,
IN OUT PULONG Hint,
OUT PULONG Block,
OUT PULONG Number
);
NTSTATUS
Ext2BlockMap(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Index,
IN BOOLEAN bAlloc,
OUT PULONG pBlock,
OUT PULONG Number
);
VOID
Ext2UpdateVcbStat(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb
);
NTSTATUS
Ext2NewBlock(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG GroupHint,
IN ULONG BlockHint,
OUT PULONG Block,
IN OUT PULONG Number
);
NTSTATUS
Ext2FreeBlock(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG Block,
IN ULONG Number
);
NTSTATUS
Ext2NewInode(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG GroupHint,
IN ULONG Type,
OUT PULONG Inode
);
NTSTATUS
Ext2FreeInode(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN ULONG Inode,
IN ULONG Type
);
NTSTATUS
Ext2AddEntry (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Dcb,
IN struct inode *Inode,
IN PUNICODE_STRING FileName,
OUT struct dentry **dentry
);
NTSTATUS
Ext2SetFileType (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Dcb,
IN PEXT2_MCB Mcb
);
NTSTATUS
Ext2RemoveEntry (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Dcb,
IN PEXT2_MCB Mcb
);
NTSTATUS
Ext2SetParentEntry (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Dcb,
IN ULONG OldParent,
IN ULONG NewParent );
NTSTATUS
Ext2TruncateBlock(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Base,
IN ULONG Start,
IN ULONG Layer,
IN ULONG SizeArray,
IN PULONG BlockArray,
IN PULONG Extra
);
struct ext3_dir_entry_2 *ext3_next_entry(struct ext3_dir_entry_2 *p);
int ext3_check_dir_entry (const char * function, struct inode * dir,
struct ext3_dir_entry_2 * de,
struct buffer_head * bh,
unsigned long offset);
loff_t ext3_max_size(int blkbits, int has_huge_files);
loff_t ext3_max_bitmap_size(int bits, int has_huge_files);
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group,
struct ext4_group_desc *gdp);
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group,
struct ext4_group_desc *gdp);
ext3_fsblk_t descriptor_loc(struct super_block *sb,
ext3_fsblk_t logical_sb_block, unsigned int nr);
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
ext4_group_t block_group, struct buffer_head **bh);
int ext4_check_descriptors(struct super_block *sb);
//
// Fastio.c
//
FAST_IO_POSSIBLE
Ext2IsFastIoPossible(
IN PEXT2_FCB Fcb
);
BOOLEAN
Ext2FastIoCheckIfPossible (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
IN BOOLEAN CheckForReadOperation,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
Ext2FastIoRead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject);
BOOLEAN
Ext2FastIoWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject);
BOOLEAN
Ext2FastIoQueryBasicInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_BASIC_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject);
BOOLEAN
Ext2FastIoQueryStandardInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_STANDARD_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject);
BOOLEAN
Ext2FastIoLock (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
IN BOOLEAN FailImmediately,
IN BOOLEAN ExclusiveLock,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
Ext2FastIoUnlockSingle (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
IN PEPROCESS Process,
IN ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
Ext2FastIoUnlockAll (
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
Ext2FastIoUnlockAllByKey (
IN PFILE_OBJECT FileObject,
IN PEPROCESS Process,
IN ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
);
BOOLEAN
Ext2FastIoQueryNetworkOpenInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject );
BOOLEAN
Ext2FastIoQueryNetworkOpenInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject);
//
// FileInfo.c
//
NTSTATUS
Ext2QueryFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2SetFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
ULONG
Ext2TotalBlocks(
PEXT2_VCB Vcb,
PLARGE_INTEGER Size,
PULONG pMeta
);
NTSTATUS
Ext2ExpandFile(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
PLARGE_INTEGER Size
);
NTSTATUS
Ext2TruncateFile (
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
PLARGE_INTEGER AllocationSize );
NTSTATUS
Ext2IsFileRemovable(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Fcb,
IN PEXT2_CCB Ccb
);
NTSTATUS
Ext2SetDispositionInfo(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_FCB Fcb,
PEXT2_CCB Ccb,
BOOLEAN bDelete
);
NTSTATUS
Ext2SetRenameInfo(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_FCB Fcb,
PEXT2_CCB Ccb
);
NTSTATUS
Ext2SetLinkInfo(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_FCB Fcb,
PEXT2_CCB Ccb
);
ULONG
Ext2InodeType(PEXT2_MCB Mcb);
NTSTATUS
Ext2DeleteFile(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_FCB Fcb,
PEXT2_MCB Mcb
);
//
// Flush.c
//
NTSTATUS
Ext2FlushFiles(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN BOOLEAN bShutDown
);
NTSTATUS
Ext2FlushVolume (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN BOOLEAN bShutDown
);
NTSTATUS
Ext2FlushFile (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_FCB Fcb,
IN PEXT2_CCB Ccb
);
NTSTATUS
Ext2Flush (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Fsctl.c
//
NTSTATUS
Ext2ReadSymlink (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN PVOID Buffer,
IN ULONG Size,
OUT PULONG BytesRead
);
NTSTATUS
Ext2WriteSymlink (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN PVOID Buffer,
IN ULONG Size,
OUT PULONG BytesWritten
);
NTSTATUS
Ext2TruncateSymlink(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
ULONG Size
);
//
// MountPoint process workitem
//
VOID
Ext2SetVpbFlag (IN PVPB Vpb,
IN USHORT Flag );
VOID
Ext2ClearVpbFlag (IN PVPB Vpb,
IN USHORT Flag );
BOOLEAN
Ext2CheckDismount (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN BOOLEAN bForce );
NTSTATUS
Ext2PurgeVolume (IN PEXT2_VCB Vcb,
IN BOOLEAN FlushBeforePurge);
NTSTATUS
Ext2PurgeFile (IN PEXT2_FCB Fcb,
IN BOOLEAN FlushBeforePurge);
BOOLEAN
Ext2IsHandleCountZero(IN PEXT2_VCB Vcb);
NTSTATUS
Ext2LockVcb (IN PEXT2_VCB Vcb,
IN PFILE_OBJECT FileObject);
NTSTATUS
Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2UnlockVcb (IN PEXT2_VCB Vcb,
IN PFILE_OBJECT FileObject);
NTSTATUS
Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2AllowExtendedDasdIo(IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2QueryExtentMappings(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_FCB Fcb,
IN PLARGE_INTEGER RequestVbn,
OUT PLARGE_INTEGER * pMappedRuns
);
NTSTATUS
Ext2QueryRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2GetRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2GetRetrievalPointerBase(IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext);
BOOLEAN
Ext2IsMediaWriteProtected (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PDEVICE_OBJECT TargetDevice
);
NTSTATUS
Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
VOID
Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb );
NTSTATUS
Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext);
//
// HTree.c
//
struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode,
ext3_lblk_t *block, int *err);
void ext3_set_de_type(struct super_block *sb,
struct ext3_dir_entry_2 *de,
umode_t mode);
__u32 ext3_current_time(struct inode *in);
void ext3_warning (struct super_block * sb, const char * function,
char * fmt, ...);
#define ext3_error ext3_warning
#define ext4_error ext3_error
void ext3_update_dx_flag(struct inode *inode);
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in);
void ext3_inc_count(struct inode *inode);
void ext3_dec_count(struct inode *inode);
struct buffer_head *
ext3_find_entry (struct ext2_icb *icb, struct dentry *dentry,
struct ext3_dir_entry_2 ** res_dir);
struct buffer_head *
ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry,
struct ext3_dir_entry_2 **res_dir, int *err);
typedef int (*filldir_t)(void *, const char *, int, unsigned long, __u32, unsigned);
int ext3_dx_readdir(struct file *filp, filldir_t filldir, void * context);
struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode,
unsigned long block, int *err);
int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry,
struct inode *inode, struct ext3_dir_entry_2 *de,
struct buffer_head *bh);
struct ext3_dir_entry_2 *
do_split(struct ext2_icb *icb, struct inode *dir,
struct buffer_head **bh,struct dx_frame *frame,
struct dx_hash_info *hinfo, int *error);
int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode);
int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir,
struct ext3_dir_entry_2 *de_del,
struct buffer_head *bh);
int ext3_is_dir_empty(struct ext2_icb *icb, struct inode *inode);
//
// Init.c
//
BOOLEAN
Ext2QueryGlobalParameters (IN PUNICODE_STRING RegistryPath);
VOID
DriverUnload (IN PDRIVER_OBJECT DriverObject);
//
// Indirect.c
//
NTSTATUS
Ext2MapIndirect(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Index,
IN BOOLEAN bAlloc,
OUT PULONG pBlock,
OUT PULONG Number
);
NTSTATUS
Ext2ExpandIndirect(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
ULONG Start,
ULONG End,
PLARGE_INTEGER Size
);
NTSTATUS
Ext2TruncateIndirect(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_MCB Mcb,
PLARGE_INTEGER Size
);
//
// linux.c: linux lib implemenation
//
int
ext2_init_linux();
void
ext2_destroy_linux();
//
// Lock.c
//
NTSTATUS
Ext2LockControl (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Memory.c
//
PEXT2_IRP_CONTEXT
Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp );
VOID
Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext);
PEXT2_FCB
Ext2AllocateFcb (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb
);
VOID
Ext2FreeFcb (IN PEXT2_FCB Fcb);
VOID
Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb);
VOID
Ext2RemoveFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb);
PEXT2_CCB
Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink);
VOID
Ext2FreeMcb (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb
);
VOID
Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb);
PEXT2_INODE
Ext2AllocateInode (PEXT2_VCB Vcb);
VOID
Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode);
struct dentry * Ext2AllocateEntry();
VOID Ext2FreeEntry (IN struct dentry *de);
struct dentry *Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName);
PEXT2_EXTENT
Ext2AllocateExtent();
VOID
Ext2FreeExtent (IN PEXT2_EXTENT Extent);
ULONG
Ext2CountExtents(IN PEXT2_EXTENT Chain);
VOID
Ext2JointExtents(
IN PEXT2_EXTENT Chain,
IN PEXT2_EXTENT Extent
);
VOID
Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain);
NTSTATUS
Ext2BuildExtents(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONGLONG Offset,
IN ULONG Size,
IN BOOLEAN bAlloc,
OUT PEXT2_EXTENT * Chain
);
BOOLEAN
Ext2ListExtents(PLARGE_MCB Extents);
VOID
Ext2CheckExtent(
PLARGE_MCB Zone,
LONGLONG Vbn,
LONGLONG Lbn,
LONGLONG Length,
BOOLEAN bAdded
);
VOID
Ext2ClearAllExtents(PLARGE_MCB Zone);
BOOLEAN
Ext2AddVcbExtent (
IN PEXT2_VCB Vcb,
IN LONGLONG Vbn,
IN LONGLONG Length
);
BOOLEAN
Ext2RemoveVcbExtent (
IN PEXT2_VCB Vcb,
IN LONGLONG Vbn,
IN LONGLONG Length
);
BOOLEAN
Ext2LookupVcbExtent (
IN PEXT2_VCB Vcb,
IN LONGLONG Vbn,
OUT PLONGLONG Lbn,
OUT PLONGLONG Length
);
BOOLEAN
Ext2AddMcbExtent (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN LONGLONG Vbn,
IN LONGLONG Lbn,
IN LONGLONG Length
);
BOOLEAN
Ext2RemoveMcbExtent (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN LONGLONG Vbn,
IN LONGLONG Length
);
BOOLEAN
Ext2LookupMcbExtent (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN LONGLONG Vbn,
OUT PLONGLONG Lbn,
OUT PLONGLONG Length
);
BOOLEAN
Ext2AddMcbMetaExts (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Block,
IN ULONG Length
);
BOOLEAN
Ext2RemoveMcbMetaExts (
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Block,
IN ULONG Length
);
BOOLEAN
Ext2AddBlockExtent(
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Start,
IN ULONG Block,
IN ULONG Number
);
BOOLEAN
Ext2LookupBlockExtent(
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Start,
IN PULONG Block,
IN PULONG Mapped
);
BOOLEAN
Ext2RemoveBlockExtent(
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONG Start,
IN ULONG Number
);
NTSTATUS
Ext2InitializeZone(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb
);
BOOLEAN
Ext2BuildName(
IN OUT PUNICODE_STRING Target,
IN PUNICODE_STRING File,
IN PUNICODE_STRING Parent
);
PEXT2_MCB
Ext2AllocateMcb (
IN PEXT2_VCB Vcb,
IN PUNICODE_STRING FileName,
IN PUNICODE_STRING Parent,
IN ULONG FileAttr
);
PEXT2_MCB
Ext2SearchMcb(
PEXT2_VCB Vcb,
PEXT2_MCB Parent,
PUNICODE_STRING FileName
);
PEXT2_MCB
Ext2SearchMcbWithoutLock(
PEXT2_MCB Parent,
PUNICODE_STRING FileName
);
VOID
Ext2InsertMcb(
PEXT2_VCB Vcb,
PEXT2_MCB Parent,
PEXT2_MCB Child
);
BOOLEAN
Ext2RemoveMcb(
PEXT2_VCB Vcb,
PEXT2_MCB Mcb
);
VOID
Ext2CleanupAllMcbs(
PEXT2_VCB Vcb
);
BOOLEAN
Ext2CheckSetBlock(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb, LONGLONG Block
);
BOOLEAN
Ext2CheckBitmapConsistency(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb
);
VOID
Ext2InsertVcb(PEXT2_VCB Vcb);
VOID
Ext2RemoveVcb(PEXT2_VCB Vcb);
NTSTATUS
Ext2InitializeLabel(
IN PEXT2_VCB Vcb,
IN PEXT2_SUPER_BLOCK Sb
);
NTSTATUS
Ext2InitializeVcb(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb,
PEXT2_SUPER_BLOCK Ext2Sb,
PDEVICE_OBJECT TargetDevice,
PDEVICE_OBJECT VolumeDevice,
PVPB Vpb );
VOID
Ext2TearDownStream (IN PEXT2_VCB Vcb);
VOID
Ext2DestroyVcb (IN PEXT2_VCB Vcb);
NTSTATUS
Ext2CompleteIrpContext (
IN PEXT2_IRP_CONTEXT IrpContext,
IN NTSTATUS Status );
VOID
Ext2SyncUninitializeCacheMap (
IN PFILE_OBJECT FileObject );
VOID
Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
VOID
Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
VOID
Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
PEXT2_MCB
Ext2FirstUnusedMcb(
PEXT2_VCB Vcb,
BOOLEAN Wait,
ULONG Number
);
VOID
Ext2ReaperThread(
PVOID Context
);
NTSTATUS
Ext2StartReaperThread();
//
// Misc.c
//
ULONG
Ext2Log2(ULONG Value);
LARGE_INTEGER
Ext2NtTime (IN ULONG i_time);
ULONG
Ext2LinuxTime (IN LARGE_INTEGER SysTime);
ULONG
Ext2OEMToUnicodeSize(
IN PEXT2_VCB Vcb,
IN PANSI_STRING Oem
);
NTSTATUS
Ext2OEMToUnicode(
IN PEXT2_VCB Vcb,
IN OUT PUNICODE_STRING Oem,
IN POEM_STRING Unicode
);
ULONG
Ext2UnicodeToOEMSize(
IN PEXT2_VCB Vcb,
IN PUNICODE_STRING Unicode
);
NTSTATUS
Ext2UnicodeToOEM (
IN PEXT2_VCB Vcb,
IN OUT POEM_STRING Oem,
IN PUNICODE_STRING Unicode
);
VOID
Ext2Sleep(ULONG ms);
int Ext2LinuxError (NTSTATUS Status);
NTSTATUS Ext2WinntError(int rc);
BOOLEAN Ext2IsDot(PUNICODE_STRING name);
BOOLEAN Ext2IsDotDot(PUNICODE_STRING name);
//
// nls/nls_rtl.c
//
int
Ext2LoadAllNls();
VOID
Ext2UnloadAllNls();
//
// Pnp.c
//
NTSTATUS
Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2PnpQueryRemove(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb );
NTSTATUS
Ext2PnpRemove(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb );
NTSTATUS
Ext2PnpCancelRemove(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb );
NTSTATUS
Ext2PnpSurpriseRemove(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb );
//
// Read.c
//
NTSTATUS
Ext2ReadInode (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONGLONG Offset,
IN PVOID Buffer,
IN ULONG Size,
IN BOOLEAN bDirectIo,
OUT PULONG dwReturn
);
NTSTATUS
Ext2Read (IN PEXT2_IRP_CONTEXT IrpContext);
//
// ext3\recover.c
//
PEXT2_MCB
Ext2LoadInternalJournal(
PEXT2_VCB Vcb,
ULONG jNo
);
INT
Ext2CheckJournal(
PEXT2_VCB Vcb,
PULONG jNo
);
INT
Ext2RecoverJournal(
PEXT2_IRP_CONTEXT IrpContext,
PEXT2_VCB Vcb
);
//
// Shutdown.c
//
NTSTATUS
Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Volinfo.c
//
NTSTATUS
Ext2QueryVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
NTSTATUS
Ext2SetVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
//
// Write.c
//
typedef struct _EXT2_RW_CONTEXT {
PIRP MasterIrp;
KEVENT Event;
ULONG Blocks;
ULONG Length;
PERESOURCE Resource;
ERESOURCE_THREAD ThreadId;
PFILE_OBJECT FileObject;
ULONG Flags;
BOOLEAN Wait;
} EXT2_RW_CONTEXT, *PEXT2_RW_CONTEXT;
#define EXT2_RW_CONTEXT_WRITE 1
NTSTATUS
Ext2WriteInode (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PEXT2_MCB Mcb,
IN ULONGLONG Offset,
IN PVOID Buffer,
IN ULONG Size,
IN BOOLEAN bDirectIo,
OUT PULONG dwReturn
);
VOID
Ext2StartFloppyFlushDpc (
PEXT2_VCB Vcb,
PEXT2_FCB Fcb,
PFILE_OBJECT FileObject );
BOOLEAN
Ext2ZeroData (
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER Start,
IN PLARGE_INTEGER End );
NTSTATUS
Ext2Write (IN PEXT2_IRP_CONTEXT IrpContext);
#endif /* _EXT2_HEADER_ */
|