1 /*
2 * PROJECT: VFAT Filesystem
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Fast IO routines
5 * COPYRIGHT: Copyright 2005 Hervé Poussineau <hpoussin@reactos.org>
6 * Copyright 2015-2018 Pierre Schweitzer <pierre@reactos.org>
7 */
8
9 #include "vfat.h"
10
11 #define NDEBUG
12 #include <debug.h>
13
14 static FAST_IO_CHECK_IF_POSSIBLE VfatFastIoCheckIfPossible;
15
16 static
17 BOOLEAN
18 NTAPI
VfatFastIoCheckIfPossible(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN BOOLEAN Wait,IN ULONG LockKey,IN BOOLEAN CheckForReadOperation,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)19 VfatFastIoCheckIfPossible(
20 IN PFILE_OBJECT FileObject,
21 IN PLARGE_INTEGER FileOffset,
22 IN ULONG Length,
23 IN BOOLEAN Wait,
24 IN ULONG LockKey,
25 IN BOOLEAN CheckForReadOperation,
26 OUT PIO_STATUS_BLOCK IoStatus,
27 IN PDEVICE_OBJECT DeviceObject)
28 {
29 /* Prevent all Fast I/O requests */
30 DPRINT("VfatFastIoCheckIfPossible(): returning FALSE.\n");
31
32 UNREFERENCED_PARAMETER(FileObject);
33 UNREFERENCED_PARAMETER(FileOffset);
34 UNREFERENCED_PARAMETER(Length);
35 UNREFERENCED_PARAMETER(Wait);
36 UNREFERENCED_PARAMETER(LockKey);
37 UNREFERENCED_PARAMETER(CheckForReadOperation);
38 UNREFERENCED_PARAMETER(IoStatus);
39 UNREFERENCED_PARAMETER(DeviceObject);
40
41 return FALSE;
42 }
43
44 static FAST_IO_READ VfatFastIoRead;
45
46 static
47 BOOLEAN
48 NTAPI
VfatFastIoRead(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN BOOLEAN Wait,IN ULONG LockKey,OUT PVOID Buffer,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)49 VfatFastIoRead(
50 IN PFILE_OBJECT FileObject,
51 IN PLARGE_INTEGER FileOffset,
52 IN ULONG Length,
53 IN BOOLEAN Wait,
54 IN ULONG LockKey,
55 OUT PVOID Buffer,
56 OUT PIO_STATUS_BLOCK IoStatus,
57 IN PDEVICE_OBJECT DeviceObject)
58 {
59 DPRINT("VfatFastIoRead()\n");
60
61 UNREFERENCED_PARAMETER(FileObject);
62 UNREFERENCED_PARAMETER(FileOffset);
63 UNREFERENCED_PARAMETER(Length);
64 UNREFERENCED_PARAMETER(Wait);
65 UNREFERENCED_PARAMETER(LockKey);
66 UNREFERENCED_PARAMETER(Buffer);
67 UNREFERENCED_PARAMETER(IoStatus);
68 UNREFERENCED_PARAMETER(DeviceObject);
69
70 return FALSE;
71 }
72
73 static FAST_IO_WRITE VfatFastIoWrite;
74
75 static
76 BOOLEAN
77 NTAPI
VfatFastIoWrite(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN BOOLEAN Wait,IN ULONG LockKey,OUT PVOID Buffer,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)78 VfatFastIoWrite(
79 IN PFILE_OBJECT FileObject,
80 IN PLARGE_INTEGER FileOffset,
81 IN ULONG Length,
82 IN BOOLEAN Wait,
83 IN ULONG LockKey,
84 OUT PVOID Buffer,
85 OUT PIO_STATUS_BLOCK IoStatus,
86 IN PDEVICE_OBJECT DeviceObject)
87 {
88 DPRINT("VfatFastIoWrite()\n");
89
90 UNREFERENCED_PARAMETER(FileObject);
91 UNREFERENCED_PARAMETER(FileOffset);
92 UNREFERENCED_PARAMETER(Length);
93 UNREFERENCED_PARAMETER(Wait);
94 UNREFERENCED_PARAMETER(LockKey);
95 UNREFERENCED_PARAMETER(Buffer);
96 UNREFERENCED_PARAMETER(IoStatus);
97 UNREFERENCED_PARAMETER(DeviceObject);
98
99 return FALSE;
100 }
101
102 static FAST_IO_QUERY_BASIC_INFO VfatFastIoQueryBasicInfo;
103
104 static
105 BOOLEAN
106 NTAPI
VfatFastIoQueryBasicInfo(IN PFILE_OBJECT FileObject,IN BOOLEAN Wait,OUT PFILE_BASIC_INFORMATION Buffer,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)107 VfatFastIoQueryBasicInfo(
108 IN PFILE_OBJECT FileObject,
109 IN BOOLEAN Wait,
110 OUT PFILE_BASIC_INFORMATION Buffer,
111 OUT PIO_STATUS_BLOCK IoStatus,
112 IN PDEVICE_OBJECT DeviceObject)
113 {
114 NTSTATUS Status;
115 PVFATFCB FCB = NULL;
116 BOOLEAN Success = FALSE;
117 ULONG BufferLength = sizeof(FILE_BASIC_INFORMATION);
118
119 DPRINT("VfatFastIoQueryBasicInfo()\n");
120
121 FCB = (PVFATFCB)FileObject->FsContext;
122 if (FCB == NULL)
123 {
124 return FALSE;
125 }
126
127 FsRtlEnterFileSystem();
128
129 if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
130 {
131 if (!ExAcquireResourceSharedLite(&FCB->MainResource, Wait))
132 {
133 FsRtlExitFileSystem();
134 return FALSE;
135 }
136 }
137
138 Status = VfatGetBasicInformation(FileObject,
139 FCB,
140 DeviceObject->DeviceExtension,
141 Buffer,
142 &BufferLength);
143
144 if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
145 {
146 ExReleaseResourceLite(&FCB->MainResource);
147 }
148
149 if (NT_SUCCESS(Status))
150 {
151 IoStatus->Status = STATUS_SUCCESS;
152 IoStatus->Information = sizeof(FILE_BASIC_INFORMATION) - BufferLength;
153 Success = TRUE;
154 }
155
156 FsRtlExitFileSystem();
157
158 return Success;
159 }
160
161 static FAST_IO_QUERY_STANDARD_INFO VfatFastIoQueryStandardInfo;
162
163 static
164 BOOLEAN
165 NTAPI
VfatFastIoQueryStandardInfo(IN PFILE_OBJECT FileObject,IN BOOLEAN Wait,OUT PFILE_STANDARD_INFORMATION Buffer,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)166 VfatFastIoQueryStandardInfo(
167 IN PFILE_OBJECT FileObject,
168 IN BOOLEAN Wait,
169 OUT PFILE_STANDARD_INFORMATION Buffer,
170 OUT PIO_STATUS_BLOCK IoStatus,
171 IN PDEVICE_OBJECT DeviceObject)
172 {
173 NTSTATUS Status;
174 PVFATFCB FCB = NULL;
175 BOOLEAN Success = FALSE;
176 ULONG BufferLength = sizeof(FILE_STANDARD_INFORMATION);
177
178 DPRINT("VfatFastIoQueryStandardInfo()\n");
179
180 UNREFERENCED_PARAMETER(DeviceObject);
181
182 FCB = (PVFATFCB)FileObject->FsContext;
183 if (FCB == NULL)
184 {
185 return FALSE;
186 }
187
188 FsRtlEnterFileSystem();
189
190 if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
191 {
192 if (!ExAcquireResourceSharedLite(&FCB->MainResource, Wait))
193 {
194 FsRtlExitFileSystem();
195 return FALSE;
196 }
197 }
198
199 Status = VfatGetStandardInformation(FCB,
200 Buffer,
201 &BufferLength);
202
203 if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
204 {
205 ExReleaseResourceLite(&FCB->MainResource);
206 }
207
208 if (NT_SUCCESS(Status))
209 {
210 IoStatus->Status = STATUS_SUCCESS;
211 IoStatus->Information = sizeof(FILE_STANDARD_INFORMATION) - BufferLength;
212 Success = TRUE;
213 }
214
215 FsRtlExitFileSystem();
216
217 return Success;
218 }
219
220 static FAST_IO_LOCK VfatFastIoLock;
221
222 static
223 BOOLEAN
224 NTAPI
VfatFastIoLock(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN PLARGE_INTEGER Length,PEPROCESS ProcessId,ULONG Key,BOOLEAN FailImmediately,BOOLEAN ExclusiveLock,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)225 VfatFastIoLock(
226 IN PFILE_OBJECT FileObject,
227 IN PLARGE_INTEGER FileOffset,
228 IN PLARGE_INTEGER Length,
229 PEPROCESS ProcessId,
230 ULONG Key,
231 BOOLEAN FailImmediately,
232 BOOLEAN ExclusiveLock,
233 OUT PIO_STATUS_BLOCK IoStatus,
234 IN PDEVICE_OBJECT DeviceObject)
235 {
236 DPRINT("VfatFastIoLock\n");
237
238 UNREFERENCED_PARAMETER(FileObject);
239 UNREFERENCED_PARAMETER(FileOffset);
240 UNREFERENCED_PARAMETER(Length);
241 UNREFERENCED_PARAMETER(ProcessId);
242 UNREFERENCED_PARAMETER(Key);
243 UNREFERENCED_PARAMETER(FailImmediately);
244 UNREFERENCED_PARAMETER(ExclusiveLock);
245 UNREFERENCED_PARAMETER(IoStatus);
246 UNREFERENCED_PARAMETER(DeviceObject);
247
248 return FALSE;
249 }
250
251 static FAST_IO_UNLOCK_SINGLE VfatFastIoUnlockSingle;
252
253 static
254 BOOLEAN
255 NTAPI
VfatFastIoUnlockSingle(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN PLARGE_INTEGER Length,PEPROCESS ProcessId,ULONG Key,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)256 VfatFastIoUnlockSingle(
257 IN PFILE_OBJECT FileObject,
258 IN PLARGE_INTEGER FileOffset,
259 IN PLARGE_INTEGER Length,
260 PEPROCESS ProcessId,
261 ULONG Key,
262 OUT PIO_STATUS_BLOCK IoStatus,
263 IN PDEVICE_OBJECT DeviceObject)
264 {
265 DPRINT("VfatFastIoUnlockSingle\n");
266
267 UNREFERENCED_PARAMETER(FileObject);
268 UNREFERENCED_PARAMETER(FileOffset);
269 UNREFERENCED_PARAMETER(Length);
270 UNREFERENCED_PARAMETER(ProcessId);
271 UNREFERENCED_PARAMETER(Key);
272 UNREFERENCED_PARAMETER(IoStatus);
273 UNREFERENCED_PARAMETER(DeviceObject);
274
275 return FALSE;
276 }
277
278 static FAST_IO_UNLOCK_ALL VfatFastIoUnlockAll;
279
280 static
281 BOOLEAN
282 NTAPI
VfatFastIoUnlockAll(IN PFILE_OBJECT FileObject,PEPROCESS ProcessId,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)283 VfatFastIoUnlockAll(
284 IN PFILE_OBJECT FileObject,
285 PEPROCESS ProcessId,
286 OUT PIO_STATUS_BLOCK IoStatus,
287 IN PDEVICE_OBJECT DeviceObject)
288 {
289 DPRINT("VfatFastIoUnlockAll\n");
290
291 UNREFERENCED_PARAMETER(FileObject);
292 UNREFERENCED_PARAMETER(ProcessId);
293 UNREFERENCED_PARAMETER(IoStatus);
294 UNREFERENCED_PARAMETER(DeviceObject);
295
296 return FALSE;
297 }
298
299 static FAST_IO_UNLOCK_ALL_BY_KEY VfatFastIoUnlockAllByKey;
300
301 static
302 BOOLEAN
303 NTAPI
VfatFastIoUnlockAllByKey(IN PFILE_OBJECT FileObject,PVOID ProcessId,ULONG Key,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)304 VfatFastIoUnlockAllByKey(
305 IN PFILE_OBJECT FileObject,
306 PVOID ProcessId,
307 ULONG Key,
308 OUT PIO_STATUS_BLOCK IoStatus,
309 IN PDEVICE_OBJECT DeviceObject)
310 {
311 DPRINT("VfatFastIoUnlockAllByKey\n");
312
313 UNREFERENCED_PARAMETER(FileObject);
314 UNREFERENCED_PARAMETER(ProcessId);
315 UNREFERENCED_PARAMETER(Key);
316 UNREFERENCED_PARAMETER(IoStatus);
317 UNREFERENCED_PARAMETER(DeviceObject);
318
319 return FALSE;
320 }
321
322 static FAST_IO_DEVICE_CONTROL VfatFastIoDeviceControl;
323
324 static
325 BOOLEAN
326 NTAPI
VfatFastIoDeviceControl(IN PFILE_OBJECT FileObject,IN BOOLEAN Wait,IN PVOID InputBuffer OPTIONAL,IN ULONG InputBufferLength,OUT PVOID OutputBuffer OPTIONAL,IN ULONG OutputBufferLength,IN ULONG IoControlCode,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)327 VfatFastIoDeviceControl(
328 IN PFILE_OBJECT FileObject,
329 IN BOOLEAN Wait,
330 IN PVOID InputBuffer OPTIONAL,
331 IN ULONG InputBufferLength,
332 OUT PVOID OutputBuffer OPTIONAL,
333 IN ULONG OutputBufferLength,
334 IN ULONG IoControlCode,
335 OUT PIO_STATUS_BLOCK IoStatus,
336 IN PDEVICE_OBJECT DeviceObject)
337 {
338 DPRINT("VfatFastIoDeviceControl\n");
339
340 UNREFERENCED_PARAMETER(FileObject);
341 UNREFERENCED_PARAMETER(Wait);
342 UNREFERENCED_PARAMETER(InputBuffer);
343 UNREFERENCED_PARAMETER(InputBufferLength);
344 UNREFERENCED_PARAMETER(OutputBuffer);
345 UNREFERENCED_PARAMETER(OutputBufferLength);
346 UNREFERENCED_PARAMETER(IoControlCode);
347 UNREFERENCED_PARAMETER(IoStatus);
348 UNREFERENCED_PARAMETER(DeviceObject);
349
350 return FALSE;
351 }
352
353 static FAST_IO_ACQUIRE_FILE VfatAcquireFileForNtCreateSection;
354
355 static
356 VOID
357 NTAPI
VfatAcquireFileForNtCreateSection(IN PFILE_OBJECT FileObject)358 VfatAcquireFileForNtCreateSection(
359 IN PFILE_OBJECT FileObject)
360 {
361 DPRINT("VfatAcquireFileForNtCreateSection\n");
362 UNREFERENCED_PARAMETER(FileObject);
363 }
364
365 static FAST_IO_RELEASE_FILE VfatReleaseFileForNtCreateSection;
366
367 static
368 VOID
369 NTAPI
VfatReleaseFileForNtCreateSection(IN PFILE_OBJECT FileObject)370 VfatReleaseFileForNtCreateSection(
371 IN PFILE_OBJECT FileObject)
372 {
373 DPRINT("VfatReleaseFileForNtCreateSection\n");
374 UNREFERENCED_PARAMETER(FileObject);
375 }
376
377 static FAST_IO_DETACH_DEVICE VfatFastIoDetachDevice;
378
379 static
380 VOID
381 NTAPI
VfatFastIoDetachDevice(IN PDEVICE_OBJECT SourceDevice,IN PDEVICE_OBJECT TargetDevice)382 VfatFastIoDetachDevice(
383 IN PDEVICE_OBJECT SourceDevice,
384 IN PDEVICE_OBJECT TargetDevice)
385 {
386 DPRINT("VfatFastIoDetachDevice\n");
387 UNREFERENCED_PARAMETER(SourceDevice);
388 UNREFERENCED_PARAMETER(TargetDevice);
389 }
390
391 static FAST_IO_QUERY_NETWORK_OPEN_INFO VfatFastIoQueryNetworkOpenInfo;
392
393 static
394 BOOLEAN
395 NTAPI
VfatFastIoQueryNetworkOpenInfo(IN PFILE_OBJECT FileObject,IN BOOLEAN Wait,OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)396 VfatFastIoQueryNetworkOpenInfo(
397 IN PFILE_OBJECT FileObject,
398 IN BOOLEAN Wait,
399 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
400 OUT PIO_STATUS_BLOCK IoStatus,
401 IN PDEVICE_OBJECT DeviceObject)
402 {
403 DPRINT("VfatFastIoQueryNetworkOpenInfo\n");
404
405 UNREFERENCED_PARAMETER(FileObject);
406 UNREFERENCED_PARAMETER(Wait);
407 UNREFERENCED_PARAMETER(Buffer);
408 UNREFERENCED_PARAMETER(IoStatus);
409 UNREFERENCED_PARAMETER(DeviceObject);
410
411 return FALSE;
412 }
413
414 static FAST_IO_ACQUIRE_FOR_MOD_WRITE VfatAcquireForModWrite;
415
416 static
417 NTSTATUS
418 NTAPI
VfatAcquireForModWrite(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER EndingOffset,OUT PERESOURCE * ResourceToRelease,IN PDEVICE_OBJECT DeviceObject)419 VfatAcquireForModWrite(
420 IN PFILE_OBJECT FileObject,
421 IN PLARGE_INTEGER EndingOffset,
422 OUT PERESOURCE* ResourceToRelease,
423 IN PDEVICE_OBJECT DeviceObject)
424 {
425 DPRINT("VfatAcquireForModWrite\n");
426
427 UNREFERENCED_PARAMETER(FileObject);
428 UNREFERENCED_PARAMETER(EndingOffset);
429 UNREFERENCED_PARAMETER(ResourceToRelease);
430 UNREFERENCED_PARAMETER(DeviceObject);
431
432 return STATUS_INVALID_DEVICE_REQUEST;
433 }
434
435 static FAST_IO_MDL_READ VfatMdlRead;
436
437 static
438 BOOLEAN
439 NTAPI
VfatMdlRead(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN ULONG LockKey,OUT PMDL * MdlChain,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)440 VfatMdlRead(
441 IN PFILE_OBJECT FileObject,
442 IN PLARGE_INTEGER FileOffset,
443 IN ULONG Length,
444 IN ULONG LockKey,
445 OUT PMDL* MdlChain,
446 OUT PIO_STATUS_BLOCK IoStatus,
447 IN PDEVICE_OBJECT DeviceObject)
448 {
449 DPRINT("VfatMdlRead\n");
450
451 UNREFERENCED_PARAMETER(FileObject);
452 UNREFERENCED_PARAMETER(FileOffset);
453 UNREFERENCED_PARAMETER(Length);
454 UNREFERENCED_PARAMETER(LockKey);
455 UNREFERENCED_PARAMETER(MdlChain);
456 UNREFERENCED_PARAMETER(IoStatus);
457 UNREFERENCED_PARAMETER(DeviceObject);
458
459 return FALSE;
460 }
461
462 static FAST_IO_MDL_READ_COMPLETE VfatMdlReadComplete;
463
464 static
465 BOOLEAN
466 NTAPI
VfatMdlReadComplete(IN PFILE_OBJECT FileObject,IN PMDL MdlChain,IN PDEVICE_OBJECT DeviceObject)467 VfatMdlReadComplete(
468 IN PFILE_OBJECT FileObject,
469 IN PMDL MdlChain,
470 IN PDEVICE_OBJECT DeviceObject)
471 {
472 DPRINT("VfatMdlReadComplete\n");
473
474 UNREFERENCED_PARAMETER(FileObject);
475 UNREFERENCED_PARAMETER(MdlChain);
476 UNREFERENCED_PARAMETER(DeviceObject);
477
478 return FALSE;
479 }
480
481 static FAST_IO_PREPARE_MDL_WRITE VfatPrepareMdlWrite;
482
483 static
484 BOOLEAN
485 NTAPI
VfatPrepareMdlWrite(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN ULONG LockKey,OUT PMDL * MdlChain,OUT PIO_STATUS_BLOCK IoStatus,IN PDEVICE_OBJECT DeviceObject)486 VfatPrepareMdlWrite(
487 IN PFILE_OBJECT FileObject,
488 IN PLARGE_INTEGER FileOffset,
489 IN ULONG Length,
490 IN ULONG LockKey,
491 OUT PMDL* MdlChain,
492 OUT PIO_STATUS_BLOCK IoStatus,
493 IN PDEVICE_OBJECT DeviceObject)
494 {
495 DPRINT("VfatPrepareMdlWrite\n");
496
497 UNREFERENCED_PARAMETER(FileObject);
498 UNREFERENCED_PARAMETER(FileOffset);
499 UNREFERENCED_PARAMETER(Length);
500 UNREFERENCED_PARAMETER(LockKey);
501 UNREFERENCED_PARAMETER(MdlChain);
502 UNREFERENCED_PARAMETER(IoStatus);
503 UNREFERENCED_PARAMETER(DeviceObject);
504
505 return FALSE;
506 }
507
508 static FAST_IO_MDL_WRITE_COMPLETE VfatMdlWriteComplete;
509
510 static
511 BOOLEAN
512 NTAPI
VfatMdlWriteComplete(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN PMDL MdlChain,IN PDEVICE_OBJECT DeviceObject)513 VfatMdlWriteComplete(
514 IN PFILE_OBJECT FileObject,
515 IN PLARGE_INTEGER FileOffset,
516 IN PMDL MdlChain,
517 IN PDEVICE_OBJECT DeviceObject)
518 {
519 DPRINT("VfatMdlWriteComplete\n");
520
521 UNREFERENCED_PARAMETER(FileObject);
522 UNREFERENCED_PARAMETER(FileOffset);
523 UNREFERENCED_PARAMETER(MdlChain);
524 UNREFERENCED_PARAMETER(DeviceObject);
525
526 return FALSE;
527 }
528
529 static FAST_IO_READ_COMPRESSED VfatFastIoReadCompressed;
530
531 static
532 BOOLEAN
533 NTAPI
VfatFastIoReadCompressed(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN ULONG LockKey,OUT PVOID Buffer,OUT PMDL * MdlChain,OUT PIO_STATUS_BLOCK IoStatus,OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,IN ULONG CompressedDataInfoLength,IN PDEVICE_OBJECT DeviceObject)534 VfatFastIoReadCompressed(
535 IN PFILE_OBJECT FileObject,
536 IN PLARGE_INTEGER FileOffset,
537 IN ULONG Length,
538 IN ULONG LockKey,
539 OUT PVOID Buffer,
540 OUT PMDL* MdlChain,
541 OUT PIO_STATUS_BLOCK IoStatus,
542 OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
543 IN ULONG CompressedDataInfoLength,
544 IN PDEVICE_OBJECT DeviceObject)
545 {
546 DPRINT("VfatFastIoReadCompressed\n");
547
548 UNREFERENCED_PARAMETER(FileObject);
549 UNREFERENCED_PARAMETER(FileOffset);
550 UNREFERENCED_PARAMETER(Length);
551 UNREFERENCED_PARAMETER(LockKey);
552 UNREFERENCED_PARAMETER(Buffer);
553 UNREFERENCED_PARAMETER(MdlChain);
554 UNREFERENCED_PARAMETER(IoStatus);
555 UNREFERENCED_PARAMETER(CompressedDataInfo);
556 UNREFERENCED_PARAMETER(CompressedDataInfoLength);
557 UNREFERENCED_PARAMETER(DeviceObject);
558
559 return FALSE;
560 }
561
562 static FAST_IO_WRITE_COMPRESSED VfatFastIoWriteCompressed;
563
564 static
565 BOOLEAN
566 NTAPI
VfatFastIoWriteCompressed(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN ULONG Length,IN ULONG LockKey,IN PVOID Buffer,OUT PMDL * MdlChain,OUT PIO_STATUS_BLOCK IoStatus,IN PCOMPRESSED_DATA_INFO CompressedDataInfo,IN ULONG CompressedDataInfoLength,IN PDEVICE_OBJECT DeviceObject)567 VfatFastIoWriteCompressed(
568 IN PFILE_OBJECT FileObject,
569 IN PLARGE_INTEGER FileOffset,
570 IN ULONG Length,
571 IN ULONG LockKey,
572 IN PVOID Buffer,
573 OUT PMDL* MdlChain,
574 OUT PIO_STATUS_BLOCK IoStatus,
575 IN PCOMPRESSED_DATA_INFO CompressedDataInfo,
576 IN ULONG CompressedDataInfoLength,
577 IN PDEVICE_OBJECT DeviceObject)
578 {
579 DPRINT("VfatFastIoWriteCompressed\n");
580
581 UNREFERENCED_PARAMETER(FileObject);
582 UNREFERENCED_PARAMETER(FileOffset);
583 UNREFERENCED_PARAMETER(Length);
584 UNREFERENCED_PARAMETER(LockKey);
585 UNREFERENCED_PARAMETER(Buffer);
586 UNREFERENCED_PARAMETER(MdlChain);
587 UNREFERENCED_PARAMETER(IoStatus);
588 UNREFERENCED_PARAMETER(CompressedDataInfo);
589 UNREFERENCED_PARAMETER(CompressedDataInfoLength);
590 UNREFERENCED_PARAMETER(DeviceObject);
591
592 return FALSE;
593 }
594
595 static FAST_IO_MDL_READ_COMPLETE_COMPRESSED VfatMdlReadCompleteCompressed;
596
597 static
598 BOOLEAN
599 NTAPI
VfatMdlReadCompleteCompressed(IN PFILE_OBJECT FileObject,IN PMDL MdlChain,IN PDEVICE_OBJECT DeviceObject)600 VfatMdlReadCompleteCompressed(
601 IN PFILE_OBJECT FileObject,
602 IN PMDL MdlChain,
603 IN PDEVICE_OBJECT DeviceObject)
604 {
605 DPRINT("VfatMdlReadCompleteCompressed\n");
606
607 UNREFERENCED_PARAMETER(FileObject);
608 UNREFERENCED_PARAMETER(MdlChain);
609 UNREFERENCED_PARAMETER(DeviceObject);
610
611 return FALSE;
612 }
613
614 static FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED VfatMdlWriteCompleteCompressed;
615
616 static
617 BOOLEAN
618 NTAPI
VfatMdlWriteCompleteCompressed(IN PFILE_OBJECT FileObject,IN PLARGE_INTEGER FileOffset,IN PMDL MdlChain,IN PDEVICE_OBJECT DeviceObject)619 VfatMdlWriteCompleteCompressed(
620 IN PFILE_OBJECT FileObject,
621 IN PLARGE_INTEGER FileOffset,
622 IN PMDL MdlChain,
623 IN PDEVICE_OBJECT DeviceObject)
624 {
625 DPRINT("VfatMdlWriteCompleteCompressed\n");
626
627 UNREFERENCED_PARAMETER(FileObject);
628 UNREFERENCED_PARAMETER(FileOffset);
629 UNREFERENCED_PARAMETER(MdlChain);
630 UNREFERENCED_PARAMETER(DeviceObject);
631
632 return FALSE;
633 }
634
635 static FAST_IO_QUERY_OPEN VfatFastIoQueryOpen;
636
637 static
638 BOOLEAN
639 NTAPI
VfatFastIoQueryOpen(IN PIRP Irp,OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,IN PDEVICE_OBJECT DeviceObject)640 VfatFastIoQueryOpen(
641 IN PIRP Irp,
642 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
643 IN PDEVICE_OBJECT DeviceObject)
644 {
645 DPRINT("VfatFastIoQueryOpen\n");
646
647 UNREFERENCED_PARAMETER(Irp);
648 UNREFERENCED_PARAMETER(NetworkInformation);
649 UNREFERENCED_PARAMETER(DeviceObject);
650
651 return FALSE;
652 }
653
654 static FAST_IO_RELEASE_FOR_MOD_WRITE VfatReleaseForModWrite;
655
656 static
657 NTSTATUS
658 NTAPI
VfatReleaseForModWrite(IN PFILE_OBJECT FileObject,IN PERESOURCE ResourceToRelease,IN PDEVICE_OBJECT DeviceObject)659 VfatReleaseForModWrite(
660 IN PFILE_OBJECT FileObject,
661 IN PERESOURCE ResourceToRelease,
662 IN PDEVICE_OBJECT DeviceObject)
663 {
664 DPRINT("VfatReleaseForModWrite\n");
665
666 UNREFERENCED_PARAMETER(FileObject);
667 UNREFERENCED_PARAMETER(ResourceToRelease);
668 UNREFERENCED_PARAMETER(DeviceObject);
669
670 return STATUS_INVALID_DEVICE_REQUEST;
671 }
672
673 static FAST_IO_ACQUIRE_FOR_CCFLUSH VfatAcquireForCcFlush;
674
675 static
676 NTSTATUS
677 NTAPI
VfatAcquireForCcFlush(IN PFILE_OBJECT FileObject,IN PDEVICE_OBJECT DeviceObject)678 VfatAcquireForCcFlush(
679 IN PFILE_OBJECT FileObject,
680 IN PDEVICE_OBJECT DeviceObject)
681 {
682 PVFATFCB Fcb = (PVFATFCB)FileObject->FsContext;
683
684 DPRINT("VfatAcquireForCcFlush\n");
685
686 UNREFERENCED_PARAMETER(DeviceObject);
687
688 /* Make sure it is not a volume lock */
689 ASSERT(!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME));
690
691 /* Acquire the resource */
692 ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
693
694 return STATUS_SUCCESS;
695 }
696
697 static FAST_IO_RELEASE_FOR_CCFLUSH VfatReleaseForCcFlush;
698
699 static
700 NTSTATUS
701 NTAPI
VfatReleaseForCcFlush(IN PFILE_OBJECT FileObject,IN PDEVICE_OBJECT DeviceObject)702 VfatReleaseForCcFlush(
703 IN PFILE_OBJECT FileObject,
704 IN PDEVICE_OBJECT DeviceObject)
705 {
706 PVFATFCB Fcb = (PVFATFCB)FileObject->FsContext;
707
708 DPRINT("VfatReleaseForCcFlush\n");
709
710 UNREFERENCED_PARAMETER(DeviceObject);
711
712 /* Make sure it is not a volume lock */
713 ASSERT(!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME));
714
715 /* Release the resource */
716 ExReleaseResourceLite(&(Fcb->MainResource));
717
718 return STATUS_SUCCESS;
719 }
720
721 BOOLEAN
722 NTAPI
VfatAcquireForLazyWrite(IN PVOID Context,IN BOOLEAN Wait)723 VfatAcquireForLazyWrite(
724 IN PVOID Context,
725 IN BOOLEAN Wait)
726 {
727 PVFATFCB Fcb = (PVFATFCB)Context;
728 ASSERT(Fcb);
729 DPRINT("VfatAcquireForLazyWrite(): Fcb %p\n", Fcb);
730
731 if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
732 {
733 DPRINT("VfatAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
734 return FALSE;
735 }
736 return TRUE;
737 }
738
739 VOID
740 NTAPI
VfatReleaseFromLazyWrite(IN PVOID Context)741 VfatReleaseFromLazyWrite(
742 IN PVOID Context)
743 {
744 PVFATFCB Fcb = (PVFATFCB)Context;
745 ASSERT(Fcb);
746 DPRINT("VfatReleaseFromLazyWrite(): Fcb %p\n", Fcb);
747
748 ExReleaseResourceLite(&(Fcb->MainResource));
749 }
750
751 CODE_SEG("INIT")
752 VOID
VfatInitFastIoRoutines(PFAST_IO_DISPATCH FastIoDispatch)753 VfatInitFastIoRoutines(
754 PFAST_IO_DISPATCH FastIoDispatch)
755 {
756 FastIoDispatch->SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
757 FastIoDispatch->FastIoCheckIfPossible = VfatFastIoCheckIfPossible;
758 FastIoDispatch->FastIoRead = VfatFastIoRead;
759 FastIoDispatch->FastIoWrite = VfatFastIoWrite;
760 FastIoDispatch->FastIoQueryBasicInfo = VfatFastIoQueryBasicInfo;
761 FastIoDispatch->FastIoQueryStandardInfo = VfatFastIoQueryStandardInfo;
762 FastIoDispatch->FastIoLock = VfatFastIoLock;
763 FastIoDispatch->FastIoUnlockSingle = VfatFastIoUnlockSingle;
764 FastIoDispatch->FastIoUnlockAll = VfatFastIoUnlockAll;
765 FastIoDispatch->FastIoUnlockAllByKey = VfatFastIoUnlockAllByKey;
766 FastIoDispatch->FastIoDeviceControl = VfatFastIoDeviceControl;
767 FastIoDispatch->AcquireFileForNtCreateSection = VfatAcquireFileForNtCreateSection;
768 FastIoDispatch->ReleaseFileForNtCreateSection = VfatReleaseFileForNtCreateSection;
769 FastIoDispatch->FastIoDetachDevice = VfatFastIoDetachDevice;
770 FastIoDispatch->FastIoQueryNetworkOpenInfo = VfatFastIoQueryNetworkOpenInfo;
771 FastIoDispatch->MdlRead = VfatMdlRead;
772 FastIoDispatch->MdlReadComplete = VfatMdlReadComplete;
773 FastIoDispatch->PrepareMdlWrite = VfatPrepareMdlWrite;
774 FastIoDispatch->MdlWriteComplete = VfatMdlWriteComplete;
775 FastIoDispatch->FastIoReadCompressed = VfatFastIoReadCompressed;
776 FastIoDispatch->FastIoWriteCompressed = VfatFastIoWriteCompressed;
777 FastIoDispatch->MdlReadCompleteCompressed = VfatMdlReadCompleteCompressed;
778 FastIoDispatch->MdlWriteCompleteCompressed = VfatMdlWriteCompleteCompressed;
779 FastIoDispatch->FastIoQueryOpen = VfatFastIoQueryOpen;
780 FastIoDispatch->AcquireForModWrite = VfatAcquireForModWrite;
781 FastIoDispatch->ReleaseForModWrite = VfatReleaseForModWrite;
782 FastIoDispatch->AcquireForCcFlush = VfatAcquireForCcFlush;
783 FastIoDispatch->ReleaseForCcFlush = VfatReleaseForCcFlush;
784 }
785