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