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