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