d83831d6c94742ac580d3468b1ebb1a13339a22b
[reactos.git] / reactos / lib / fslib / vfatlib / vfatlib.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS VFAT filesystem library
4 * FILE: vfatlib.h
5 */
6
7 #ifndef _VFATLIB_H_
8 #define _VFATLIB_H_
9
10 #include <stdio.h>
11
12 #define WIN32_NO_STATUS
13 #define _INC_WINDOWS
14 #define COM_NO_WINDOWS_H
15 #include <windef.h>
16 #include <winbase.h>
17 #include <objbase.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>
24
25 #include "check/common.h"
26 #include "check/io.h"
27 #include "check/fat.h"
28 #include "check/file.h"
29
30 #include <pshpack1.h>
31 typedef struct _FAT16_BOOT_SECTOR
32 {
33 unsigned char magic0; // 0
34 unsigned char res0; // 1
35 unsigned char magic1; // 2
36 unsigned char OEMName[8]; // 3
37 unsigned short BytesPerSector; // 11
38 unsigned char SectorsPerCluster; // 13
39 unsigned short ReservedSectors; // 14
40 unsigned char FATCount; // 16
41 unsigned short RootEntries; // 17
42 unsigned short Sectors; // 19
43 unsigned char Media; // 21
44 unsigned short FATSectors; // 22
45 unsigned short SectorsPerTrack; // 24
46 unsigned short Heads; // 26
47 unsigned long HiddenSectors; // 28
48 unsigned long SectorsHuge; // 32
49 unsigned char Drive; // 36
50 unsigned char Res1; // 37
51 unsigned char ExtBootSignature; // 38
52 unsigned long VolumeID; // 39
53 unsigned char VolumeLabel[11]; // 43
54 unsigned char SysType[8]; // 54
55 unsigned char Res2[446]; // 62
56 unsigned long Signature1; // 508
57 } FAT16_BOOT_SECTOR, *PFAT16_BOOT_SECTOR;
58
59
60 typedef struct _FAT32_BOOT_SECTOR
61 {
62 unsigned char magic0; // 0
63 unsigned char res0; // 1
64 unsigned char magic1; // 2
65 unsigned char OEMName[8]; // 3
66 unsigned short BytesPerSector; // 11
67 unsigned char SectorsPerCluster; // 13
68 unsigned short ReservedSectors; // 14
69 unsigned char FATCount; // 16
70 unsigned short RootEntries; // 17
71 unsigned short Sectors; // 19
72 unsigned char Media; // 21
73 unsigned short FATSectors; // 22
74 unsigned short SectorsPerTrack; // 24
75 unsigned short Heads; // 26
76 unsigned long HiddenSectors; // 28
77 unsigned long SectorsHuge; // 32
78 unsigned long FATSectors32; // 36
79 unsigned short ExtFlag; // 40
80 unsigned short FSVersion; // 42
81 unsigned long RootCluster; // 44
82 unsigned short FSInfoSector; // 48
83 unsigned short BootBackup; // 50
84 unsigned char Res3[12]; // 52
85 unsigned char Drive; // 64
86 unsigned char Res4; // 65
87 unsigned char ExtBootSignature; // 66
88 unsigned long VolumeID; // 67
89 unsigned char VolumeLabel[11]; // 71
90 unsigned char SysType[8]; // 82
91 unsigned char Res2[418]; // 90
92 unsigned long Signature1; // 508
93 } FAT32_BOOT_SECTOR, *PFAT32_BOOT_SECTOR;
94
95 typedef struct _FAT32_FSINFO
96 {
97 unsigned long LeadSig; // 0
98 unsigned char Res1[480]; // 4
99 unsigned long StrucSig; // 484
100 unsigned long FreeCount; // 488
101 unsigned long NextFree; // 492
102 unsigned long Res2[3]; // 496
103 unsigned long TrailSig; // 508
104 } FAT32_FSINFO, *PFAT32_FSINFO;
105 #include <poppack.h>
106
107 typedef struct _FORMAT_CONTEXT
108 {
109 PFMIFSCALLBACK Callback;
110 ULONG TotalSectorCount;
111 ULONG CurrentSectorCount;
112 BOOLEAN Success;
113 ULONG Percent;
114 } FORMAT_CONTEXT, *PFORMAT_CONTEXT;
115
116
117 NTSTATUS
118 Fat12Format(HANDLE FileHandle,
119 PPARTITION_INFORMATION PartitionInfo,
120 PDISK_GEOMETRY DiskGeometry,
121 PUNICODE_STRING Label,
122 BOOLEAN QuickFormat,
123 ULONG ClusterSize,
124 PFORMAT_CONTEXT Context);
125
126 NTSTATUS
127 Fat16Format(HANDLE FileHandle,
128 PPARTITION_INFORMATION PartitionInfo,
129 PDISK_GEOMETRY DiskGeometry,
130 PUNICODE_STRING Label,
131 BOOLEAN QuickFormat,
132 ULONG ClusterSize,
133 PFORMAT_CONTEXT Context);
134
135 NTSTATUS
136 Fat32Format(HANDLE FileHandle,
137 PPARTITION_INFORMATION PartitionInfo,
138 PDISK_GEOMETRY DiskGeometry,
139 PUNICODE_STRING Label,
140 BOOLEAN QuickFormat,
141 ULONG ClusterSize,
142 PFORMAT_CONTEXT Context);
143
144 VOID
145 UpdateProgress(PFORMAT_CONTEXT Context,
146 ULONG Increment);
147
148 VOID
149 VfatPrint(PCHAR Format, ...);
150
151 #endif /* _VFATLIB_H_ */
152
153 /* EOF */