f5f3dbeb50dbbd53877ed83aed4ae4d3a1474856
[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 #include <stdio.h>
8
9 #define WIN32_NO_STATUS
10 #define _INC_WINDOWS
11 #define COM_NO_WINDOWS_H
12 #include <windef.h>
13 #include <winbase.h>
14 #include <objbase.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>
21
22 #include <time.h>
23 #include <limits.h> // for INT_MAX definition
24
25 #include "check/dosfsck.h"
26 #include "check/common.h"
27 #include "check/io.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"
33
34 #include <pshpack1.h>
35 typedef struct _FAT16_BOOT_SECTOR
36 {
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;
62
63
64 typedef struct _FAT32_BOOT_SECTOR
65 {
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;
98
99 typedef struct _FAT32_FSINFO
100 {
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;
109 #include <poppack.h>
110
111 typedef struct _FORMAT_CONTEXT
112 {
113 PFMIFSCALLBACK Callback;
114 ULONG TotalSectorCount;
115 ULONG CurrentSectorCount;
116 BOOLEAN Success;
117 ULONG Percent;
118 } FORMAT_CONTEXT, *PFORMAT_CONTEXT;
119
120
121 NTSTATUS
122 Fat12Format(HANDLE FileHandle,
123 PPARTITION_INFORMATION PartitionInfo,
124 PDISK_GEOMETRY DiskGeometry,
125 PUNICODE_STRING Label,
126 BOOLEAN QuickFormat,
127 ULONG ClusterSize,
128 PFORMAT_CONTEXT Context);
129
130 NTSTATUS
131 Fat16Format(HANDLE FileHandle,
132 PPARTITION_INFORMATION PartitionInfo,
133 PDISK_GEOMETRY DiskGeometry,
134 PUNICODE_STRING Label,
135 BOOLEAN QuickFormat,
136 ULONG ClusterSize,
137 PFORMAT_CONTEXT Context);
138
139 NTSTATUS
140 Fat32Format(HANDLE FileHandle,
141 PPARTITION_INFORMATION PartitionInfo,
142 PDISK_GEOMETRY DiskGeometry,
143 PUNICODE_STRING Label,
144 BOOLEAN QuickFormat,
145 ULONG ClusterSize,
146 PFORMAT_CONTEXT Context);
147
148 VOID
149 UpdateProgress(PFORMAT_CONTEXT Context,
150 ULONG Increment);
151
152 VOID
153 VfatPrint(PCHAR Format, ...);
154
155 /* EOF */