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