[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 #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 "check/common.h"
23 #include "check/io.h"
24 #include "check/fat.h"
25 #include "check/file.h"
26
27 #include <pshpack1.h>
28 typedef struct _FAT16_BOOT_SECTOR
29 {
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;
55
56
57 typedef struct _FAT32_BOOT_SECTOR
58 {
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;
91
92 typedef struct _FAT32_FSINFO
93 {
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;
102 #include <poppack.h>
103
104 typedef struct _FORMAT_CONTEXT
105 {
106 PFMIFSCALLBACK Callback;
107 ULONG TotalSectorCount;
108 ULONG CurrentSectorCount;
109 BOOLEAN Success;
110 ULONG Percent;
111 } FORMAT_CONTEXT, *PFORMAT_CONTEXT;
112
113
114 NTSTATUS
115 Fat12Format(HANDLE FileHandle,
116 PPARTITION_INFORMATION PartitionInfo,
117 PDISK_GEOMETRY DiskGeometry,
118 PUNICODE_STRING Label,
119 BOOLEAN QuickFormat,
120 ULONG ClusterSize,
121 PFORMAT_CONTEXT Context);
122
123 NTSTATUS
124 Fat16Format(HANDLE FileHandle,
125 PPARTITION_INFORMATION PartitionInfo,
126 PDISK_GEOMETRY DiskGeometry,
127 PUNICODE_STRING Label,
128 BOOLEAN QuickFormat,
129 ULONG ClusterSize,
130 PFORMAT_CONTEXT Context);
131
132 NTSTATUS
133 Fat32Format(HANDLE FileHandle,
134 PPARTITION_INFORMATION PartitionInfo,
135 PDISK_GEOMETRY DiskGeometry,
136 PUNICODE_STRING Label,
137 BOOLEAN QuickFormat,
138 ULONG ClusterSize,
139 PFORMAT_CONTEXT Context);
140
141 VOID
142 UpdateProgress(PFORMAT_CONTEXT Context,
143 ULONG Increment);
144
145 VOID
146 VfatPrint(PCHAR Format, ...);
147
148 /* EOF */