[NTFS] Fix 2 Clang-Cl warnings about CurrentKey->IndexEntry->Flags
[reactos.git] / drivers / filesystems / fs_rec / fs_rec.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS File System Recognizer
4 * FILE: drivers/filesystems/fs_rec/fs_rec.h
5 * PURPOSE: Main Header File
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 * Eric Kohl
8 */
9
10 #ifndef _FS_REC_H
11 #define _FS_REC_H
12
13 #include <ntifs.h>
14
15 /* Tag for memory allocations */
16 #define FSREC_TAG 'cRsF'
17
18 /* UDFS Offsets */
19 #define UDFS_VRS_START_OFFSET 32768
20 #define UDFS_AVDP_SECTOR 256
21
22 /* Non-standard rounding macros */
23 #ifndef ROUND_UP
24 #define ROUND_UP(n, align) \
25 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
26
27 #define ROUND_DOWN(n, align) \
28 (((ULONG)n) & ~((align) - 1l))
29 #endif
30
31 /* Conversion types and macros taken from internal ntifs headers */
32 typedef union _UCHAR1
33 {
34 UCHAR Uchar[1];
35 UCHAR ForceAlignment;
36 } UCHAR1, *PUCHAR1;
37
38 typedef union _UCHAR2
39 {
40 UCHAR Uchar[2];
41 USHORT ForceAlignment;
42 } UCHAR2, *PUCHAR2;
43
44 typedef union _UCHAR4
45 {
46 UCHAR Uchar[4];
47 ULONG ForceAlignment;
48 } UCHAR4, *PUCHAR4;
49
50 #define CopyUchar1(Dst,Src) { \
51 *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
52 }
53
54 #define CopyUchar2(Dst,Src) { \
55 *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
56 }
57
58 #define CopyUchar4(Dst,Src) { \
59 *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
60 }
61
62 #define FatUnpackBios(Bios,Pbios) { \
63 CopyUchar2(&(Bios)->BytesPerSector, &(Pbios)->BytesPerSector[0] ); \
64 CopyUchar1(&(Bios)->SectorsPerCluster, &(Pbios)->SectorsPerCluster[0]); \
65 CopyUchar2(&(Bios)->ReservedSectors, &(Pbios)->ReservedSectors[0] ); \
66 CopyUchar1(&(Bios)->Fats, &(Pbios)->Fats[0] ); \
67 CopyUchar2(&(Bios)->RootEntries, &(Pbios)->RootEntries[0] ); \
68 CopyUchar2(&(Bios)->Sectors, &(Pbios)->Sectors[0] ); \
69 CopyUchar1(&(Bios)->Media, &(Pbios)->Media[0] ); \
70 CopyUchar2(&(Bios)->SectorsPerFat, &(Pbios)->SectorsPerFat[0] ); \
71 CopyUchar2(&(Bios)->SectorsPerTrack, &(Pbios)->SectorsPerTrack[0] ); \
72 CopyUchar2(&(Bios)->Heads, &(Pbios)->Heads[0] ); \
73 CopyUchar4(&(Bios)->HiddenSectors, &(Pbios)->HiddenSectors[0] ); \
74 CopyUchar4(&(Bios)->LargeSectors, &(Pbios)->LargeSectors[0] ); \
75 }
76
77 /* Packed versions of the BPB and Boot Sector */
78 typedef struct _PACKED_BIOS_PARAMETER_BLOCK
79 {
80 UCHAR BytesPerSector[2];
81 UCHAR SectorsPerCluster[1];
82 UCHAR ReservedSectors[2];
83 UCHAR Fats[1];
84 UCHAR RootEntries[2];
85 UCHAR Sectors[2];
86 UCHAR Media[1];
87 UCHAR SectorsPerFat[2];
88 UCHAR SectorsPerTrack[2];
89 UCHAR Heads[2];
90 UCHAR HiddenSectors[4];
91 UCHAR LargeSectors[4];
92 } PACKED_BIOS_PARAMETER_BLOCK, *PPACKED_BIOS_PARAMETER_BLOCK;
93
94 typedef struct _PACKED_BOOT_SECTOR
95 {
96 UCHAR Jump[3];
97 UCHAR Oem[8];
98 PACKED_BIOS_PARAMETER_BLOCK PackedBpb;
99 UCHAR PhysicalDriveNumber;
100 UCHAR CurrentHead;
101 UCHAR Signature;
102 UCHAR Id[4];
103 UCHAR VolumeLabel[11];
104 UCHAR SystemId[8];
105 } PACKED_BOOT_SECTOR, *PPACKED_BOOT_SECTOR;
106
107 /* Unpacked version of the BPB */
108 typedef struct BIOS_PARAMETER_BLOCK
109 {
110 USHORT BytesPerSector;
111 UCHAR SectorsPerCluster;
112 USHORT ReservedSectors;
113 UCHAR Fats;
114 USHORT RootEntries;
115 USHORT Sectors;
116 UCHAR Media;
117 USHORT SectorsPerFat;
118 USHORT SectorsPerTrack;
119 USHORT Heads;
120 ULONG32 HiddenSectors;
121 ULONG32 LargeSectors;
122 ULONG32 LargeSectorsPerFat;
123 union
124 {
125 USHORT ExtendedFlags;
126 struct
127 {
128 ULONG ActiveFat:4;
129 ULONG Reserved0:3;
130 ULONG MirrorDisabled:1;
131 ULONG Reserved1:8;
132 };
133 };
134 USHORT FsVersion;
135 ULONG32 RootDirFirstCluster;
136 USHORT FsInfoSector;
137 USHORT BackupBootSector;
138 } BIOS_PARAMETER_BLOCK, *PBIOS_PARAMETER_BLOCK;
139
140 /* UDFS Structures */
141 #include <pshpack1.h>
142 typedef struct _TAG
143 {
144 USHORT Identifier;
145 USHORT Version;
146 UCHAR Checksum;
147 UCHAR Reserved;
148 USHORT SerialNumber;
149 USHORT Crc;
150 USHORT CrcLength;
151 ULONG Location;
152 } TAG, *PTAG;
153
154 typedef struct _EXTENT
155 {
156 ULONG Length;
157 ULONG Location;
158 } EXTENT, *PEXTENT;
159
160 typedef struct _AVDP
161 {
162 TAG DescriptorTag;
163 EXTENT MainVolumeDescriptorExtent;
164 EXTENT ReserveVolumeDescriptorExtent;
165 } AVDP, *PAVDP;
166 #include <poppack.h>
167
168 /* Filesystem Types */
169 typedef enum _FILE_SYSTEM_TYPE
170 {
171 FS_TYPE_UNUSED,
172 FS_TYPE_VFAT,
173 FS_TYPE_NTFS,
174 FS_TYPE_CDFS,
175 FS_TYPE_UDFS,
176 FS_TYPE_EXT2,
177 FS_TYPE_BTRFS,
178 FS_TYPE_REISERFS,
179 FS_TYPE_FFS,
180 } FILE_SYSTEM_TYPE, *PFILE_SYSTEM_TYPE;
181
182 /* FS Recognizer State */
183 typedef enum _FS_REC_STATE
184 {
185 Pending,
186 Loaded,
187 Unloading
188 } FS_REC_STATE, *PFS_REC_STATE;
189
190 /* Device extension */
191 typedef struct _DEVICE_EXTENSION
192 {
193 FS_REC_STATE State;
194 FILE_SYSTEM_TYPE FsType;
195 PDEVICE_OBJECT Alternate;
196 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
197
198 /* Prototypes */
199 NTSTATUS
200 NTAPI
201 FsRecCdfsFsControl(
202 IN PDEVICE_OBJECT DeviceObject,
203 IN PIRP Irp
204 );
205
206 NTSTATUS
207 NTAPI
208 FsRecVfatFsControl(
209 IN PDEVICE_OBJECT DeviceObject,
210 IN PIRP Irp
211 );
212
213 NTSTATUS
214 NTAPI
215 FsRecNtfsFsControl(
216 IN PDEVICE_OBJECT DeviceObject,
217 IN PIRP Irp
218 );
219
220 NTSTATUS
221 NTAPI
222 FsRecUdfsFsControl(
223 IN PDEVICE_OBJECT DeviceObject,
224 IN PIRP Irp
225 );
226
227 NTSTATUS
228 NTAPI
229 FsRecExt2FsControl(
230 IN PDEVICE_OBJECT DeviceObject,
231 IN PIRP Irp
232 );
233
234 NTSTATUS
235 NTAPI
236 FsRecBtrfsFsControl(
237 IN PDEVICE_OBJECT DeviceObject,
238 IN PIRP Irp
239 );
240
241 NTSTATUS
242 NTAPI
243 FsRecReiserfsFsControl(
244 IN PDEVICE_OBJECT DeviceObject,
245 IN PIRP Irp
246 );
247
248 NTSTATUS
249 NTAPI
250 FsRecFfsFsControl(
251 IN PDEVICE_OBJECT DeviceObject,
252 IN PIRP Irp
253 );
254
255 BOOLEAN
256 NTAPI
257 FsRecGetDeviceSectors(
258 IN PDEVICE_OBJECT DeviceObject,
259 IN ULONG SectorSize,
260 OUT PLARGE_INTEGER SectorCount
261 );
262
263 BOOLEAN
264 NTAPI
265 FsRecGetDeviceSectorSize(
266 IN PDEVICE_OBJECT DeviceObject,
267 OUT PULONG SectorSize
268 );
269
270 BOOLEAN
271 NTAPI
272 FsRecReadBlock(
273 IN PDEVICE_OBJECT DeviceObject,
274 IN PLARGE_INTEGER Offset,
275 IN ULONG Length,
276 IN ULONG SectorSize,
277 IN OUT PVOID *Buffer,
278 OUT PBOOLEAN DeviceError OPTIONAL
279 );
280
281 NTSTATUS
282 NTAPI
283 FsRecLoadFileSystem(
284 IN PDEVICE_OBJECT DeviceObject,
285 IN PWCHAR DriverServiceName
286 );
287
288 #endif /* _FS_REC_H */