2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS VFAT filesystem library
13 #define WIN32_NO_STATUS
15 #define COM_NO_WINDOWS_H
18 #define NTOS_MODE_USER
19 #include <ndk/iofuncs.h>
20 #include <ndk/kefuncs.h>
21 #include <ndk/obfuncs.h>
22 #include <ndk/rtlfuncs.h>
23 #include <fmifs/fmifs.h>
25 #include "check/dosfsck.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
;
56 typedef struct _FAT32_BOOT_SECTOR
58 unsigned char magic0
; // 0
59 unsigned char res0
; // 1
60 unsigned char magic1
; // 2
61 unsigned char OEMName
[8]; // 3
62 unsigned short BytesPerSector
; // 11
63 unsigned char SectorsPerCluster
; // 13
64 unsigned short ReservedSectors
; // 14
65 unsigned char FATCount
; // 16
66 unsigned short RootEntries
; // 17
67 unsigned short Sectors
; // 19
68 unsigned char Media
; // 21
69 unsigned short FATSectors
; // 22
70 unsigned short SectorsPerTrack
; // 24
71 unsigned short Heads
; // 26
72 unsigned long HiddenSectors
; // 28
73 unsigned long SectorsHuge
; // 32
74 unsigned long FATSectors32
; // 36
75 unsigned short ExtFlag
; // 40
76 unsigned short FSVersion
; // 42
77 unsigned long RootCluster
; // 44
78 unsigned short FSInfoSector
; // 48
79 unsigned short BootBackup
; // 50
80 unsigned char Res3
[12]; // 52
81 unsigned char Drive
; // 64
82 unsigned char Res4
; // 65
83 unsigned char ExtBootSignature
; // 66
84 unsigned long VolumeID
; // 67
85 unsigned char VolumeLabel
[11]; // 71
86 unsigned char SysType
[8]; // 82
87 unsigned char Res2
[418]; // 90
88 unsigned long Signature1
; // 508
89 } FAT32_BOOT_SECTOR
, *PFAT32_BOOT_SECTOR
;
91 typedef struct _FAT32_FSINFO
93 unsigned long LeadSig
; // 0
94 unsigned char Res1
[480]; // 4
95 unsigned long StrucSig
; // 484
96 unsigned long FreeCount
; // 488
97 unsigned long NextFree
; // 492
98 unsigned long Res2
[3]; // 496
99 unsigned long TrailSig
; // 508
100 } FAT32_FSINFO
, *PFAT32_FSINFO
;
103 #define FSINFO_SECTOR_BEGIN_SIGNATURE 0x41615252 // 'RRaA'
104 #define FSINFO_SECTOR_END_SIGNATURE 0xAA550000
105 #define FSINFO_SIGNATURE 0x61417272 // 'rrAa'
107 typedef struct _FORMAT_CONTEXT
109 PFMIFSCALLBACK Callback
;
110 ULONG TotalSectorCount
;
111 ULONG CurrentSectorCount
;
114 } FORMAT_CONTEXT
, *PFORMAT_CONTEXT
;
120 Fat12Format(HANDLE FileHandle
,
121 PPARTITION_INFORMATION PartitionInfo
,
122 PDISK_GEOMETRY DiskGeometry
,
123 PUNICODE_STRING Label
,
126 PFORMAT_CONTEXT Context
);
129 Fat16Format(HANDLE FileHandle
,
130 PPARTITION_INFORMATION PartitionInfo
,
131 PDISK_GEOMETRY DiskGeometry
,
132 PUNICODE_STRING Label
,
135 PFORMAT_CONTEXT Context
);
138 Fat32Format(HANDLE FileHandle
,
139 PPARTITION_INFORMATION PartitionInfo
,
140 PDISK_GEOMETRY DiskGeometry
,
141 PUNICODE_STRING Label
,
144 PFORMAT_CONTEXT Context
);
147 UpdateProgress(PFORMAT_CONTEXT Context
,
151 VfatPrintV(PCHAR Format
, va_list args
);
154 VfatPrint(PCHAR Format
, ...);
156 #endif /* _VFATLIB_H_ */