[FASTFAT]
[reactos.git] / reactos / drivers / filesystems / fastfat / vfat.h
1 #include <ntifs.h>
2 #include <bugcodes.h>
3 #include <ntdddisk.h>
4 #include <debug.h>
5 #include <dos.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 #define TAG_CCB 'BCCV'
408 #define TAG_FCB 'BCFV'
409 #define TAG_IRP 'PRIV'
410 #define TAG_VFAT 'TAFV'
411
412 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
413
414 typedef struct __DOSTIME
415 {
416 USHORT Second:5;
417 USHORT Minute:6;
418 USHORT Hour:5;
419 }
420 DOSTIME, *PDOSTIME;
421
422 typedef struct __DOSDATE
423 {
424 USHORT Day:5;
425 USHORT Month:4;
426 USHORT Year:5;
427 }
428 DOSDATE, *PDOSDATE;
429
430 #define IRPCONTEXT_CANWAIT 0x0001
431 #define IRPCONTEXT_PENDINGRETURNED 0x0002
432
433 typedef struct
434 {
435 PIRP Irp;
436 PDEVICE_OBJECT DeviceObject;
437 PDEVICE_EXTENSION DeviceExt;
438 ULONG Flags;
439 WORK_QUEUE_ITEM WorkQueueItem;
440 PIO_STACK_LOCATION Stack;
441 UCHAR MajorFunction;
442 UCHAR MinorFunction;
443 PFILE_OBJECT FileObject;
444 ULONG RefCount;
445 KEVENT Event;
446 } VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
447
448 typedef struct _VFAT_DIRENTRY_CONTEXT
449 {
450 ULONG StartIndex;
451 ULONG DirIndex;
452 DIR_ENTRY DirEntry;
453 UNICODE_STRING LongNameU;
454 UNICODE_STRING ShortNameU;
455 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
456
457
458 /* ------------------------------------------------------ shutdown.c */
459
460 DRIVER_DISPATCH VfatShutdown;
461 NTSTATUS NTAPI VfatShutdown (PDEVICE_OBJECT DeviceObject,
462 PIRP Irp);
463
464 /* -------------------------------------------------------- volume.c */
465
466 NTSTATUS VfatQueryVolumeInformation (PVFAT_IRP_CONTEXT IrpContext);
467
468 NTSTATUS VfatSetVolumeInformation (PVFAT_IRP_CONTEXT IrpContext);
469
470 /* ------------------------------------------------------ blockdev.c */
471
472 NTSTATUS VfatReadDisk(IN PDEVICE_OBJECT pDeviceObject,
473 IN PLARGE_INTEGER ReadOffset,
474 IN ULONG ReadLength,
475 IN PUCHAR Buffer,
476 IN BOOLEAN Override);
477
478 NTSTATUS VfatReadDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
479 IN PLARGE_INTEGER ReadOffset,
480 IN ULONG ReadLength,
481 IN ULONG BufferOffset,
482 IN BOOLEAN Wait);
483
484 NTSTATUS VfatWriteDiskPartial(IN PVFAT_IRP_CONTEXT IrpContext,
485 IN PLARGE_INTEGER WriteOffset,
486 IN ULONG WriteLength,
487 IN ULONG BufferOffset,
488 IN BOOLEAN Wait);
489
490 NTSTATUS VfatBlockDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
491 IN ULONG CtlCode,
492 IN PVOID InputBuffer,
493 IN ULONG InputBufferSize,
494 IN OUT PVOID OutputBuffer,
495 IN OUT PULONG pOutputBufferSize,
496 IN BOOLEAN Override);
497
498 /* ----------------------------------------------------------- dir.c */
499
500 NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT);
501
502 BOOLEAN FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt,
503 USHORT DosDate,
504 USHORT DosTime,
505 PLARGE_INTEGER SystemTime);
506
507 BOOLEAN FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt,
508 PLARGE_INTEGER SystemTime,
509 USHORT *pDosDate,
510 USHORT *pDosTime);
511
512 /* -------------------------------------------------------- create.c */
513
514 NTSTATUS VfatCreate (PVFAT_IRP_CONTEXT IrpContext);
515
516 NTSTATUS FindFile (PDEVICE_EXTENSION DeviceExt,
517 PVFATFCB Parent,
518 PUNICODE_STRING FileToFindU,
519 PVFAT_DIRENTRY_CONTEXT DirContext,
520 BOOLEAN First);
521
522 VOID vfat8Dot3ToString (PFAT_DIR_ENTRY pEntry,
523 PUNICODE_STRING NameU);
524
525 NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt,
526 PVPB Vpb);
527
528 /* --------------------------------------------------------- close.c */
529
530 NTSTATUS VfatClose (PVFAT_IRP_CONTEXT IrpContext);
531
532 NTSTATUS VfatCloseFile(PDEVICE_EXTENSION DeviceExt,
533 PFILE_OBJECT FileObject);
534
535 /* ------------------------------------------------------- cleanup.c */
536
537 NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext);
538
539 /* --------------------------------------------------------- fastio.c */
540
541 VOID
542 VfatInitFastIoRoutines(PFAST_IO_DISPATCH FastIoDispatch);
543
544 BOOLEAN NTAPI
545 VfatAcquireForLazyWrite(IN PVOID Context,
546 IN BOOLEAN Wait);
547
548 VOID NTAPI
549 VfatReleaseFromLazyWrite(IN PVOID Context);
550
551 BOOLEAN NTAPI
552 VfatAcquireForReadAhead(IN PVOID Context,
553 IN BOOLEAN Wait);
554
555 VOID NTAPI
556 VfatReleaseFromReadAhead(IN PVOID Context);
557
558 /* --------------------------------------------------------- fsctl.c */
559
560 NTSTATUS VfatFileSystemControl (PVFAT_IRP_CONTEXT IrpContext);
561
562 /* --------------------------------------------------------- finfo.c */
563
564 NTSTATUS VfatQueryInformation (PVFAT_IRP_CONTEXT IrpContext);
565
566 NTSTATUS VfatSetInformation (PVFAT_IRP_CONTEXT IrpContext);
567
568 NTSTATUS
569 VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject,
570 PVFATFCB Fcb,
571 PDEVICE_EXTENSION DeviceExt,
572 PLARGE_INTEGER AllocationSize);
573
574 /* --------------------------------------------------------- iface.c */
575
576 NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject,
577 PUNICODE_STRING RegistryPath);
578
579 /* --------------------------------------------------------- dirwr.c */
580
581 NTSTATUS VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
582 PUNICODE_STRING PathNameU,
583 PVFATFCB* Fcb,
584 PVFATFCB ParentFcb,
585 ULONG RequestedOptions,
586 UCHAR ReqAttr);
587
588 NTSTATUS VfatUpdateEntry (PVFATFCB pFcb);
589
590 NTSTATUS VfatDelEntry(PDEVICE_EXTENSION, PVFATFCB);
591
592 BOOLEAN
593 vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
594 PVFATFCB pDirFcb,
595 ULONG nbSlots,
596 PULONG start);
597
598 /* -------------------------------------------------------- string.c */
599
600 VOID
601 vfatSplitPathName(PUNICODE_STRING PathNameU,
602 PUNICODE_STRING DirNameU,
603 PUNICODE_STRING FileNameU);
604
605 BOOLEAN vfatIsLongIllegal(WCHAR c);
606
607 BOOLEAN wstrcmpjoki (PWSTR s1,
608 PWSTR s2);
609
610 /* ----------------------------------------------------------- fat.c */
611
612 NTSTATUS FAT12GetNextCluster(PDEVICE_EXTENSION DeviceExt,
613 ULONG CurrentCluster,
614 PULONG NextCluster);
615
616 NTSTATUS FAT12FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt,
617 PULONG Cluster);
618
619 NTSTATUS FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt,
620 ULONG ClusterToWrite,
621 ULONG NewValue,
622 PULONG OldValue);
623
624 NTSTATUS FAT16GetNextCluster(PDEVICE_EXTENSION DeviceExt,
625 ULONG CurrentCluster,
626 PULONG NextCluster);
627
628 NTSTATUS FAT16FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt,
629 PULONG Cluster);
630
631 NTSTATUS FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt,
632 ULONG ClusterToWrite,
633 ULONG NewValue,
634 PULONG OldValue);
635
636 NTSTATUS FAT32GetNextCluster(PDEVICE_EXTENSION DeviceExt,
637 ULONG CurrentCluster,
638 PULONG NextCluster);
639
640 NTSTATUS FAT32FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt,
641 PULONG Cluster);
642
643 NTSTATUS FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt,
644 ULONG ClusterToWrite,
645 ULONG NewValue,
646 PULONG OldValue);
647
648 NTSTATUS OffsetToCluster (PDEVICE_EXTENSION DeviceExt,
649 ULONG FirstCluster,
650 ULONG FileOffset,
651 PULONG Cluster,
652 BOOLEAN Extend);
653
654 ULONGLONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
655 ULONG Cluster);
656
657 NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
658 ULONG CurrentCluster,
659 PULONG NextCluster);
660
661 NTSTATUS GetNextClusterExtend (PDEVICE_EXTENSION DeviceExt,
662 ULONG CurrentCluster,
663 PULONG NextCluster);
664
665 NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
666 PLARGE_INTEGER Clusters);
667
668 NTSTATUS
669 WriteCluster(PDEVICE_EXTENSION DeviceExt,
670 ULONG ClusterToWrite,
671 ULONG NewValue);
672
673 /* ------------------------------------------------------ direntry.c */
674
675 ULONG vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION pDeviceExt,
676 PDIR_ENTRY pDirEntry);
677
678 BOOLEAN VfatIsDirectoryEmpty(PVFATFCB Fcb);
679
680 NTSTATUS FATGetNextDirEntry(PVOID * pContext,
681 PVOID * pPage,
682 IN PVFATFCB pDirFcb,
683 IN PVFAT_DIRENTRY_CONTEXT DirContext,
684 BOOLEAN First);
685
686 NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
687 PVOID * pPage,
688 IN PVFATFCB pDirFcb,
689 IN PVFAT_DIRENTRY_CONTEXT DirContext,
690 BOOLEAN First);
691
692 /* ----------------------------------------------------------- fcb.c */
693
694 PVFATFCB vfatNewFCB (PDEVICE_EXTENSION pVCB,
695 PUNICODE_STRING pFileNameU);
696
697 VOID vfatDestroyFCB (PVFATFCB pFCB);
698
699 VOID vfatDestroyCCB(PVFATCCB pCcb);
700
701 VOID vfatGrabFCB (PDEVICE_EXTENSION pVCB,
702 PVFATFCB pFCB);
703
704 VOID vfatReleaseFCB (PDEVICE_EXTENSION pVCB,
705 PVFATFCB pFCB);
706
707 VOID vfatAddFCBToTable (PDEVICE_EXTENSION pVCB,
708 PVFATFCB pFCB);
709
710 PVFATFCB vfatGrabFCBFromTable (PDEVICE_EXTENSION pDeviceExt,
711 PUNICODE_STRING pFileNameU);
712
713 PVFATFCB vfatMakeRootFCB (PDEVICE_EXTENSION pVCB);
714
715 PVFATFCB vfatOpenRootFCB (PDEVICE_EXTENSION pVCB);
716
717 BOOLEAN vfatFCBIsDirectory (PVFATFCB FCB);
718
719 BOOLEAN vfatFCBIsRoot(PVFATFCB FCB);
720
721 NTSTATUS vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
722 PVFATFCB fcb,
723 PFILE_OBJECT fileObject);
724
725 NTSTATUS vfatDirFindFile (PDEVICE_EXTENSION pVCB,
726 PVFATFCB parentFCB,
727 PUNICODE_STRING FileToFindU,
728 PVFATFCB * fileFCB);
729
730 NTSTATUS vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
731 PVFATFCB *pParentFCB,
732 PVFATFCB *pFCB,
733 PUNICODE_STRING pFileNameU);
734
735 NTSTATUS vfatMakeFCBFromDirEntry (PVCB vcb,
736 PVFATFCB directoryFCB,
737 PVFAT_DIRENTRY_CONTEXT DirContext,
738 PVFATFCB * fileFCB);
739
740 /* ------------------------------------------------------------ rw.c */
741
742 NTSTATUS VfatRead (PVFAT_IRP_CONTEXT IrpContext);
743
744 NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext);
745
746 NTSTATUS NextCluster(PDEVICE_EXTENSION DeviceExt,
747 ULONG FirstCluster,
748 PULONG CurrentCluster,
749 BOOLEAN Extend);
750
751 /* ----------------------------------------------------------- misc.c */
752
753 NTSTATUS VfatQueueRequest(PVFAT_IRP_CONTEXT IrpContext);
754
755 PVFAT_IRP_CONTEXT VfatAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
756 PIRP Irp);
757
758 VOID VfatFreeIrpContext(PVFAT_IRP_CONTEXT IrpContext);
759
760 DRIVER_DISPATCH VfatBuildRequest;
761 NTSTATUS NTAPI VfatBuildRequest (PDEVICE_OBJECT DeviceObject,
762 PIRP Irp);
763
764 PVOID VfatGetUserBuffer(IN PIRP);
765
766 NTSTATUS VfatLockUserBuffer(IN PIRP, IN ULONG,
767 IN LOCK_OPERATION);
768
769 NTSTATUS
770 VfatSetExtendedAttributes(PFILE_OBJECT FileObject,
771 PVOID Ea,
772 ULONG EaLength);
773 /* ------------------------------------------------------------- flush.c */
774
775 NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext);
776
777 NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb);
778
779 /* --------------------------------------------------------------- pnp.c */
780
781 NTSTATUS VfatPnp(PVFAT_IRP_CONTEXT IrpContext);
782
783 /* EOF */