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>
22 #include "check/common.h"
24 #include "check/fat.h"
25 #include "check/file.h"
28 typedef struct _FAT16_BOOT_SECTOR
30 unsigned char magic0
; // 0
31 unsigned char res0
; // 1
32 unsigned char magic1
; // 2
33 unsigned char OEMName
[8]; // 3
34 unsigned short BytesPerSector
; // 11
35 unsigned char SectorsPerCluster
; // 13
36 unsigned short ReservedSectors
; // 14
37 unsigned char FATCount
; // 16
38 unsigned short RootEntries
; // 17
39 unsigned short Sectors
; // 19
40 unsigned char Media
; // 21
41 unsigned short FATSectors
; // 22
42 unsigned short SectorsPerTrack
; // 24
43 unsigned short Heads
; // 26
44 unsigned long HiddenSectors
; // 28
45 unsigned long SectorsHuge
; // 32
46 unsigned char Drive
; // 36
47 unsigned char Res1
; // 37
48 unsigned char ExtBootSignature
; // 38
49 unsigned long VolumeID
; // 39
50 unsigned char VolumeLabel
[11]; // 43
51 unsigned char SysType
[8]; // 54
52 unsigned char Res2
[446]; // 62
53 unsigned long Signature1
; // 508
54 } FAT16_BOOT_SECTOR
, *PFAT16_BOOT_SECTOR
;
57 typedef struct _FAT32_BOOT_SECTOR
59 unsigned char magic0
; // 0
60 unsigned char res0
; // 1
61 unsigned char magic1
; // 2
62 unsigned char OEMName
[8]; // 3
63 unsigned short BytesPerSector
; // 11
64 unsigned char SectorsPerCluster
; // 13
65 unsigned short ReservedSectors
; // 14
66 unsigned char FATCount
; // 16
67 unsigned short RootEntries
; // 17
68 unsigned short Sectors
; // 19
69 unsigned char Media
; // 21
70 unsigned short FATSectors
; // 22
71 unsigned short SectorsPerTrack
; // 24
72 unsigned short Heads
; // 26
73 unsigned long HiddenSectors
; // 28
74 unsigned long SectorsHuge
; // 32
75 unsigned long FATSectors32
; // 36
76 unsigned short ExtFlag
; // 40
77 unsigned short FSVersion
; // 42
78 unsigned long RootCluster
; // 44
79 unsigned short FSInfoSector
; // 48
80 unsigned short BootBackup
; // 50
81 unsigned char Res3
[12]; // 52
82 unsigned char Drive
; // 64
83 unsigned char Res4
; // 65
84 unsigned char ExtBootSignature
; // 66
85 unsigned long VolumeID
; // 67
86 unsigned char VolumeLabel
[11]; // 71
87 unsigned char SysType
[8]; // 82
88 unsigned char Res2
[418]; // 90
89 unsigned long Signature1
; // 508
90 } FAT32_BOOT_SECTOR
, *PFAT32_BOOT_SECTOR
;
92 typedef struct _FAT32_FSINFO
94 unsigned long LeadSig
; // 0
95 unsigned char Res1
[480]; // 4
96 unsigned long StrucSig
; // 484
97 unsigned long FreeCount
; // 488
98 unsigned long NextFree
; // 492
99 unsigned long Res2
[3]; // 496
100 unsigned long TrailSig
; // 508
101 } FAT32_FSINFO
, *PFAT32_FSINFO
;
104 typedef struct _FORMAT_CONTEXT
106 PFMIFSCALLBACK Callback
;
107 ULONG TotalSectorCount
;
108 ULONG CurrentSectorCount
;
111 } FORMAT_CONTEXT
, *PFORMAT_CONTEXT
;
115 Fat12Format(HANDLE FileHandle
,
116 PPARTITION_INFORMATION PartitionInfo
,
117 PDISK_GEOMETRY DiskGeometry
,
118 PUNICODE_STRING Label
,
121 PFORMAT_CONTEXT Context
);
124 Fat16Format(HANDLE FileHandle
,
125 PPARTITION_INFORMATION PartitionInfo
,
126 PDISK_GEOMETRY DiskGeometry
,
127 PUNICODE_STRING Label
,
130 PFORMAT_CONTEXT Context
);
133 Fat32Format(HANDLE FileHandle
,
134 PPARTITION_INFORMATION PartitionInfo
,
135 PDISK_GEOMETRY DiskGeometry
,
136 PUNICODE_STRING Label
,
139 PFORMAT_CONTEXT Context
);
142 UpdateProgress(PFORMAT_CONTEXT Context
,
146 VfatPrint(PCHAR Format
, ...);