2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS VFAT filesystem library
9 #define WIN32_NO_STATUS
11 #define COM_NO_WINDOWS_H
15 #define NTOS_MODE_USER
16 #include <ndk/iofuncs.h>
17 #include <ndk/kefuncs.h>
18 #include <ndk/obfuncs.h>
19 #include <ndk/rtlfuncs.h>
20 #include <fmifs/fmifs.h>
23 #include <limits.h> // for INT_MAX definition
25 #include "check/dosfsck.h"
26 #include "check/common.h"
28 #include "check/lfn.h"
29 #include "check/boot.h"
30 #include "check/fat.h"
31 #include "check/file.h"
32 #include "check/check.h"
35 typedef struct _FAT16_BOOT_SECTOR
37 unsigned char magic0
; // 0
38 unsigned char res0
; // 1
39 unsigned char magic1
; // 2
40 unsigned char OEMName
[8]; // 3
41 unsigned short BytesPerSector
; // 11
42 unsigned char SectorsPerCluster
; // 13
43 unsigned short ReservedSectors
; // 14
44 unsigned char FATCount
; // 16
45 unsigned short RootEntries
; // 17
46 unsigned short Sectors
; // 19
47 unsigned char Media
; // 21
48 unsigned short FATSectors
; // 22
49 unsigned short SectorsPerTrack
; // 24
50 unsigned short Heads
; // 26
51 unsigned long HiddenSectors
; // 28
52 unsigned long SectorsHuge
; // 32
53 unsigned char Drive
; // 36
54 unsigned char Res1
; // 37
55 unsigned char ExtBootSignature
; // 38
56 unsigned long VolumeID
; // 39
57 unsigned char VolumeLabel
[11]; // 43
58 unsigned char SysType
[8]; // 54
59 unsigned char Res2
[446]; // 62
60 unsigned long Signature1
; // 508
61 } FAT16_BOOT_SECTOR
, *PFAT16_BOOT_SECTOR
;
64 typedef struct _FAT32_BOOT_SECTOR
66 unsigned char magic0
; // 0
67 unsigned char res0
; // 1
68 unsigned char magic1
; // 2
69 unsigned char OEMName
[8]; // 3
70 unsigned short BytesPerSector
; // 11
71 unsigned char SectorsPerCluster
; // 13
72 unsigned short ReservedSectors
; // 14
73 unsigned char FATCount
; // 16
74 unsigned short RootEntries
; // 17
75 unsigned short Sectors
; // 19
76 unsigned char Media
; // 21
77 unsigned short FATSectors
; // 22
78 unsigned short SectorsPerTrack
; // 24
79 unsigned short Heads
; // 26
80 unsigned long HiddenSectors
; // 28
81 unsigned long SectorsHuge
; // 32
82 unsigned long FATSectors32
; // 36
83 unsigned short ExtFlag
; // 40
84 unsigned short FSVersion
; // 42
85 unsigned long RootCluster
; // 44
86 unsigned short FSInfoSector
; // 48
87 unsigned short BootBackup
; // 50
88 unsigned char Res3
[12]; // 52
89 unsigned char Drive
; // 64
90 unsigned char Res4
; // 65
91 unsigned char ExtBootSignature
; // 66
92 unsigned long VolumeID
; // 67
93 unsigned char VolumeLabel
[11]; // 71
94 unsigned char SysType
[8]; // 82
95 unsigned char Res2
[418]; // 90
96 unsigned long Signature1
; // 508
97 } FAT32_BOOT_SECTOR
, *PFAT32_BOOT_SECTOR
;
99 typedef struct _FAT32_FSINFO
101 unsigned long LeadSig
; // 0
102 unsigned char Res1
[480]; // 4
103 unsigned long StrucSig
; // 484
104 unsigned long FreeCount
; // 488
105 unsigned long NextFree
; // 492
106 unsigned long Res2
[3]; // 496
107 unsigned long TrailSig
; // 508
108 } FAT32_FSINFO
, *PFAT32_FSINFO
;
111 typedef struct _FORMAT_CONTEXT
113 PFMIFSCALLBACK Callback
;
114 ULONG TotalSectorCount
;
115 ULONG CurrentSectorCount
;
118 } FORMAT_CONTEXT
, *PFORMAT_CONTEXT
;
122 Fat12Format(HANDLE FileHandle
,
123 PPARTITION_INFORMATION PartitionInfo
,
124 PDISK_GEOMETRY DiskGeometry
,
125 PUNICODE_STRING Label
,
128 PFORMAT_CONTEXT Context
);
131 Fat16Format(HANDLE FileHandle
,
132 PPARTITION_INFORMATION PartitionInfo
,
133 PDISK_GEOMETRY DiskGeometry
,
134 PUNICODE_STRING Label
,
137 PFORMAT_CONTEXT Context
);
140 Fat32Format(HANDLE FileHandle
,
141 PPARTITION_INFORMATION PartitionInfo
,
142 PDISK_GEOMETRY DiskGeometry
,
143 PUNICODE_STRING Label
,
146 PFORMAT_CONTEXT Context
);
149 UpdateProgress(PFORMAT_CONTEXT Context
,
153 VfatPrint(PCHAR Format
, ...);