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