- NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL...
[reactos.git] / reactos / drivers / filesystems / vfat / vfat.h
1 #include <debug.h>
2 #include <ntifs.h>
3 #include <ntdddisk.h>
4 #include <reactos/helper.h>
5
6 #ifdef __GNUC__
7 #include <ccros.h>
8
9 #define USE_ROS_CC_AND_FS
10 #else
11 #define KEBUGCHECK KeBugCheck
12 #define KEBUGCHECKEX KeBugCheckEx
13 #define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
14 #define ROUND_UP(N, S) ROUND_DOWN((N) + (S) - 1, (S))
15 #endif
16
17 #include <pshpack1.h>
18 struct _BootSector
19 {
20 unsigned char magic0, res0, magic1;
21 unsigned char OEMName[8];
22 unsigned short BytesPerSector;
23 unsigned char SectorsPerCluster;
24 unsigned short ReservedSectors;
25 unsigned char FATCount;
26 unsigned short RootEntries, Sectors;
27 unsigned char Media;
28 unsigned short FATSectors, SectorsPerTrack, Heads;
29 unsigned long HiddenSectors, SectorsHuge;
30 unsigned char Drive, Res1, Sig;
31 unsigned long VolumeID;
32 unsigned char VolumeLabel[11], SysType[8];
33 unsigned char Res2[448];
34 unsigned short Signatur1;
35 };
36
37 struct _BootSector32
38 {
39 unsigned char magic0, res0, magic1; // 0
40 unsigned char OEMName[8]; // 3
41 unsigned short BytesPerSector; // 11
42 unsigned char SectorsPerCluster; // 13
43 unsigned short ReservedSectors; // 14
44 unsigned char FATCount; // 16
45 unsigned short RootEntries, Sectors; // 17
46 unsigned char Media; // 21
47 unsigned short FATSectors, SectorsPerTrack, Heads; // 22
48 unsigned long HiddenSectors, SectorsHuge; // 28
49 unsigned long FATSectors32; // 36
50 unsigned short ExtFlag; // 40
51 unsigned short FSVersion; // 42
52 unsigned long RootCluster; // 44
53 unsigned short FSInfoSector; // 48
54 unsigned short BootBackup; // 50
55 unsigned char Res3[12]; // 52
56 unsigned char Drive; // 64
57 unsigned char Res4; // 65
58 unsigned char ExtBootSignature; // 66
59 unsigned long VolumeID; // 67
60 unsigned char VolumeLabel[11], SysType[8]; // 71
61 unsigned char Res2[420]; // 90
62 unsigned short Signature1; // 510
63 };
64
65 struct _BootSectorFatX
66 {
67 unsigned char SysType[4]; // 0
68 unsigned long VolumeID; // 4
69 unsigned long SectorsPerCluster; // 8
70 unsigned short FATCount; // 12
71 unsigned long Unknown; // 14
72 unsigned char Unused[4078]; // 18
73 };
74
75 struct _FsInfoSector
76 {
77 unsigned long ExtBootSignature2; // 0
78 unsigned char Res6[480]; // 4
79 unsigned long FSINFOSignature; // 484
80 unsigned long FreeCluster; // 488
81 unsigned long NextCluster; // 492
82 unsigned char Res7[12]; // 496
83 unsigned long Signatur2; // 508
84 };
85
86 typedef struct _BootSector BootSector;
87
88 struct _FATDirEntry
89 {
90 union
91 {
92 struct { unsigned char Filename[8], Ext[3]; };
93 unsigned char ShortName[11];
94 };
95 unsigned char Attrib;
96 unsigned char lCase;
97 unsigned char CreationTimeMs;
98 unsigned short CreationTime,CreationDate,AccessDate;
99 union
100 {
101 unsigned short FirstClusterHigh; // FAT32
102 unsigned short ExtendedAttributes; // FAT12/FAT16
103 };
104 unsigned short UpdateTime; //time create/update
105 unsigned short UpdateDate; //date create/update
106 unsigned short FirstCluster;
107 unsigned long FileSize;
108 };
109
110 #define FAT_EAFILE "EA DATA. SF"
111
112 typedef struct _EAFileHeader FAT_EA_FILE_HEADER, *PFAT_EA_FILE_HEADER;
113
114 struct _EAFileHeader
115 {
116 unsigned short Signature; // ED
117 unsigned short Unknown[15];
118 unsigned short EASetTable[240];
119 };
120
121 typedef struct _EASetHeader FAT_EA_SET_HEADER, *PFAT_EA_SET_HEADER;
122
123 struct _EASetHeader
124 {
125 unsigned short Signature; // EA
126 unsigned short Offset; // relative offset, same value as in the EASetTable
127 unsigned short Unknown1[2];
128 char TargetFileName[12];
129 unsigned short Unknown2[3];
130 unsigned int EALength;
131 // EA Header
132 };
133
134 typedef struct _EAHeader FAT_EA_HEADER, *PFAT_EA_HEADER;
135
136 struct _EAHeader
137 {
138 unsigned char Unknown;
139 unsigned char EANameLength;
140 unsigned short EAValueLength;
141 // Name Data
142 // Value Data
143 };
144
145 typedef struct _FATDirEntry FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
146
147 struct _FATXDirEntry
148 {
149 unsigned char FilenameLength; // 0
150 unsigned char Attrib; // 1
151 unsigned char Filename[42]; // 2
152 unsigned long FirstCluster; // 44
153 unsigned long FileSize; // 48
154 unsigned short UpdateTime; // 52
155 unsigned short UpdateDate; // 54
156 unsigned short CreationTime; // 56
157 unsigned short CreationDate; // 58
158 unsigned short AccessTime; // 60
159 unsigned short AccessDate; // 62
160 };
161
162 struct _slot
163 {
164 unsigned char id; // sequence number for slot
165 WCHAR name0_4[5]; // first 5 characters in name
166 unsigned char attr; // attribute byte
167 unsigned char reserved; // always 0
168 unsigned char alias_checksum; // checksum for 8.3 alias
169 WCHAR name5_10[6]; // 6 more characters in name
170 unsigned char start[2]; // starting cluster number
171 WCHAR name11_12[2]; // last 2 characters in name
172 };
173
174 typedef struct _slot slot;
175
176 #include <poppack.h>
177
178 #define VFAT_CASE_LOWER_BASE 8 // base is lower case
179 #define VFAT_CASE_LOWER_EXT 16 // extension is lower case
180
181 #define LONGNAME_MAX_LENGTH 256 // max length for a long filename
182
183 #define ENTRY_DELETED(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
184 #define ENTRY_VOLUME(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
185 #define ENTRY_END(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
186
187 #define FAT_ENTRY_DELETED(DirEntry) ((DirEntry)->Filename[0] == 0xe5)
188 #define FAT_ENTRY_END(DirEntry) ((DirEntry)->Filename[0] == 0)
189 #define FAT_ENTRY_LONG(DirEntry) (((DirEntry)->Attrib & 0x3f) == 0x0f)
190 #define FAT_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
191
192 #define FATX_ENTRY_DELETED(DirEntry) ((DirEntry)->FilenameLength == 0xe5)
193 #define FATX_ENTRY_END(DirEntry) ((DirEntry)->FilenameLength == 0xff)
194 #define FATX_ENTRY_LONG(DirEntry) (FALSE)
195 #define FATX_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
196
197 #define FAT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FAT_DIR_ENTRY))
198 #define FATX_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FATX_DIR_ENTRY))
199
200 typedef struct _FATXDirEntry FATX_DIR_ENTRY, *PFATX_DIR_ENTRY;
201
202 union _DIR_ENTRY
203 {
204 FAT_DIR_ENTRY Fat;
205 FATX_DIR_ENTRY FatX;
206 };
207
208 typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
209
210 #define BLOCKSIZE 512
211
212 #define FAT16 (1)
213 #define FAT12 (2)
214 #define FAT32 (3)
215 #define FATX16 (4)
216 #define FATX32 (5)
217
218 #define VCB_VOLUME_LOCKED 0x0001
219 #define VCB_DISMOUNT_PENDING 0x0002
220 #define VCB_IS_FATX 0x0004
221 #define VCB_IS_DIRTY 0x4000 /* Volume is dirty */
222 #define VCB_CLEAR_DIRTY 0x8000 /* Clean dirty flag at shutdown */
223
224 typedef struct
225 {
226 ULONG VolumeID;
227 ULONG FATStart;
228 ULONG FATCount;
229 ULONG FATSectors;
230 ULONG rootDirectorySectors;
231 ULONG rootStart;
232 ULONG dataStart;
233 ULONG RootCluster;
234 ULONG SectorsPerCluster;
235 ULONG BytesPerSector;
236 ULONG BytesPerCluster;
237 ULONG NumberOfClusters;
238 ULONG FatType;
239 ULONG Sectors;
240 BOOLEAN FixedMedia;
241 } FATINFO, *PFATINFO;
242
243 struct _VFATFCB;
244 struct _VFAT_DIRENTRY_CONTEXT;
245
246 typedef struct _HASHENTRY
247 {
248 ULONG Hash;
249 struct _VFATFCB* self;
250 struct _HASHENTRY* next;
251 }
252 HASHENTRY;
253
254 #define FCB_HASH_TABLE_SIZE 65536
255
256 typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
257
258 typedef NTSTATUS (*PGET_NEXT_CLUSTER)(PDEVICE_EXTENSION,ULONG,PULONG);
259 typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
260 typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
261
262 typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
263
264 typedef struct DEVICE_EXTENSION
265 {
266 ERESOURCE DirResource;
267 ERESOURCE FatResource;
268
269 KSPIN_LOCK FcbListLock;
270 LIST_ENTRY FcbListHead;
271 ULONG HashTableSize;
272 struct _HASHENTRY** FcbHashTable;
273
274 PDEVICE_OBJECT StorageDevice;
275 PFILE_OBJECT FATFileObject;
276 FATINFO FatInfo;
277 ULONG LastAvailableCluster;
278 ULONG AvailableClusters;
279 BOOLEAN AvailableClustersValid;
280 ULONG Flags;
281 struct _VFATFCB * VolumeFcb;
282
283 /* Pointers to functions for manipulating FAT. */
284 PGET_NEXT_CLUSTER GetNextCluster;
285 PFIND_AND_MARK_AVAILABLE_CLUSTER FindAndMarkAvailableCluster;
286 PWRITE_CLUSTER WriteCluster;
287 ULONG CleanShutBitMask;
288
289 /* Pointers to functions for manipulating directory entries. */
290 PGET_NEXT_DIR_ENTRY GetNextDirEntry;
291
292 ULONG BaseDateYear;
293
294 LIST_ENTRY VolumeListEntry;
295 } DEVICE_EXTENSION, VCB, *PVCB;
296
297 typedef struct
298 {
299 PDRIVER_OBJECT DriverObject;
300 PDEVICE_OBJECT DeviceObject;
301 ULONG Flags;
302 ERESOURCE VolumeListLock;
303 LIST_ENTRY VolumeListHead;
304 NPAGED_LOOKASIDE_LIST FcbLookasideList;
305 NPAGED_LOOKASIDE_LIST CcbLookasideList;
306 NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
307 FAST_IO_DISPATCH FastIoDispatch;
308 CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
309 } VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
310
311 extern PVFAT_GLOBAL_DATA VfatGlobalData;
312
313 #define FCB_CACHE_INITIALIZED 0x0001
314 #define FCB_DELETE_PENDING 0x0002
315 #define FCB_IS_FAT 0x0004
316 #define FCB_IS_PAGE_FILE 0x0008
317 #define FCB_IS_VOLUME 0x0010
318 #define FCB_IS_DIRTY 0x0020
319 #define FCB_IS_FATX_ENTRY 0x0040
320
321 typedef struct _VFATFCB
322 {
323 /* FCB header required by ROS/NT */
324 FSRTL_COMMON_FCB_HEADER RFCB;
325 SECTION_OBJECT_POINTERS SectionObjectPointers;
326 ERESOURCE MainResource;
327 ERESOURCE PagingIoResource;
328 /* end FCB header required by ROS/NT */
329
330 /* directory entry for this file or directory */
331 DIR_ENTRY entry;
332
333 /* Pointer to attributes in entry */
334 PUCHAR Attributes;
335
336 /* long file name, points into PathNameBuffer */
337 UNICODE_STRING LongNameU;
338
339 /* short file name */
340 UNICODE_STRING ShortNameU;
341
342 /* directory name, points into PathNameBuffer */
343 UNICODE_STRING DirNameU;
344
345 /* path + long file name 260 max*/
346 UNICODE_STRING PathNameU;
347
348 /* buffer for PathNameU */
349 PWCHAR PathNameBuffer;
350
351 /* buffer for ShortNameU */
352 WCHAR ShortNameBuffer[13];
353
354 /* */
355 LONG RefCount;
356
357 /* List of FCB's for this volume */
358 LIST_ENTRY FcbListEntry;
359
360 /* pointer to the parent fcb */
361 struct _VFATFCB* parentFcb;
362
363 /* Flags for the fcb */
364 ULONG Flags;
365
366 /* pointer to the file object which has initialized the fcb */
367 PFILE_OBJECT FileObject;
368
369 /* Directory index for the short name entry */
370 ULONG dirIndex;
371
372 /* Directory index where the long name starts */
373 ULONG startIndex;
374
375 /* Share access for the file object */
376 SHARE_ACCESS FCBShareAccess;
377
378 /* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
379 ULONG OpenHandleCount;
380
381 /* Entry into the hash table for the path + long name */
382 HASHENTRY Hash;
383
384 /* Entry into the hash table for the path + short name */
385 HASHENTRY ShortHash;
386
387 /* List of byte-range locks for this file */
388 FILE_LOCK FileLock;
389
390 /*
391 * Optimalization: caching of last read/write cluster+offset pair. Can't
392 * be in VFATCCB because it must be reset everytime the allocated clusters
393 * change.
394 */
395 FAST_MUTEX LastMutex;
396 ULONG LastCluster;
397 ULONG LastOffset;
398 } VFATFCB, *PVFATFCB;
399
400 typedef struct _VFATCCB
401 {
402 LARGE_INTEGER CurrentByteOffset;
403 /* for DirectoryControl */
404 ULONG Entry;
405 /* for DirectoryControl */
406 UNICODE_STRING SearchPattern;
407 } VFATCCB, *PVFATCCB;
408
409 #ifndef TAG
410 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
411 #endif
412
413 #define TAG_CCB TAG('V', 'C', 'C', 'B')
414 #define TAG_FCB TAG('V', 'F', 'C', 'B')
415 #define TAG_IRP TAG('V', 'I', 'R', 'P')
416
417 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
418
419 typedef struct __DOSTIME
420 {
421 USHORT Second:5;
422 USHORT Minute:6;
423 USHORT Hour:5;
424 }
425 DOSTIME, *PDOSTIME;
426
427 typedef struct __DOSDATE
428 {
429 USHORT Day:5;
430 USHORT Month:4;
431 USHORT Year:5;
432 }
433 DOSDATE, *PDOSDATE;
434
435 #define IRPCONTEXT_CANWAIT 0x0001
436 #define IRPCONTEXT_PENDINGRETURNED 0x0002
437
438 typedef struct
439 {
440 PIRP Irp;
441 PDEVICE_OBJECT DeviceObject;
442 PDEVICE_EXTENSION DeviceExt;
443 ULONG Flags;
444 WORK_QUEUE_ITEM WorkQueueItem;
445 PIO_STACK_LOCATION Stack;
446 UCHAR MajorFunction;
447 UCHAR MinorFunction;
448 PFILE_OBJECT FileObject;
449 ULONG RefCount;
450 KEVENT Event;
451 } VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
452
453 typedef struct _VFAT_DIRENTRY_CONTEXT
454 {
455 ULONG StartIndex;
456 ULONG DirIndex;
457 DIR_ENTRY DirEntry;
458 UNICODE_STRING LongNameU;
459 UNICODE_STRING ShortNameU;
460 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
461
462
463 /* ------------------------------------------------------ shutdown.c */
464
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 NTSTATUS NTAPI VfatBuildRequest (PDEVICE_OBJECT DeviceObject,
765 PIRP Irp);
766
767 PVOID VfatGetUserBuffer(IN PIRP);
768
769 NTSTATUS VfatLockUserBuffer(IN PIRP, IN ULONG,
770 IN LOCK_OPERATION);
771
772 NTSTATUS
773 VfatSetExtendedAttributes(PFILE_OBJECT FileObject,
774 PVOID Ea,
775 ULONG EaLength);
776 /* ------------------------------------------------------------- flush.c */
777
778 NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext);
779
780 NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb);
781
782
783 /* EOF */