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