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