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