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