b02d4b480f184442edc3c84bb92861ff4a71256e
[reactos.git] / reactos / drivers / filesystems / fastfat / vfat.h
1 #ifndef _FASTFAT_PCH_
2 #define _FASTFAT_PCH_
3
4 #include <ntifs.h>
5 #include <ntdddisk.h>
6 #include <dos.h>
7 #include <pseh/pseh2.h>
8
9 #define USE_ROS_CC_AND_FS
10
11 #define ROUND_DOWN(n, align) \
12 (((ULONG)n) & ~((align) - 1l))
13
14 #define ROUND_UP(n, align) \
15 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
16
17 #include <pshpack1.h>
18 struct _BootSector
19 {
20 unsigned char magic0, res0, magic1;
21 unsigned char OEMName[8];
22 unsigned short BytesPerSector;
23 unsigned char SectorsPerCluster;
24 unsigned short ReservedSectors;
25 unsigned char FATCount;
26 unsigned short RootEntries, Sectors;
27 unsigned char Media;
28 unsigned short FATSectors, SectorsPerTrack, Heads;
29 unsigned long HiddenSectors, SectorsHuge;
30 unsigned char Drive, Res1, Sig;
31 unsigned long VolumeID;
32 unsigned char VolumeLabel[11], SysType[8];
33 unsigned char Res2[448];
34 unsigned short Signatur1;
35 };
36
37 struct _BootSector32
38 {
39 unsigned char magic0, res0, magic1; // 0
40 unsigned char OEMName[8]; // 3
41 unsigned short BytesPerSector; // 11
42 unsigned char SectorsPerCluster; // 13
43 unsigned short ReservedSectors; // 14
44 unsigned char FATCount; // 16
45 unsigned short RootEntries, Sectors; // 17
46 unsigned char Media; // 21
47 unsigned short FATSectors, SectorsPerTrack, Heads; // 22
48 unsigned long HiddenSectors, SectorsHuge; // 28
49 unsigned long FATSectors32; // 36
50 unsigned short ExtFlag; // 40
51 unsigned short FSVersion; // 42
52 unsigned long RootCluster; // 44
53 unsigned short FSInfoSector; // 48
54 unsigned short BootBackup; // 50
55 unsigned char Res3[12]; // 52
56 unsigned char Drive; // 64
57 unsigned char Res4; // 65
58 unsigned char ExtBootSignature; // 66
59 unsigned long VolumeID; // 67
60 unsigned char VolumeLabel[11], SysType[8]; // 71
61 unsigned char Res2[420]; // 90
62 unsigned short Signature1; // 510
63 };
64
65 struct _BootSectorFatX
66 {
67 unsigned char SysType[4]; // 0
68 unsigned long VolumeID; // 4
69 unsigned long SectorsPerCluster; // 8
70 unsigned short FATCount; // 12
71 unsigned long Unknown; // 14
72 unsigned char Unused[4078]; // 18
73 };
74
75 struct _FsInfoSector
76 {
77 unsigned long ExtBootSignature2; // 0
78 unsigned char Res6[480]; // 4
79 unsigned long FSINFOSignature; // 484
80 unsigned long FreeCluster; // 488
81 unsigned long NextCluster; // 492
82 unsigned char Res7[12]; // 496
83 unsigned long Signatur2; // 508
84 };
85
86 typedef struct _BootSector BootSector;
87
88 struct _FATDirEntry
89 {
90 union
91 {
92 struct { unsigned char Filename[8], Ext[3]; };
93 unsigned char ShortName[11];
94 };
95 unsigned char Attrib;
96 unsigned char lCase;
97 unsigned char CreationTimeMs;
98 unsigned short CreationTime,CreationDate,AccessDate;
99 union
100 {
101 unsigned short FirstClusterHigh; // FAT32
102 unsigned short ExtendedAttributes; // FAT12/FAT16
103 };
104 unsigned short UpdateTime; //time create/update
105 unsigned short UpdateDate; //date create/update
106 unsigned short FirstCluster;
107 unsigned long FileSize;
108 };
109
110 #define FAT_EAFILE "EA DATA. SF"
111
112 typedef struct _EAFileHeader FAT_EA_FILE_HEADER, *PFAT_EA_FILE_HEADER;
113
114 struct _EAFileHeader
115 {
116 unsigned short Signature; // ED
117 unsigned short Unknown[15];
118 unsigned short EASetTable[240];
119 };
120
121 typedef struct _EASetHeader FAT_EA_SET_HEADER, *PFAT_EA_SET_HEADER;
122
123 struct _EASetHeader
124 {
125 unsigned short Signature; // EA
126 unsigned short Offset; // relative offset, same value as in the EASetTable
127 unsigned short Unknown1[2];
128 char TargetFileName[12];
129 unsigned short Unknown2[3];
130 unsigned int EALength;
131 // EA Header
132 };
133
134 typedef struct _EAHeader FAT_EA_HEADER, *PFAT_EA_HEADER;
135
136 struct _EAHeader
137 {
138 unsigned char Unknown;
139 unsigned char EANameLength;
140 unsigned short EAValueLength;
141 // Name Data
142 // Value Data
143 };
144
145 typedef struct _FATDirEntry FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
146
147 struct _FATXDirEntry
148 {
149 unsigned char FilenameLength; // 0
150 unsigned char Attrib; // 1
151 unsigned char Filename[42]; // 2
152 unsigned long FirstCluster; // 44
153 unsigned long FileSize; // 48
154 unsigned short UpdateTime; // 52
155 unsigned short UpdateDate; // 54
156 unsigned short CreationTime; // 56
157 unsigned short CreationDate; // 58
158 unsigned short AccessTime; // 60
159 unsigned short AccessDate; // 62
160 };
161
162 struct _slot
163 {
164 unsigned char id; // sequence number for slot
165 WCHAR name0_4[5]; // first 5 characters in name
166 unsigned char attr; // attribute byte
167 unsigned char reserved; // always 0
168 unsigned char alias_checksum; // checksum for 8.3 alias
169 WCHAR name5_10[6]; // 6 more characters in name
170 unsigned char start[2]; // starting cluster number
171 WCHAR name11_12[2]; // last 2 characters in name
172 };
173
174 typedef struct _slot slot;
175
176 #include <poppack.h>
177
178 #define VFAT_CASE_LOWER_BASE 8 // base is lower case
179 #define VFAT_CASE_LOWER_EXT 16 // extension is lower case
180
181 #define LONGNAME_MAX_LENGTH 256 // max length for a long filename
182
183 #define ENTRY_DELETED(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
184 #define ENTRY_VOLUME(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
185 #define ENTRY_END(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
186
187 #define FAT_ENTRY_DELETED(DirEntry) ((DirEntry)->Filename[0] == 0xe5)
188 #define FAT_ENTRY_END(DirEntry) ((DirEntry)->Filename[0] == 0)
189 #define FAT_ENTRY_LONG(DirEntry) (((DirEntry)->Attrib & 0x3f) == 0x0f)
190 #define FAT_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
191
192 #define FATX_ENTRY_DELETED(DirEntry) ((DirEntry)->FilenameLength == 0xe5)
193 #define FATX_ENTRY_END(DirEntry) ((DirEntry)->FilenameLength == 0xff)
194 #define FATX_ENTRY_LONG(DirEntry) (FALSE)
195 #define FATX_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
196
197 #define FAT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FAT_DIR_ENTRY))
198 #define FATX_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FATX_DIR_ENTRY))
199
200 typedef struct _FATXDirEntry FATX_DIR_ENTRY, *PFATX_DIR_ENTRY;
201
202 union _DIR_ENTRY
203 {
204 FAT_DIR_ENTRY Fat;
205 FATX_DIR_ENTRY FatX;
206 };
207
208 typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
209
210 #define BLOCKSIZE 512
211
212 #define FAT16 (1)
213 #define FAT12 (2)
214 #define FAT32 (3)
215 #define FATX16 (4)
216 #define FATX32 (5)
217
218 #define VCB_VOLUME_LOCKED 0x0001
219 #define VCB_DISMOUNT_PENDING 0x0002
220 #define VCB_IS_FATX 0x0004
221 #define VCB_IS_DIRTY 0x4000 /* Volume is dirty */
222 #define VCB_CLEAR_DIRTY 0x8000 /* Clean dirty flag at shutdown */
223
224 typedef struct
225 {
226 ULONG VolumeID;
227 ULONG FATStart;
228 ULONG FATCount;
229 ULONG FATSectors;
230 ULONG rootDirectorySectors;
231 ULONG rootStart;
232 ULONG dataStart;
233 ULONG RootCluster;
234 ULONG SectorsPerCluster;
235 ULONG BytesPerSector;
236 ULONG BytesPerCluster;
237 ULONG NumberOfClusters;
238 ULONG FatType;
239 ULONG Sectors;
240 BOOLEAN FixedMedia;
241 } FATINFO, *PFATINFO;
242
243 struct _VFATFCB;
244 struct _VFAT_DIRENTRY_CONTEXT;
245
246 typedef struct _HASHENTRY
247 {
248 ULONG Hash;
249 struct _VFATFCB* self;
250 struct _HASHENTRY* next;
251 }
252 HASHENTRY;
253
254 #define FCB_HASH_TABLE_SIZE 65536
255
256 typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
257
258 typedef NTSTATUS (*PGET_NEXT_CLUSTER)(PDEVICE_EXTENSION,ULONG,PULONG);
259 typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
260 typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
261
262 typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
263
264 typedef struct DEVICE_EXTENSION
265 {
266 ERESOURCE DirResource;
267 ERESOURCE FatResource;
268
269 KSPIN_LOCK FcbListLock;
270 LIST_ENTRY FcbListHead;
271 ULONG HashTableSize;
272 struct _HASHENTRY **FcbHashTable;
273
274 PDEVICE_OBJECT StorageDevice;
275 PFILE_OBJECT FATFileObject;
276 FATINFO FatInfo;
277 ULONG LastAvailableCluster;
278 ULONG AvailableClusters;
279 BOOLEAN AvailableClustersValid;
280 ULONG Flags;
281 struct _VFATFCB *VolumeFcb;
282
283 /* Pointers to functions for manipulating FAT. */
284 PGET_NEXT_CLUSTER GetNextCluster;
285 PFIND_AND_MARK_AVAILABLE_CLUSTER FindAndMarkAvailableCluster;
286 PWRITE_CLUSTER WriteCluster;
287 ULONG CleanShutBitMask;
288
289 /* Pointers to functions for manipulating directory entries. */
290 PGET_NEXT_DIR_ENTRY GetNextDirEntry;
291
292 ULONG BaseDateYear;
293
294 LIST_ENTRY VolumeListEntry;
295
296 /* Notifications */
297 LIST_ENTRY NotifyList;
298 PNOTIFY_SYNC NotifySync;
299
300 /* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
301 ULONG OpenHandleCount;
302
303 /* VPBs for dismount */
304 PVPB IoVPB;
305 PVPB SpareVPB;
306 } DEVICE_EXTENSION, VCB, *PVCB;
307
308 typedef struct
309 {
310 PDRIVER_OBJECT DriverObject;
311 PDEVICE_OBJECT DeviceObject;
312 ULONG Flags;
313 ERESOURCE VolumeListLock;
314 LIST_ENTRY VolumeListHead;
315 NPAGED_LOOKASIDE_LIST FcbLookasideList;
316 NPAGED_LOOKASIDE_LIST CcbLookasideList;
317 NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
318 FAST_IO_DISPATCH FastIoDispatch;
319 CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
320 } VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
321
322 extern PVFAT_GLOBAL_DATA VfatGlobalData;
323
324 #define FCB_CACHE_INITIALIZED 0x0001
325 #define FCB_DELETE_PENDING 0x0002
326 #define FCB_IS_FAT 0x0004
327 #define FCB_IS_PAGE_FILE 0x0008
328 #define FCB_IS_VOLUME 0x0010
329 #define FCB_IS_DIRTY 0x0020
330 #define FCB_IS_FATX_ENTRY 0x0040
331
332 typedef struct _VFATFCB
333 {
334 /* FCB header required by ROS/NT */
335 FSRTL_COMMON_FCB_HEADER RFCB;
336 SECTION_OBJECT_POINTERS SectionObjectPointers;
337 ERESOURCE MainResource;
338 ERESOURCE PagingIoResource;
339 /* end FCB header required by ROS/NT */
340
341 /* directory entry for this file or directory */
342 DIR_ENTRY entry;
343
344 /* Pointer to attributes in entry */
345 PUCHAR Attributes;
346
347 /* long file name, points into PathNameBuffer */
348 UNICODE_STRING LongNameU;
349
350 /* short file name */
351 UNICODE_STRING ShortNameU;
352
353 /* directory name, points into PathNameBuffer */
354 UNICODE_STRING DirNameU;
355
356 /* path + long file name 260 max*/
357 UNICODE_STRING PathNameU;
358
359 /* buffer for PathNameU */
360 PWCHAR PathNameBuffer;
361
362 /* buffer for ShortNameU */
363 WCHAR ShortNameBuffer[13];
364
365 /* */
366 LONG RefCount;
367
368 /* List of FCB's for this volume */
369 LIST_ENTRY FcbListEntry;
370
371 /* pointer to the parent fcb */
372 struct _VFATFCB *parentFcb;
373
374 /* Flags for the fcb */
375 ULONG Flags;
376
377 /* pointer to the file object which has initialized the fcb */
378 PFILE_OBJECT FileObject;
379
380 /* Directory index for the short name entry */
381 ULONG dirIndex;
382
383 /* Directory index where the long name starts */
384 ULONG startIndex;
385
386 /* Share access for the file object */
387 SHARE_ACCESS FCBShareAccess;
388
389 /* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
390 ULONG OpenHandleCount;
391
392 /* Entry into the hash table for the path + long name */
393 HASHENTRY Hash;
394
395 /* Entry into the hash table for the path + short name */
396 HASHENTRY ShortHash;
397
398 /* List of byte-range locks for this file */
399 FILE_LOCK FileLock;
400
401 /*
402 * Optimalization: caching of last read/write cluster+offset pair. Can't
403 * be in VFATCCB because it must be reset everytime the allocated clusters
404 * change.
405 */
406 FAST_MUTEX LastMutex;
407 ULONG LastCluster;
408 ULONG LastOffset;
409 } VFATFCB, *PVFATFCB;
410
411 typedef struct _VFATCCB
412 {
413 LARGE_INTEGER CurrentByteOffset;
414 /* for DirectoryControl */
415 ULONG Entry;
416 /* for DirectoryControl */
417 UNICODE_STRING SearchPattern;
418 } VFATCCB, *PVFATCCB;
419
420 #define TAG_CCB 'BCCV'
421 #define TAG_FCB 'BCFV'
422 #define TAG_IRP 'PRIV'
423 #define TAG_VFAT 'TAFV'
424
425 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
426
427 typedef struct __DOSTIME
428 {
429 USHORT Second:5;
430 USHORT Minute:6;
431 USHORT Hour:5;
432 }
433 DOSTIME, *PDOSTIME;
434
435 typedef struct __DOSDATE
436 {
437 USHORT Day:5;
438 USHORT Month:4;
439 USHORT Year:7;
440 }
441 DOSDATE, *PDOSDATE;
442
443 #define IRPCONTEXT_CANWAIT 0x0001
444 #define IRPCONTEXT_PENDINGRETURNED 0x0002
445
446 typedef struct
447 {
448 PIRP Irp;
449 PDEVICE_OBJECT DeviceObject;
450 PDEVICE_EXTENSION DeviceExt;
451 ULONG Flags;
452 WORK_QUEUE_ITEM WorkQueueItem;
453 PIO_STACK_LOCATION Stack;
454 UCHAR MajorFunction;
455 UCHAR MinorFunction;
456 PFILE_OBJECT FileObject;
457 ULONG RefCount;
458 KEVENT Event;
459 } VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
460
461 typedef struct _VFAT_DIRENTRY_CONTEXT
462 {
463 ULONG StartIndex;
464 ULONG DirIndex;
465 DIR_ENTRY DirEntry;
466 UNICODE_STRING LongNameU;
467 UNICODE_STRING ShortNameU;
468 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
469
470 typedef struct _VFAT_MOVE_CONTEXT
471 {
472 ULONG FirstCluster;
473 ULONG FileSize;
474 USHORT CreationDate;
475 USHORT CreationTime;
476 } VFAT_MOVE_CONTEXT, *PVFAT_MOVE_CONTEXT;
477
478 /* blockdev.c */
479
480 NTSTATUS
481 VfatReadDisk(
482 IN PDEVICE_OBJECT pDeviceObject,
483 IN PLARGE_INTEGER ReadOffset,
484 IN ULONG ReadLength,
485 IN PUCHAR Buffer,
486 IN BOOLEAN Override);
487
488 NTSTATUS
489 VfatReadDiskPartial(
490 IN PVFAT_IRP_CONTEXT IrpContext,
491 IN PLARGE_INTEGER ReadOffset,
492 IN ULONG ReadLength,
493 IN ULONG BufferOffset,
494 IN BOOLEAN Wait);
495
496 NTSTATUS
497 VfatWriteDiskPartial(
498 IN PVFAT_IRP_CONTEXT IrpContext,
499 IN PLARGE_INTEGER WriteOffset,
500 IN ULONG WriteLength,
501 IN ULONG BufferOffset,
502 IN BOOLEAN Wait);
503
504 NTSTATUS
505 VfatBlockDeviceIoControl(
506 IN PDEVICE_OBJECT DeviceObject,
507 IN ULONG CtlCode,
508 IN PVOID InputBuffer,
509 IN ULONG InputBufferSize,
510 IN OUT PVOID OutputBuffer,
511 IN OUT PULONG pOutputBufferSize,
512 IN BOOLEAN Override);
513
514 /* cleanup.c */
515
516 NTSTATUS
517 VfatCleanup(
518 PVFAT_IRP_CONTEXT IrpContext);
519
520 /* close.c */
521
522 NTSTATUS
523 VfatClose(
524 PVFAT_IRP_CONTEXT IrpContext);
525
526 NTSTATUS
527 VfatCloseFile(
528 PDEVICE_EXTENSION DeviceExt,
529 PFILE_OBJECT FileObject);
530
531 /* create.c */
532
533 NTSTATUS
534 VfatCreate(
535 PVFAT_IRP_CONTEXT IrpContext);
536
537 NTSTATUS
538 FindFile(
539 PDEVICE_EXTENSION DeviceExt,
540 PVFATFCB Parent,
541 PUNICODE_STRING FileToFindU,
542 PVFAT_DIRENTRY_CONTEXT DirContext,
543 BOOLEAN First);
544
545 VOID
546 vfat8Dot3ToString(
547 PFAT_DIR_ENTRY pEntry,
548 PUNICODE_STRING NameU);
549
550 NTSTATUS
551 ReadVolumeLabel(
552 PDEVICE_EXTENSION DeviceExt,
553 PVPB Vpb);
554
555 /* dir.c */
556
557 NTSTATUS
558 VfatDirectoryControl(
559 PVFAT_IRP_CONTEXT IrpContext);
560
561 BOOLEAN
562 FsdDosDateTimeToSystemTime(
563 PDEVICE_EXTENSION DeviceExt,
564 USHORT DosDate,
565 USHORT DosTime,
566 PLARGE_INTEGER SystemTime);
567
568 BOOLEAN
569 FsdSystemTimeToDosDateTime(
570 PDEVICE_EXTENSION DeviceExt,
571 PLARGE_INTEGER SystemTime,
572 USHORT *pDosDate,
573 USHORT *pDosTime);
574
575 /* direntry.c */
576
577 ULONG
578 vfatDirEntryGetFirstCluster(
579 PDEVICE_EXTENSION pDeviceExt,
580 PDIR_ENTRY pDirEntry);
581
582 BOOLEAN
583 VfatIsDirectoryEmpty(
584 PVFATFCB Fcb);
585
586 NTSTATUS
587 FATGetNextDirEntry(
588 PVOID *pContext,
589 PVOID *pPage,
590 IN PVFATFCB pDirFcb,
591 IN PVFAT_DIRENTRY_CONTEXT DirContext,
592 BOOLEAN First);
593
594 NTSTATUS
595 FATXGetNextDirEntry(
596 PVOID *pContext,
597 PVOID *pPage,
598 IN PVFATFCB pDirFcb,
599 IN PVFAT_DIRENTRY_CONTEXT DirContext,
600 BOOLEAN First);
601
602 /* dirwr.c */
603
604 NTSTATUS
605 VfatAddEntry(
606 PDEVICE_EXTENSION DeviceExt,
607 PUNICODE_STRING PathNameU,
608 PVFATFCB* Fcb,
609 PVFATFCB ParentFcb,
610 ULONG RequestedOptions,
611 UCHAR ReqAttr,
612 PVFAT_MOVE_CONTEXT MoveContext);
613
614 NTSTATUS
615 VfatUpdateEntry(
616 PVFATFCB pFcb);
617
618 NTSTATUS
619 VfatDelEntry(
620 PDEVICE_EXTENSION,
621 PVFATFCB,
622 PVFAT_MOVE_CONTEXT);
623
624 BOOLEAN
625 vfatFindDirSpace(
626 PDEVICE_EXTENSION DeviceExt,
627 PVFATFCB pDirFcb,
628 ULONG nbSlots,
629 PULONG start);
630
631 NTSTATUS
632 vfatRenameEntry(
633 IN PDEVICE_EXTENSION DeviceExt,
634 IN PVFATFCB pFcb,
635 IN PUNICODE_STRING FileName,
636 IN BOOLEAN CaseChangeOnly);
637
638 NTSTATUS
639 VfatMoveEntry(
640 IN PDEVICE_EXTENSION DeviceExt,
641 IN PVFATFCB pFcb,
642 IN PUNICODE_STRING FileName,
643 IN PVFATFCB ParentFcb);
644
645 /* ea.h */
646
647 NTSTATUS
648 VfatSetExtendedAttributes(
649 PFILE_OBJECT FileObject,
650 PVOID Ea,
651 ULONG EaLength);
652
653 /* fastio.c */
654
655 VOID
656 VfatInitFastIoRoutines(
657 PFAST_IO_DISPATCH FastIoDispatch);
658
659 BOOLEAN
660 NTAPI
661 VfatAcquireForLazyWrite(
662 IN PVOID Context,
663 IN BOOLEAN Wait);
664
665 VOID
666 NTAPI
667 VfatReleaseFromLazyWrite(
668 IN PVOID Context);
669
670 BOOLEAN
671 NTAPI
672 VfatAcquireForReadAhead(
673 IN PVOID Context,
674 IN BOOLEAN Wait);
675
676 VOID
677 NTAPI
678 VfatReleaseFromReadAhead(
679 IN PVOID Context);
680
681 /* fat.c */
682
683 NTSTATUS
684 FAT12GetNextCluster(
685 PDEVICE_EXTENSION DeviceExt,
686 ULONG CurrentCluster,
687 PULONG NextCluster);
688
689 NTSTATUS
690 FAT12FindAndMarkAvailableCluster(
691 PDEVICE_EXTENSION DeviceExt,
692 PULONG Cluster);
693
694 NTSTATUS
695 FAT12WriteCluster(
696 PDEVICE_EXTENSION DeviceExt,
697 ULONG ClusterToWrite,
698 ULONG NewValue,
699 PULONG OldValue);
700
701 NTSTATUS
702 FAT16GetNextCluster(
703 PDEVICE_EXTENSION DeviceExt,
704 ULONG CurrentCluster,
705 PULONG NextCluster);
706
707 NTSTATUS
708 FAT16FindAndMarkAvailableCluster(
709 PDEVICE_EXTENSION DeviceExt,
710 PULONG Cluster);
711
712 NTSTATUS
713 FAT16WriteCluster(
714 PDEVICE_EXTENSION DeviceExt,
715 ULONG ClusterToWrite,
716 ULONG NewValue,
717 PULONG OldValue);
718
719 NTSTATUS
720 FAT32GetNextCluster(
721 PDEVICE_EXTENSION DeviceExt,
722 ULONG CurrentCluster,
723 PULONG NextCluster);
724
725 NTSTATUS
726 FAT32FindAndMarkAvailableCluster(
727 PDEVICE_EXTENSION DeviceExt,
728 PULONG Cluster);
729
730 NTSTATUS
731 FAT32WriteCluster(
732 PDEVICE_EXTENSION DeviceExt,
733 ULONG ClusterToWrite,
734 ULONG NewValue,
735 PULONG OldValue);
736
737 NTSTATUS
738 OffsetToCluster(
739 PDEVICE_EXTENSION DeviceExt,
740 ULONG FirstCluster,
741 ULONG FileOffset,
742 PULONG Cluster,
743 BOOLEAN Extend);
744
745 ULONGLONG
746 ClusterToSector(
747 PDEVICE_EXTENSION DeviceExt,
748 ULONG Cluster);
749
750 NTSTATUS
751 GetNextCluster(
752 PDEVICE_EXTENSION DeviceExt,
753 ULONG CurrentCluster,
754 PULONG NextCluster);
755
756 NTSTATUS
757 GetNextClusterExtend(
758 PDEVICE_EXTENSION DeviceExt,
759 ULONG CurrentCluster,
760 PULONG NextCluster);
761
762 NTSTATUS
763 CountAvailableClusters(
764 PDEVICE_EXTENSION DeviceExt,
765 PLARGE_INTEGER Clusters);
766
767 NTSTATUS
768 WriteCluster(
769 PDEVICE_EXTENSION DeviceExt,
770 ULONG ClusterToWrite,
771 ULONG NewValue);
772
773 /* fcb.c */
774
775 PVFATFCB
776 vfatNewFCB(
777 PDEVICE_EXTENSION pVCB,
778 PUNICODE_STRING pFileNameU);
779
780 NTSTATUS
781 vfatUpdateFCB(
782 PDEVICE_EXTENSION pVCB,
783 PVFATFCB Fcb,
784 PUNICODE_STRING LongName,
785 PUNICODE_STRING ShortName,
786 PVFATFCB ParentFcb);
787
788 VOID
789 vfatDestroyFCB(
790 PVFATFCB pFCB);
791
792 VOID
793 vfatDestroyCCB(
794 PVFATCCB pCcb);
795
796 VOID
797 vfatGrabFCB(
798 PDEVICE_EXTENSION pVCB,
799 PVFATFCB pFCB);
800
801 VOID
802 vfatReleaseFCB(
803 PDEVICE_EXTENSION pVCB,
804 PVFATFCB pFCB);
805
806 PVFATFCB
807 vfatGrabFCBFromTable(
808 PDEVICE_EXTENSION pDeviceExt,
809 PUNICODE_STRING pFileNameU);
810
811 PVFATFCB
812 vfatMakeRootFCB(
813 PDEVICE_EXTENSION pVCB);
814
815 PVFATFCB
816 vfatOpenRootFCB(
817 PDEVICE_EXTENSION pVCB);
818
819 BOOLEAN
820 vfatFCBIsDirectory(
821 PVFATFCB FCB);
822
823 BOOLEAN
824 vfatFCBIsRoot(
825 PVFATFCB FCB);
826
827 NTSTATUS
828 vfatAttachFCBToFileObject(
829 PDEVICE_EXTENSION vcb,
830 PVFATFCB fcb,
831 PFILE_OBJECT fileObject);
832
833 NTSTATUS
834 vfatDirFindFile(
835 PDEVICE_EXTENSION pVCB,
836 PVFATFCB parentFCB,
837 PUNICODE_STRING FileToFindU,
838 PVFATFCB *fileFCB);
839
840 NTSTATUS
841 vfatGetFCBForFile(
842 PDEVICE_EXTENSION pVCB,
843 PVFATFCB *pParentFCB,
844 PVFATFCB *pFCB,
845 PUNICODE_STRING pFileNameU);
846
847 NTSTATUS
848 vfatMakeFCBFromDirEntry(
849 PVCB vcb,
850 PVFATFCB directoryFCB,
851 PVFAT_DIRENTRY_CONTEXT DirContext,
852 PVFATFCB *fileFCB);
853
854 /* finfo.c */
855
856 NTSTATUS
857 VfatQueryInformation(
858 PVFAT_IRP_CONTEXT IrpContext);
859
860 NTSTATUS
861 VfatSetInformation(
862 PVFAT_IRP_CONTEXT IrpContext);
863
864 NTSTATUS
865 VfatSetAllocationSizeInformation(
866 PFILE_OBJECT FileObject,
867 PVFATFCB Fcb,
868 PDEVICE_EXTENSION DeviceExt,
869 PLARGE_INTEGER AllocationSize);
870
871 /* flush.c */
872
873 NTSTATUS
874 VfatFlush(
875 PVFAT_IRP_CONTEXT IrpContext);
876
877 NTSTATUS
878 VfatFlushVolume(
879 PDEVICE_EXTENSION DeviceExt,
880 PVFATFCB VolumeFcb);
881
882 /* fsctl.c */
883
884 NTSTATUS
885 VfatFileSystemControl(
886 PVFAT_IRP_CONTEXT IrpContext);
887
888 /* iface.c */
889
890 NTSTATUS
891 NTAPI
892 DriverEntry(
893 PDRIVER_OBJECT DriverObject,
894 PUNICODE_STRING RegistryPath);
895
896
897 /* misc.c */
898
899 NTSTATUS
900 VfatQueueRequest(
901 PVFAT_IRP_CONTEXT IrpContext);
902
903 PVFAT_IRP_CONTEXT
904 VfatAllocateIrpContext(
905 PDEVICE_OBJECT DeviceObject,
906 PIRP Irp);
907
908 VOID
909 VfatFreeIrpContext(
910 PVFAT_IRP_CONTEXT IrpContext);
911
912 DRIVER_DISPATCH
913 VfatBuildRequest;
914
915 NTSTATUS
916 NTAPI
917 VfatBuildRequest(
918 PDEVICE_OBJECT DeviceObject,
919 PIRP Irp);
920
921 PVOID
922 VfatGetUserBuffer(
923 IN PIRP);
924
925 NTSTATUS
926 VfatLockUserBuffer(
927 IN PIRP,
928 IN ULONG,
929 IN LOCK_OPERATION);
930
931 /* pnp.c */
932
933 NTSTATUS
934 VfatPnp(
935 PVFAT_IRP_CONTEXT IrpContext);
936
937 /* rw.c */
938
939 NTSTATUS
940 VfatRead(
941 PVFAT_IRP_CONTEXT IrpContext);
942
943 NTSTATUS
944 VfatWrite(
945 PVFAT_IRP_CONTEXT IrpContext);
946
947 NTSTATUS
948 NextCluster(
949 PDEVICE_EXTENSION DeviceExt,
950 ULONG FirstCluster,
951 PULONG CurrentCluster,
952 BOOLEAN Extend);
953
954 /* shutdown.c */
955
956 DRIVER_DISPATCH
957 VfatShutdown;
958
959 NTSTATUS
960 NTAPI
961 VfatShutdown(
962 PDEVICE_OBJECT DeviceObject,
963 PIRP Irp);
964
965 /* string.c */
966
967 VOID
968 vfatSplitPathName(
969 PUNICODE_STRING PathNameU,
970 PUNICODE_STRING DirNameU,
971 PUNICODE_STRING FileNameU);
972
973 BOOLEAN
974 vfatIsLongIllegal(
975 WCHAR c);
976
977 BOOLEAN
978 wstrcmpjoki(
979 PWSTR s1,
980 PWSTR s2);
981
982 /* volume.c */
983
984 NTSTATUS
985 VfatQueryVolumeInformation(
986 PVFAT_IRP_CONTEXT IrpContext);
987
988 NTSTATUS
989 VfatSetVolumeInformation(
990 PVFAT_IRP_CONTEXT IrpContext);
991
992 #endif /* _FASTFAT_PCH_ */