7887945e220b282f4c99ab026fddb5fd0f14e2d0
[reactos.git] / reactos / drivers / filesystems / fastfat / vfat.h
1 #ifndef _FASTFAT_PCH_
2 #define _FASTFAT_PCH_
3
4 #include <ntifs.h>
5 #include <ntdddisk.h>
6 #include <dos.h>
7 #include <pseh/pseh2.h>
8
9 #ifdef __GNUC__
10 #define INIT_SECTION __attribute__((section ("INIT")))
11 #else
12 #define INIT_SECTION /* Done via alloc_text for MSC */
13 #endif
14
15 #define USE_ROS_CC_AND_FS
16 #if 0
17 #ifndef _MSC_VER
18 #define ENABLE_SWAPOUT
19 #endif
20 #endif
21
22 #define ROUND_DOWN(n, align) \
23 (((ULONG)n) & ~((align) - 1l))
24
25 #define ROUND_UP(n, align) \
26 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
27
28 #define ROUND_DOWN_64(n, align) \
29 (((ULONGLONG)n) & ~((align) - 1LL))
30
31 #define ROUND_UP_64(n, align) \
32 ROUND_DOWN_64(((ULONGLONG)n) + (align) - 1LL, (align))
33
34 #include <pshpack1.h>
35 struct _BootSector
36 {
37 unsigned char magic0, res0, magic1;
38 unsigned char OEMName[8];
39 unsigned short BytesPerSector;
40 unsigned char SectorsPerCluster;
41 unsigned short ReservedSectors;
42 unsigned char FATCount;
43 unsigned short RootEntries, Sectors;
44 unsigned char Media;
45 unsigned short FATSectors, SectorsPerTrack, Heads;
46 unsigned long HiddenSectors, SectorsHuge;
47 unsigned char Drive, Res1, Sig;
48 unsigned long VolumeID;
49 unsigned char VolumeLabel[11], SysType[8];
50 unsigned char Res2[448];
51 unsigned short Signatur1;
52 };
53
54 struct _BootSector32
55 {
56 unsigned char magic0, res0, magic1; // 0
57 unsigned char OEMName[8]; // 3
58 unsigned short BytesPerSector; // 11
59 unsigned char SectorsPerCluster; // 13
60 unsigned short ReservedSectors; // 14
61 unsigned char FATCount; // 16
62 unsigned short RootEntries, Sectors; // 17
63 unsigned char Media; // 21
64 unsigned short FATSectors, SectorsPerTrack, Heads; // 22
65 unsigned long HiddenSectors, SectorsHuge; // 28
66 unsigned long FATSectors32; // 36
67 unsigned short ExtFlag; // 40
68 unsigned short FSVersion; // 42
69 unsigned long RootCluster; // 44
70 unsigned short FSInfoSector; // 48
71 unsigned short BootBackup; // 50
72 unsigned char Res3[12]; // 52
73 unsigned char Drive; // 64
74 unsigned char Res4; // 65
75 unsigned char ExtBootSignature; // 66
76 unsigned long VolumeID; // 67
77 unsigned char VolumeLabel[11], SysType[8]; // 71
78 unsigned char Res2[420]; // 90
79 unsigned short Signature1; // 510
80 };
81
82 struct _BootSectorFatX
83 {
84 unsigned char SysType[4]; // 0
85 unsigned long VolumeID; // 4
86 unsigned long SectorsPerCluster; // 8
87 unsigned short FATCount; // 12
88 unsigned long Unknown; // 14
89 unsigned char Unused[4078]; // 18
90 };
91
92 struct _FsInfoSector
93 {
94 unsigned long ExtBootSignature2; // 0
95 unsigned char Res6[480]; // 4
96 unsigned long FSINFOSignature; // 484
97 unsigned long FreeCluster; // 488
98 unsigned long NextCluster; // 492
99 unsigned char Res7[12]; // 496
100 unsigned long Signatur2; // 508
101 };
102
103 typedef struct _BootSector BootSector;
104
105 struct _FATDirEntry
106 {
107 union
108 {
109 struct { unsigned char Filename[8], Ext[3]; };
110 unsigned char ShortName[11];
111 };
112 unsigned char Attrib;
113 unsigned char lCase;
114 unsigned char CreationTimeMs;
115 unsigned short CreationTime,CreationDate,AccessDate;
116 union
117 {
118 unsigned short FirstClusterHigh; // FAT32
119 unsigned short ExtendedAttributes; // FAT12/FAT16
120 };
121 unsigned short UpdateTime; //time create/update
122 unsigned short UpdateDate; //date create/update
123 unsigned short FirstCluster;
124 unsigned long FileSize;
125 };
126
127 #define FAT_EAFILE "EA DATA. SF"
128
129 typedef struct _EAFileHeader FAT_EA_FILE_HEADER, *PFAT_EA_FILE_HEADER;
130
131 struct _EAFileHeader
132 {
133 unsigned short Signature; // ED
134 unsigned short Unknown[15];
135 unsigned short EASetTable[240];
136 };
137
138 typedef struct _EASetHeader FAT_EA_SET_HEADER, *PFAT_EA_SET_HEADER;
139
140 struct _EASetHeader
141 {
142 unsigned short Signature; // EA
143 unsigned short Offset; // relative offset, same value as in the EASetTable
144 unsigned short Unknown1[2];
145 char TargetFileName[12];
146 unsigned short Unknown2[3];
147 unsigned int EALength;
148 // EA Header
149 };
150
151 typedef struct _EAHeader FAT_EA_HEADER, *PFAT_EA_HEADER;
152
153 struct _EAHeader
154 {
155 unsigned char Unknown;
156 unsigned char EANameLength;
157 unsigned short EAValueLength;
158 // Name Data
159 // Value Data
160 };
161
162 typedef struct _FATDirEntry FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
163
164 struct _FATXDirEntry
165 {
166 unsigned char FilenameLength; // 0
167 unsigned char Attrib; // 1
168 unsigned char Filename[42]; // 2
169 unsigned long FirstCluster; // 44
170 unsigned long FileSize; // 48
171 unsigned short UpdateTime; // 52
172 unsigned short UpdateDate; // 54
173 unsigned short CreationTime; // 56
174 unsigned short CreationDate; // 58
175 unsigned short AccessTime; // 60
176 unsigned short AccessDate; // 62
177 };
178
179 struct _slot
180 {
181 unsigned char id; // sequence number for slot
182 WCHAR name0_4[5]; // first 5 characters in name
183 unsigned char attr; // attribute byte
184 unsigned char reserved; // always 0
185 unsigned char alias_checksum; // checksum for 8.3 alias
186 WCHAR name5_10[6]; // 6 more characters in name
187 unsigned char start[2]; // starting cluster number
188 WCHAR name11_12[2]; // last 2 characters in name
189 };
190
191 typedef struct _slot slot;
192
193 #include <poppack.h>
194
195 #define VFAT_CASE_LOWER_BASE 8 // base is lower case
196 #define VFAT_CASE_LOWER_EXT 16 // extension is lower case
197
198 #define LONGNAME_MAX_LENGTH 256 // max length for a long filename
199
200 #define ENTRY_DELETED(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
201 #define ENTRY_VOLUME(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
202 #define ENTRY_END(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
203
204 #define FAT_ENTRY_DELETED(DirEntry) ((DirEntry)->Filename[0] == 0xe5)
205 #define FAT_ENTRY_END(DirEntry) ((DirEntry)->Filename[0] == 0)
206 #define FAT_ENTRY_LONG(DirEntry) (((DirEntry)->Attrib & 0x3f) == 0x0f)
207 #define FAT_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
208
209 #define FATX_ENTRY_DELETED(DirEntry) ((DirEntry)->FilenameLength == 0xe5)
210 #define FATX_ENTRY_END(DirEntry) ((DirEntry)->FilenameLength == 0xff)
211 #define FATX_ENTRY_LONG(DirEntry) (FALSE)
212 #define FATX_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
213
214 #define FAT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FAT_DIR_ENTRY))
215 #define FATX_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FATX_DIR_ENTRY))
216
217 typedef struct _FATXDirEntry FATX_DIR_ENTRY, *PFATX_DIR_ENTRY;
218
219 union _DIR_ENTRY
220 {
221 FAT_DIR_ENTRY Fat;
222 FATX_DIR_ENTRY FatX;
223 };
224
225 typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
226
227 #define BLOCKSIZE 512
228
229 #define FAT16 (1)
230 #define FAT12 (2)
231 #define FAT32 (3)
232 #define FATX16 (4)
233 #define FATX32 (5)
234
235 #define VCB_VOLUME_LOCKED 0x0001
236 #define VCB_DISMOUNT_PENDING 0x0002
237 #define VCB_IS_FATX 0x0004
238 #define VCB_IS_DIRTY 0x4000 /* Volume is dirty */
239 #define VCB_CLEAR_DIRTY 0x8000 /* Clean dirty flag at shutdown */
240
241 typedef struct
242 {
243 ULONG VolumeID;
244 CHAR VolumeLabel[11];
245 ULONG FATStart;
246 ULONG FATCount;
247 ULONG FATSectors;
248 ULONG rootDirectorySectors;
249 ULONG rootStart;
250 ULONG dataStart;
251 ULONG RootCluster;
252 ULONG SectorsPerCluster;
253 ULONG BytesPerSector;
254 ULONG BytesPerCluster;
255 ULONG NumberOfClusters;
256 ULONG FatType;
257 ULONG Sectors;
258 BOOLEAN FixedMedia;
259 } FATINFO, *PFATINFO;
260
261 struct _VFATFCB;
262 struct _VFAT_DIRENTRY_CONTEXT;
263 struct _VFAT_MOVE_CONTEXT;
264
265 typedef struct _HASHENTRY
266 {
267 ULONG Hash;
268 struct _VFATFCB* self;
269 struct _HASHENTRY* next;
270 }
271 HASHENTRY;
272
273 typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
274
275 typedef NTSTATUS (*PGET_NEXT_CLUSTER)(PDEVICE_EXTENSION,ULONG,PULONG);
276 typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
277 typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
278
279 typedef BOOLEAN (*PIS_DIRECTORY_EMPTY)(struct _VFATFCB*);
280 typedef NTSTATUS (*PADD_ENTRY)(PDEVICE_EXTENSION,PUNICODE_STRING,struct _VFATFCB**,struct _VFATFCB*,ULONG,UCHAR,struct _VFAT_MOVE_CONTEXT*);
281 typedef NTSTATUS (*PDEL_ENTRY)(PDEVICE_EXTENSION,struct _VFATFCB*,struct _VFAT_MOVE_CONTEXT*);
282 typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
283
284 typedef struct _VFAT_DISPATCH
285 {
286 PIS_DIRECTORY_EMPTY IsDirectoryEmpty;
287 PADD_ENTRY AddEntry;
288 PDEL_ENTRY DelEntry;
289 PGET_NEXT_DIR_ENTRY GetNextDirEntry;
290 } VFAT_DISPATCH, *PVFAT_DISPATCH;
291
292 typedef struct DEVICE_EXTENSION
293 {
294 ERESOURCE DirResource;
295 ERESOURCE FatResource;
296
297 KSPIN_LOCK FcbListLock;
298 LIST_ENTRY FcbListHead;
299 ULONG HashTableSize;
300 struct _HASHENTRY **FcbHashTable;
301
302 PDEVICE_OBJECT VolumeDevice;
303 PDEVICE_OBJECT StorageDevice;
304 PFILE_OBJECT FATFileObject;
305 FATINFO FatInfo;
306 ULONG LastAvailableCluster;
307 ULONG AvailableClusters;
308 BOOLEAN AvailableClustersValid;
309 ULONG Flags;
310 struct _VFATFCB *VolumeFcb;
311
312 /* Pointers to functions for manipulating FAT. */
313 PGET_NEXT_CLUSTER GetNextCluster;
314 PFIND_AND_MARK_AVAILABLE_CLUSTER FindAndMarkAvailableCluster;
315 PWRITE_CLUSTER WriteCluster;
316 ULONG CleanShutBitMask;
317
318 ULONG BaseDateYear;
319
320 LIST_ENTRY VolumeListEntry;
321
322 /* Notifications */
323 LIST_ENTRY NotifyList;
324 PNOTIFY_SYNC NotifySync;
325
326 /* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE */
327 ULONG OpenHandleCount;
328
329 /* VPBs for dismount */
330 PVPB IoVPB;
331 PVPB SpareVPB;
332
333 /* Pointers to functions for manipulating directory entries. */
334 VFAT_DISPATCH Dispatch;
335 } DEVICE_EXTENSION, VCB, *PVCB;
336
337 FORCEINLINE
338 BOOLEAN
339 VfatIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt,
340 struct _VFATFCB* Fcb)
341 {
342 return DeviceExt->Dispatch.IsDirectoryEmpty(Fcb);
343 }
344
345 FORCEINLINE
346 NTSTATUS
347 VfatAddEntry(PDEVICE_EXTENSION DeviceExt,
348 PUNICODE_STRING NameU,
349 struct _VFATFCB** Fcb,
350 struct _VFATFCB* ParentFcb,
351 ULONG RequestedOptions,
352 UCHAR ReqAttr,
353 struct _VFAT_MOVE_CONTEXT* MoveContext)
354 {
355 return DeviceExt->Dispatch.AddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr, MoveContext);
356 }
357
358 FORCEINLINE
359 NTSTATUS
360 VfatDelEntry(PDEVICE_EXTENSION DeviceExt,
361 struct _VFATFCB* Fcb,
362 struct _VFAT_MOVE_CONTEXT* MoveContext)
363 {
364 return DeviceExt->Dispatch.DelEntry(DeviceExt, Fcb, MoveContext);
365 }
366
367 FORCEINLINE
368 NTSTATUS
369 VfatGetNextDirEntry(PDEVICE_EXTENSION DeviceExt,
370 PVOID *pContext,
371 PVOID *pPage,
372 struct _VFATFCB* pDirFcb,
373 struct _VFAT_DIRENTRY_CONTEXT* DirContext,
374 BOOLEAN First)
375 {
376 return DeviceExt->Dispatch.GetNextDirEntry(pContext, pPage, pDirFcb, DirContext, First);
377 }
378
379 #define VFAT_BREAK_ON_CORRUPTION 1
380
381 typedef struct
382 {
383 PDRIVER_OBJECT DriverObject;
384 PDEVICE_OBJECT DeviceObject;
385 ULONG Flags;
386 ERESOURCE VolumeListLock;
387 LIST_ENTRY VolumeListHead;
388 NPAGED_LOOKASIDE_LIST FcbLookasideList;
389 NPAGED_LOOKASIDE_LIST CcbLookasideList;
390 NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
391 FAST_IO_DISPATCH FastIoDispatch;
392 CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
393 } VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
394
395 extern PVFAT_GLOBAL_DATA VfatGlobalData;
396
397 #define FCB_CACHE_INITIALIZED 0x0001
398 #define FCB_DELETE_PENDING 0x0002
399 #define FCB_IS_FAT 0x0004
400 #define FCB_IS_PAGE_FILE 0x0008
401 #define FCB_IS_VOLUME 0x0010
402 #define FCB_IS_DIRTY 0x0020
403
404 typedef struct _VFATFCB
405 {
406 /* FCB header required by ROS/NT */
407 FSRTL_COMMON_FCB_HEADER RFCB;
408 SECTION_OBJECT_POINTERS SectionObjectPointers;
409 ERESOURCE MainResource;
410 ERESOURCE PagingIoResource;
411 /* end FCB header required by ROS/NT */
412
413 /* directory entry for this file or directory */
414 DIR_ENTRY entry;
415
416 /* Pointer to attributes in entry */
417 PUCHAR Attributes;
418
419 /* long file name, points into PathNameBuffer */
420 UNICODE_STRING LongNameU;
421
422 /* short file name */
423 UNICODE_STRING ShortNameU;
424
425 /* directory name, points into PathNameBuffer */
426 UNICODE_STRING DirNameU;
427
428 /* path + long file name 260 max*/
429 UNICODE_STRING PathNameU;
430
431 /* buffer for PathNameU */
432 PWCHAR PathNameBuffer;
433
434 /* buffer for ShortNameU */
435 WCHAR ShortNameBuffer[13];
436
437 /* */
438 LONG RefCount;
439
440 /* List of FCB's for this volume */
441 LIST_ENTRY FcbListEntry;
442
443 /* List of FCB's for the parent */
444 LIST_ENTRY ParentListEntry;
445
446 /* pointer to the parent fcb */
447 struct _VFATFCB *parentFcb;
448
449 /* List for the children */
450 LIST_ENTRY ParentListHead;
451
452 /* Flags for the fcb */
453 ULONG Flags;
454
455 /* pointer to the file object which has initialized the fcb */
456 PFILE_OBJECT FileObject;
457
458 /* Directory index for the short name entry */
459 ULONG dirIndex;
460
461 /* Directory index where the long name starts */
462 ULONG startIndex;
463
464 /* Share access for the file object */
465 SHARE_ACCESS FCBShareAccess;
466
467 /* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
468 ULONG OpenHandleCount;
469
470 /* Entry into the hash table for the path + long name */
471 HASHENTRY Hash;
472
473 /* Entry into the hash table for the path + short name */
474 HASHENTRY ShortHash;
475
476 /* List of byte-range locks for this file */
477 FILE_LOCK FileLock;
478
479 /*
480 * Optimization: caching of last read/write cluster+offset pair. Can't
481 * be in VFATCCB because it must be reset everytime the allocated clusters
482 * change.
483 */
484 FAST_MUTEX LastMutex;
485 ULONG LastCluster;
486 ULONG LastOffset;
487 } VFATFCB, *PVFATFCB;
488
489 typedef struct _VFATCCB
490 {
491 LARGE_INTEGER CurrentByteOffset;
492 /* for DirectoryControl */
493 ULONG Entry;
494 /* for DirectoryControl */
495 UNICODE_STRING SearchPattern;
496 } VFATCCB, *PVFATCCB;
497
498 #define TAG_CCB 'BCCV'
499 #define TAG_FCB 'BCFV'
500 #define TAG_IRP 'PRIV'
501 #define TAG_VFAT 'TAFV'
502
503 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
504
505 typedef struct __DOSTIME
506 {
507 USHORT Second:5;
508 USHORT Minute:6;
509 USHORT Hour:5;
510 }
511 DOSTIME, *PDOSTIME;
512
513 typedef struct __DOSDATE
514 {
515 USHORT Day:5;
516 USHORT Month:4;
517 USHORT Year:7;
518 }
519 DOSDATE, *PDOSDATE;
520
521 #define IRPCONTEXT_CANWAIT 0x0001
522 #define IRPCONTEXT_COMPLETE 0x0002
523 #define IRPCONTEXT_QUEUE 0x0004
524 #define IRPCONTEXT_PENDINGRETURNED 0x0008
525
526 typedef struct
527 {
528 PIRP Irp;
529 PDEVICE_OBJECT DeviceObject;
530 PDEVICE_EXTENSION DeviceExt;
531 ULONG Flags;
532 WORK_QUEUE_ITEM WorkQueueItem;
533 PIO_STACK_LOCATION Stack;
534 UCHAR MajorFunction;
535 UCHAR MinorFunction;
536 PFILE_OBJECT FileObject;
537 ULONG RefCount;
538 KEVENT Event;
539 CCHAR PriorityBoost;
540 } VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
541
542 typedef struct _VFAT_DIRENTRY_CONTEXT
543 {
544 ULONG StartIndex;
545 ULONG DirIndex;
546 DIR_ENTRY DirEntry;
547 UNICODE_STRING LongNameU;
548 UNICODE_STRING ShortNameU;
549 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
550
551 typedef struct _VFAT_MOVE_CONTEXT
552 {
553 ULONG FirstCluster;
554 ULONG FileSize;
555 USHORT CreationDate;
556 USHORT CreationTime;
557 BOOLEAN InPlace;
558 } VFAT_MOVE_CONTEXT, *PVFAT_MOVE_CONTEXT;
559
560 FORCEINLINE
561 NTSTATUS
562 VfatMarkIrpContextForQueue(PVFAT_IRP_CONTEXT IrpContext)
563 {
564 PULONG Flags = &IrpContext->Flags;
565
566 *Flags &= ~IRPCONTEXT_COMPLETE;
567 *Flags |= IRPCONTEXT_QUEUE;
568
569 return STATUS_PENDING;
570 }
571
572 FORCEINLINE
573 BOOLEAN
574 vfatFCBIsDirectory(PVFATFCB FCB)
575 {
576 return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_DIRECTORY);
577 }
578
579 FORCEINLINE
580 BOOLEAN
581 vfatFCBIsReadOnly(PVFATFCB FCB)
582 {
583 return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_READONLY);
584 }
585
586 FORCEINLINE
587 BOOLEAN
588 vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
589 {
590 return BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX);
591 }
592
593 /* blockdev.c */
594
595 NTSTATUS
596 VfatReadDisk(
597 IN PDEVICE_OBJECT pDeviceObject,
598 IN PLARGE_INTEGER ReadOffset,
599 IN ULONG ReadLength,
600 IN PUCHAR Buffer,
601 IN BOOLEAN Override);
602
603 NTSTATUS
604 VfatReadDiskPartial(
605 IN PVFAT_IRP_CONTEXT IrpContext,
606 IN PLARGE_INTEGER ReadOffset,
607 IN ULONG ReadLength,
608 IN ULONG BufferOffset,
609 IN BOOLEAN Wait);
610
611 NTSTATUS
612 VfatWriteDiskPartial(
613 IN PVFAT_IRP_CONTEXT IrpContext,
614 IN PLARGE_INTEGER WriteOffset,
615 IN ULONG WriteLength,
616 IN ULONG BufferOffset,
617 IN BOOLEAN Wait);
618
619 NTSTATUS
620 VfatBlockDeviceIoControl(
621 IN PDEVICE_OBJECT DeviceObject,
622 IN ULONG CtlCode,
623 IN PVOID InputBuffer,
624 IN ULONG InputBufferSize,
625 IN OUT PVOID OutputBuffer,
626 IN OUT PULONG pOutputBufferSize,
627 IN BOOLEAN Override);
628
629 /* cleanup.c */
630
631 NTSTATUS
632 VfatCleanup(
633 PVFAT_IRP_CONTEXT IrpContext);
634
635 /* close.c */
636
637 NTSTATUS
638 VfatClose(
639 PVFAT_IRP_CONTEXT IrpContext);
640
641 NTSTATUS
642 VfatCloseFile(
643 PDEVICE_EXTENSION DeviceExt,
644 PFILE_OBJECT FileObject);
645
646 /* create.c */
647
648 NTSTATUS
649 VfatCreate(
650 PVFAT_IRP_CONTEXT IrpContext);
651
652 NTSTATUS
653 FindFile(
654 PDEVICE_EXTENSION DeviceExt,
655 PVFATFCB Parent,
656 PUNICODE_STRING FileToFindU,
657 PVFAT_DIRENTRY_CONTEXT DirContext,
658 BOOLEAN First);
659
660 VOID
661 vfat8Dot3ToString(
662 PFAT_DIR_ENTRY pEntry,
663 PUNICODE_STRING NameU);
664
665 /* dir.c */
666
667 NTSTATUS
668 VfatDirectoryControl(
669 PVFAT_IRP_CONTEXT IrpContext);
670
671 BOOLEAN
672 FsdDosDateTimeToSystemTime(
673 PDEVICE_EXTENSION DeviceExt,
674 USHORT DosDate,
675 USHORT DosTime,
676 PLARGE_INTEGER SystemTime);
677
678 BOOLEAN
679 FsdSystemTimeToDosDateTime(
680 PDEVICE_EXTENSION DeviceExt,
681 PLARGE_INTEGER SystemTime,
682 USHORT *pDosDate,
683 USHORT *pDosTime);
684
685 /* direntry.c */
686
687 ULONG
688 vfatDirEntryGetFirstCluster(
689 PDEVICE_EXTENSION pDeviceExt,
690 PDIR_ENTRY pDirEntry);
691
692 /* dirwr.c */
693
694 NTSTATUS
695 VfatUpdateEntry(
696 PVFATFCB pFcb,
697 IN BOOLEAN IsFatX);
698
699 BOOLEAN
700 vfatFindDirSpace(
701 PDEVICE_EXTENSION DeviceExt,
702 PVFATFCB pDirFcb,
703 ULONG nbSlots,
704 PULONG start);
705
706 NTSTATUS
707 vfatRenameEntry(
708 IN PDEVICE_EXTENSION DeviceExt,
709 IN PVFATFCB pFcb,
710 IN PUNICODE_STRING FileName,
711 IN BOOLEAN CaseChangeOnly);
712
713 NTSTATUS
714 VfatMoveEntry(
715 IN PDEVICE_EXTENSION DeviceExt,
716 IN PVFATFCB pFcb,
717 IN PUNICODE_STRING FileName,
718 IN PVFATFCB ParentFcb);
719
720 /* ea.h */
721
722 NTSTATUS
723 VfatSetExtendedAttributes(
724 PFILE_OBJECT FileObject,
725 PVOID Ea,
726 ULONG EaLength);
727
728 /* fastio.c */
729
730 VOID
731 VfatInitFastIoRoutines(
732 PFAST_IO_DISPATCH FastIoDispatch);
733
734 BOOLEAN
735 NTAPI
736 VfatAcquireForLazyWrite(
737 IN PVOID Context,
738 IN BOOLEAN Wait);
739
740 VOID
741 NTAPI
742 VfatReleaseFromLazyWrite(
743 IN PVOID Context);
744
745 BOOLEAN
746 NTAPI
747 VfatAcquireForReadAhead(
748 IN PVOID Context,
749 IN BOOLEAN Wait);
750
751 VOID
752 NTAPI
753 VfatReleaseFromReadAhead(
754 IN PVOID Context);
755
756 /* fat.c */
757
758 NTSTATUS
759 FAT12GetNextCluster(
760 PDEVICE_EXTENSION DeviceExt,
761 ULONG CurrentCluster,
762 PULONG NextCluster);
763
764 NTSTATUS
765 FAT12FindAndMarkAvailableCluster(
766 PDEVICE_EXTENSION DeviceExt,
767 PULONG Cluster);
768
769 NTSTATUS
770 FAT12WriteCluster(
771 PDEVICE_EXTENSION DeviceExt,
772 ULONG ClusterToWrite,
773 ULONG NewValue,
774 PULONG OldValue);
775
776 NTSTATUS
777 FAT16GetNextCluster(
778 PDEVICE_EXTENSION DeviceExt,
779 ULONG CurrentCluster,
780 PULONG NextCluster);
781
782 NTSTATUS
783 FAT16FindAndMarkAvailableCluster(
784 PDEVICE_EXTENSION DeviceExt,
785 PULONG Cluster);
786
787 NTSTATUS
788 FAT16WriteCluster(
789 PDEVICE_EXTENSION DeviceExt,
790 ULONG ClusterToWrite,
791 ULONG NewValue,
792 PULONG OldValue);
793
794 NTSTATUS
795 FAT32GetNextCluster(
796 PDEVICE_EXTENSION DeviceExt,
797 ULONG CurrentCluster,
798 PULONG NextCluster);
799
800 NTSTATUS
801 FAT32FindAndMarkAvailableCluster(
802 PDEVICE_EXTENSION DeviceExt,
803 PULONG Cluster);
804
805 NTSTATUS
806 FAT32WriteCluster(
807 PDEVICE_EXTENSION DeviceExt,
808 ULONG ClusterToWrite,
809 ULONG NewValue,
810 PULONG OldValue);
811
812 NTSTATUS
813 OffsetToCluster(
814 PDEVICE_EXTENSION DeviceExt,
815 ULONG FirstCluster,
816 ULONG FileOffset,
817 PULONG Cluster,
818 BOOLEAN Extend);
819
820 ULONGLONG
821 ClusterToSector(
822 PDEVICE_EXTENSION DeviceExt,
823 ULONG Cluster);
824
825 NTSTATUS
826 GetNextCluster(
827 PDEVICE_EXTENSION DeviceExt,
828 ULONG CurrentCluster,
829 PULONG NextCluster);
830
831 NTSTATUS
832 GetNextClusterExtend(
833 PDEVICE_EXTENSION DeviceExt,
834 ULONG CurrentCluster,
835 PULONG NextCluster);
836
837 NTSTATUS
838 CountAvailableClusters(
839 PDEVICE_EXTENSION DeviceExt,
840 PLARGE_INTEGER Clusters);
841
842 NTSTATUS
843 WriteCluster(
844 PDEVICE_EXTENSION DeviceExt,
845 ULONG ClusterToWrite,
846 ULONG NewValue);
847
848 /* fcb.c */
849
850 PVFATFCB
851 vfatNewFCB(
852 PDEVICE_EXTENSION pVCB,
853 PUNICODE_STRING pFileNameU);
854
855 NTSTATUS
856 vfatSetFCBNewDirName(
857 PDEVICE_EXTENSION pVCB,
858 PVFATFCB Fcb,
859 PVFATFCB ParentFcb);
860
861 NTSTATUS
862 vfatUpdateFCB(
863 PDEVICE_EXTENSION pVCB,
864 PVFATFCB Fcb,
865 PVFAT_DIRENTRY_CONTEXT DirContext,
866 PVFATFCB ParentFcb);
867
868 VOID
869 vfatDestroyFCB(
870 PVFATFCB pFCB);
871
872 VOID
873 vfatDestroyCCB(
874 PVFATCCB pCcb);
875
876 VOID
877 vfatGrabFCB(
878 PDEVICE_EXTENSION pVCB,
879 PVFATFCB pFCB);
880
881 VOID
882 vfatReleaseFCB(
883 PDEVICE_EXTENSION pVCB,
884 PVFATFCB pFCB);
885
886 PVFATFCB
887 vfatGrabFCBFromTable(
888 PDEVICE_EXTENSION pDeviceExt,
889 PUNICODE_STRING pFileNameU);
890
891 PVFATFCB
892 vfatMakeRootFCB(
893 PDEVICE_EXTENSION pVCB);
894
895 PVFATFCB
896 vfatOpenRootFCB(
897 PDEVICE_EXTENSION pVCB);
898
899 BOOLEAN
900 vfatFCBIsDirectory(
901 PVFATFCB FCB);
902
903 BOOLEAN
904 vfatFCBIsRoot(
905 PVFATFCB FCB);
906
907 NTSTATUS
908 vfatAttachFCBToFileObject(
909 PDEVICE_EXTENSION vcb,
910 PVFATFCB fcb,
911 PFILE_OBJECT fileObject);
912
913 NTSTATUS
914 vfatDirFindFile(
915 PDEVICE_EXTENSION pVCB,
916 PVFATFCB parentFCB,
917 PUNICODE_STRING FileToFindU,
918 PVFATFCB *fileFCB);
919
920 NTSTATUS
921 vfatGetFCBForFile(
922 PDEVICE_EXTENSION pVCB,
923 PVFATFCB *pParentFCB,
924 PVFATFCB *pFCB,
925 PUNICODE_STRING pFileNameU);
926
927 NTSTATUS
928 vfatMakeFCBFromDirEntry(
929 PVCB vcb,
930 PVFATFCB directoryFCB,
931 PVFAT_DIRENTRY_CONTEXT DirContext,
932 PVFATFCB *fileFCB);
933
934 /* finfo.c */
935
936 NTSTATUS
937 VfatGetStandardInformation(
938 PVFATFCB FCB,
939 PFILE_STANDARD_INFORMATION StandardInfo,
940 PULONG BufferLength);
941
942 NTSTATUS
943 VfatGetBasicInformation(
944 PFILE_OBJECT FileObject,
945 PVFATFCB FCB,
946 PDEVICE_OBJECT DeviceObject,
947 PFILE_BASIC_INFORMATION BasicInfo,
948 PULONG BufferLength);
949
950 NTSTATUS
951 VfatQueryInformation(
952 PVFAT_IRP_CONTEXT IrpContext);
953
954 NTSTATUS
955 VfatSetInformation(
956 PVFAT_IRP_CONTEXT IrpContext);
957
958 NTSTATUS
959 VfatSetAllocationSizeInformation(
960 PFILE_OBJECT FileObject,
961 PVFATFCB Fcb,
962 PDEVICE_EXTENSION DeviceExt,
963 PLARGE_INTEGER AllocationSize);
964
965 /* flush.c */
966
967 NTSTATUS
968 VfatFlush(
969 PVFAT_IRP_CONTEXT IrpContext);
970
971 NTSTATUS
972 VfatFlushVolume(
973 PDEVICE_EXTENSION DeviceExt,
974 PVFATFCB VolumeFcb);
975
976 /* fsctl.c */
977
978 NTSTATUS
979 VfatFileSystemControl(
980 PVFAT_IRP_CONTEXT IrpContext);
981
982 /* iface.c */
983
984 NTSTATUS
985 NTAPI
986 DriverEntry(
987 PDRIVER_OBJECT DriverObject,
988 PUNICODE_STRING RegistryPath);
989
990
991 /* misc.c */
992
993 DRIVER_DISPATCH
994 VfatBuildRequest;
995
996 NTSTATUS
997 NTAPI
998 VfatBuildRequest(
999 PDEVICE_OBJECT DeviceObject,
1000 PIRP Irp);
1001
1002 PVOID
1003 VfatGetUserBuffer(
1004 IN PIRP,
1005 IN BOOLEAN Paging);
1006
1007 NTSTATUS
1008 VfatLockUserBuffer(
1009 IN PIRP,
1010 IN ULONG,
1011 IN LOCK_OPERATION);
1012
1013 BOOLEAN
1014 VfatCheckForDismount(
1015 IN PDEVICE_EXTENSION DeviceExt,
1016 IN BOOLEAN Create);
1017
1018 /* pnp.c */
1019
1020 NTSTATUS
1021 VfatPnp(
1022 PVFAT_IRP_CONTEXT IrpContext);
1023
1024 /* rw.c */
1025
1026 NTSTATUS
1027 VfatRead(
1028 PVFAT_IRP_CONTEXT IrpContext);
1029
1030 NTSTATUS
1031 VfatWrite(
1032 PVFAT_IRP_CONTEXT IrpContext);
1033
1034 NTSTATUS
1035 NextCluster(
1036 PDEVICE_EXTENSION DeviceExt,
1037 ULONG FirstCluster,
1038 PULONG CurrentCluster,
1039 BOOLEAN Extend);
1040
1041 /* shutdown.c */
1042
1043 DRIVER_DISPATCH
1044 VfatShutdown;
1045
1046 NTSTATUS
1047 NTAPI
1048 VfatShutdown(
1049 PDEVICE_OBJECT DeviceObject,
1050 PIRP Irp);
1051
1052 /* string.c */
1053
1054 VOID
1055 vfatSplitPathName(
1056 PUNICODE_STRING PathNameU,
1057 PUNICODE_STRING DirNameU,
1058 PUNICODE_STRING FileNameU);
1059
1060 BOOLEAN
1061 vfatIsLongIllegal(
1062 WCHAR c);
1063
1064 BOOLEAN
1065 wstrcmpjoki(
1066 PWSTR s1,
1067 PWSTR s2);
1068
1069 /* volume.c */
1070
1071 NTSTATUS
1072 VfatQueryVolumeInformation(
1073 PVFAT_IRP_CONTEXT IrpContext);
1074
1075 NTSTATUS
1076 VfatSetVolumeInformation(
1077 PVFAT_IRP_CONTEXT IrpContext);
1078
1079 #endif /* _FASTFAT_PCH_ */