Sync with trunk (r48545)
[reactos.git] / drivers / filesystems / fastfat_new / fastfat.h
1 #include <ntifs.h>
2 #include <bugcodes.h>
3 #include <ntdddisk.h>
4 #include <debug.h>
5 #include <pseh/pseh2.h>
6
7 #include "fullfat.h"
8
9 #include <fat.h>
10 #include <fatstruc.h>
11
12 #define Add2Ptr(P,I,T) ((T)((PUCHAR)(P) + (I)))
13 #define PtrOffset(B,O) ((ULONG)((ULONG_PTR)(O) - (ULONG_PTR)(B)))
14
15 #define TAG_CCB 'BCCV'
16 #define TAG_FCB 'BCFV'
17 #define TAG_IRP 'PRIV'
18 #define TAG_VFAT 'TAFV'
19 #define TAG_FSD_CLOSE_CONTEXT 'CLCV'
20
21
22 /* Global resource acquire/release */
23 #define FatAcquireExclusiveGlobal(IrpContext) \
24 ( \
25 ExAcquireResourceExclusiveLite(&FatGlobalData.Resource, \
26 (IrpContext)->Flags & IRPCONTEXT_CANWAIT) \
27 )
28
29 #define FatAcquireSharedGlobal(IrpContext) \
30 ( \
31 ExAcquireResourceSharedLite(&FatGlobalData.Resource, \
32 (IrpContext)->Flags & IRPCONTEXT_CANWAIT) \
33 )
34
35 #define FatReleaseGlobal(IrpContext) \
36 { \
37 ExReleaseResourceLite(&(FatGlobalData.Resource)); \
38 }
39
40 #define FatIsFastIoPossible(FCB) ((BOOLEAN) \
41 (((FCB)->Condition != FcbGood || !FsRtlOplockIsFastIoPossible(&(FCB)->Fcb.Oplock)) ? \
42 FastIoIsNotPossible \
43 : \
44 (!FsRtlAreThereCurrentFileLocks(&(FCB)->Fcb.Lock) && \
45 ((FCB)->OutstandingAsyncWrites == 0) && \
46 !FlagOn((FCB)->Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED) ? \
47 FastIoIsPossible \
48 : \
49 FastIoIsQuestionable \
50 ) \
51 ) \
52 )
53
54 #define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
55 #define IsFileDeleted(FCB) (FlagOn((FCB)->State, FCB_STATE_DELETE_ON_CLOSE) && ((FCB)->UncleanCount == 0))
56
57 BOOLEAN
58 FORCEINLINE
59 FatIsIoRangeValid(IN LARGE_INTEGER Start, IN ULONG Length)
60 {
61 /* Check if it's more than 32bits, or if the length causes 32bit overflow.
62 FAT-specific! */
63
64 return !(Start.HighPart || Start.LowPart + Length < Start.LowPart);
65 }
66
67
68 NTSYSAPI
69 NTSTATUS
70 NTAPI
71 RtlUpcaseUnicodeStringToCountedOemString(
72 IN OUT POEM_STRING DestinationString,
73 IN PCUNICODE_STRING SourceString,
74 IN BOOLEAN AllocateDestinationString
75 );
76
77
78 /* ------------------------------------------------------ shutdown.c */
79
80 DRIVER_DISPATCH FatShutdown;
81 NTSTATUS NTAPI
82 FatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp);
83
84 /* -------------------------------------------------------- volume.c */
85
86 NTSTATUS NTAPI
87 FatQueryVolumeInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp);
88
89 NTSTATUS NTAPI
90 FatSetVolumeInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp);
91
92 VOID NTAPI
93 FatReadStreamFile(PVCB Vcb,
94 ULONGLONG ByteOffset,
95 ULONG ByteSize,
96 PBCB *Bcb,
97 PVOID *Buffer);
98
99 BOOLEAN
100 NTAPI
101 FatCheckForDismount(IN PFAT_IRP_CONTEXT IrpContext,
102 PVCB Vcb,
103 IN BOOLEAN Force);
104
105 /* ----------------------------------------------------------- dir.c */
106
107 NTSTATUS NTAPI
108 FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
109
110 VOID NTAPI
111 FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
112 IN PVCB Vcb);
113
114 PFCB NTAPI
115 FatCreateDcb(IN PFAT_IRP_CONTEXT IrpContext,
116 IN PVCB Vcb,
117 IN PFCB ParentDcb,
118 IN FF_FILE *FileHandle);
119
120 IO_STATUS_BLOCK NTAPI
121 FatiOpenExistingDcb(IN PFAT_IRP_CONTEXT IrpContext,
122 IN PFILE_OBJECT FileObject,
123 IN PVCB Vcb,
124 IN PFCB Dcb,
125 IN PACCESS_MASK DesiredAccess,
126 IN USHORT ShareAccess,
127 IN ULONG CreateDisposition,
128 IN BOOLEAN NoEaKnowledge,
129 IN BOOLEAN DeleteOnClose);
130
131 /* -------------------------------------------------------- create.c */
132
133 IO_STATUS_BLOCK
134 NTAPI
135 FatiOverwriteFile(PFAT_IRP_CONTEXT IrpContext,
136 PFILE_OBJECT FileObject,
137 PFCB Fcb,
138 ULONG AllocationSize,
139 PFILE_FULL_EA_INFORMATION EaBuffer,
140 ULONG EaLength,
141 UCHAR FileAttributes,
142 ULONG CreateDisposition,
143 BOOLEAN NoEaKnowledge);
144
145 NTSTATUS NTAPI
146 FatCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
147
148
149 /* --------------------------------------------------------- close.c */
150
151 NTSTATUS NTAPI
152 FatClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
153
154 /* ------------------------------------------------------- cleanup.c */
155
156 NTSTATUS NTAPI
157 FatCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp);
158
159 /* --------------------------------------------------------- fastio.c */
160
161 VOID
162 FatInitFastIoRoutines(PFAST_IO_DISPATCH FastIoDispatch);
163
164 BOOLEAN NTAPI
165 FatAcquireForLazyWrite(IN PVOID Context,
166 IN BOOLEAN Wait);
167
168 VOID NTAPI
169 FatReleaseFromLazyWrite(IN PVOID Context);
170
171 BOOLEAN NTAPI
172 FatAcquireForReadAhead(IN PVOID Context,
173 IN BOOLEAN Wait);
174
175 VOID NTAPI
176 FatReleaseFromReadAhead(IN PVOID Context);
177
178 BOOLEAN NTAPI
179 FatNoopAcquire(IN PVOID Context,
180 IN BOOLEAN Wait);
181
182 VOID NTAPI
183 FatNoopRelease(IN PVOID Context);
184
185 /* --------------------------------------------------------- fastfat.c */
186
187 extern FAST_MUTEX FatCloseQueueMutex;
188
189 PFAT_IRP_CONTEXT NTAPI
190 FatBuildIrpContext(PIRP Irp, BOOLEAN CanWait);
191
192 VOID NTAPI
193 FatDestroyIrpContext(PFAT_IRP_CONTEXT IrpContext);
194
195 VOID
196 NTAPI
197 FatQueueRequest(IN PFAT_IRP_CONTEXT IrpContext,
198 IN PFAT_OPERATION_HANDLER OperationHandler);
199
200 VOID NTAPI
201 FatCompleteRequest(PFAT_IRP_CONTEXT IrpContext OPTIONAL,
202 PIRP Irp OPTIONAL,
203 NTSTATUS Status);
204
205 BOOLEAN NTAPI
206 FatAcquireExclusiveVcb(IN PFAT_IRP_CONTEXT IrpContext,
207 IN PVCB Vcb);
208
209 BOOLEAN NTAPI
210 FatAcquireSharedVcb(IN PFAT_IRP_CONTEXT IrpContext,
211 IN PVCB Vcb);
212
213 VOID NTAPI
214 FatReleaseVcb(IN PFAT_IRP_CONTEXT IrpContext,
215 IN PVCB Vcb);
216
217 BOOLEAN NTAPI
218 FatAcquireExclusiveFcb(IN PFAT_IRP_CONTEXT IrpContext,
219 IN PFCB Fcb);
220
221 BOOLEAN NTAPI
222 FatAcquireSharedFcb(IN PFAT_IRP_CONTEXT IrpContext,
223 IN PFCB Fcb);
224
225 VOID NTAPI
226 FatReleaseFcb(IN PFAT_IRP_CONTEXT IrpContext,
227 IN PFCB Fcb);
228
229 TYPE_OF_OPEN
230 NTAPI
231 FatDecodeFileObject(IN PFILE_OBJECT FileObject,
232 OUT PVCB *Vcb,
233 OUT PFCB *FcbOrDcb,
234 OUT PCCB *Ccb);
235
236 VOID NTAPI
237 FatSetFileObject(PFILE_OBJECT FileObject,
238 TYPE_OF_OPEN TypeOfOpen,
239 PVOID Fcb,
240 PCCB Ccb);
241
242 PVOID FASTCALL
243 FatMapUserBuffer(PIRP Irp);
244
245 BOOLEAN NTAPI
246 FatIsTopLevelIrp(IN PIRP Irp);
247
248 VOID NTAPI
249 FatNotifyReportChange(IN PFAT_IRP_CONTEXT IrpContext,
250 IN PVCB Vcb,
251 IN PFCB Fcb,
252 IN ULONG Filter,
253 IN ULONG Action);
254
255 /* --------------------------------------------------------- fullfat.c */
256
257 FF_T_SINT32
258 FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
259
260 FF_T_SINT32
261 FatReadBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
262
263 VOID NTAPI
264 FatQueryFileTimes(OUT PLARGE_INTEGER FileTimes,
265 IN PDIR_ENTRY Dirent);
266
267 /* --------------------------------------------------------- lock.c */
268
269 NTSTATUS NTAPI
270 FatLockControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
271
272 VOID NTAPI
273 FatOplockComplete(IN PVOID Context,
274 IN PIRP Irp);
275
276 VOID NTAPI
277 FatPrePostIrp(IN PVOID Context,
278 IN PIRP Irp);
279
280 /* --------------------------------------------------------- fsctl.c */
281
282 NTSTATUS NTAPI
283 FatFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
284
285 /* --------------------------------------------------------- finfo.c */
286
287 NTSTATUS NTAPI FatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
288 NTSTATUS NTAPI FatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
289
290 /* --------------------------------------------------------- fullfat.c */
291
292 FF_FILE *FF_OpenW(FF_IOMAN *pIoman, PUNICODE_STRING pathW, FF_T_UINT8 Mode, FF_ERROR *pError);
293
294 /* --------------------------------------------------------- iface.c */
295
296 NTSTATUS
297 NTAPI
298 DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
299
300 /* ----------------------------------------------------------- fat.c */
301 NTSTATUS NTAPI
302 FatInitializeVcb(
303 IN PFAT_IRP_CONTEXT IrpContext,
304 IN PVCB Vcb,
305 IN PDEVICE_OBJECT TargetDeviceObject,
306 IN PVPB Vpb);
307
308 VOID NTAPI
309 FatUninitializeVcb(
310 IN PVCB Vcb);
311
312 /* ------------------------------------------------------ device.c */
313
314 NTSTATUS NTAPI
315 FatDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
316
317 NTSTATUS
318 FatPerformDevIoCtrl(PDEVICE_OBJECT DeviceObject,
319 ULONG ControlCode,
320 PVOID InputBuffer,
321 ULONG InputBufferSize,
322 PVOID OutputBuffer,
323 ULONG OutputBufferSize,
324 BOOLEAN Override);
325
326 /* ----------------------------------------------------------- fcb.c */
327 PFCB NTAPI
328 FatCreateFcb(
329 IN PFAT_IRP_CONTEXT IrpContext,
330 IN PVCB Vcb,
331 IN PFCB ParentDcb,
332 IN FF_FILE *FileHandle);
333
334 VOID NTAPI
335 FatDeleteFcb(IN PFAT_IRP_CONTEXT IrpContext,
336 IN PFCB Fcb);
337
338 IO_STATUS_BLOCK NTAPI
339 FatiOpenExistingFcb(IN PFAT_IRP_CONTEXT IrpContext,
340 IN PFILE_OBJECT FileObject,
341 IN PVCB Vcb,
342 IN PFCB Fcb,
343 IN PACCESS_MASK DesiredAccess,
344 IN USHORT ShareAccess,
345 IN ULONG AllocationSize,
346 IN PFILE_FULL_EA_INFORMATION EaBuffer,
347 IN ULONG EaLength,
348 IN UCHAR FileAttributes,
349 IN ULONG CreateDisposition,
350 IN BOOLEAN NoEaKnowledge,
351 IN BOOLEAN DeleteOnClose,
352 IN BOOLEAN OpenedAsDos,
353 OUT PBOOLEAN OplockPostIrp);
354
355 PFCB NTAPI
356 FatFindFcb(PFAT_IRP_CONTEXT IrpContext,
357 PRTL_SPLAY_LINKS *RootNode,
358 PSTRING AnsiName,
359 PBOOLEAN IsDosName);
360
361 VOID NTAPI
362 FatInsertName(IN PFAT_IRP_CONTEXT IrpContext,
363 IN PRTL_SPLAY_LINKS *RootNode,
364 IN PFCB_NAME_LINK Name);
365
366 VOID NTAPI
367 FatRemoveNames(IN PFAT_IRP_CONTEXT IrpContext,
368 IN PFCB Fcb);
369
370 PCCB NTAPI
371 FatCreateCcb();
372
373 VOID NTAPI
374 FatDeleteCcb(IN PFAT_IRP_CONTEXT IrpContext,
375 IN PCCB Ccb);
376
377 VOID NTAPI
378 FatSetFullNameInFcb(PFCB Fcb,
379 PUNICODE_STRING Name);
380
381 VOID NTAPI
382 FatSetFullFileNameInFcb(IN PFAT_IRP_CONTEXT IrpContext,
383 IN PFCB Fcb);
384
385 VOID NTAPI
386 FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
387 IN PFCB Fcb);
388
389 VOID NTAPI
390 Fati8dot3ToString(IN PCHAR FileName,
391 IN BOOLEAN DownCase,
392 OUT POEM_STRING OutString);
393
394 /* ------------------------------------------------------------ rw.c */
395
396 NTSTATUS NTAPI
397 FatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
398
399 NTSTATUS NTAPI
400 FatWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
401
402 /* ------------------------------------------------------------- flush.c */
403
404 NTSTATUS NTAPI
405 FatFlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp);
406
407
408 /* EOF */