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