[FASTFAT]
[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 #define CCB_DELETE_ON_CLOSE 0x0001
490
491 typedef struct _VFATCCB
492 {
493 LARGE_INTEGER CurrentByteOffset;
494 ULONG Flags;
495 /* for DirectoryControl */
496 ULONG Entry;
497 /* for DirectoryControl */
498 UNICODE_STRING SearchPattern;
499 } VFATCCB, *PVFATCCB;
500
501 #define TAG_CCB 'BCCV'
502 #define TAG_FCB 'BCFV'
503 #define TAG_IRP 'PRIV'
504 #define TAG_VFAT 'TAFV'
505
506 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
507
508 typedef struct __DOSTIME
509 {
510 USHORT Second:5;
511 USHORT Minute:6;
512 USHORT Hour:5;
513 }
514 DOSTIME, *PDOSTIME;
515
516 typedef struct __DOSDATE
517 {
518 USHORT Day:5;
519 USHORT Month:4;
520 USHORT Year:7;
521 }
522 DOSDATE, *PDOSDATE;
523
524 #define IRPCONTEXT_CANWAIT 0x0001
525 #define IRPCONTEXT_COMPLETE 0x0002
526 #define IRPCONTEXT_QUEUE 0x0004
527 #define IRPCONTEXT_PENDINGRETURNED 0x0008
528
529 typedef struct
530 {
531 PIRP Irp;
532 PDEVICE_OBJECT DeviceObject;
533 PDEVICE_EXTENSION DeviceExt;
534 ULONG Flags;
535 WORK_QUEUE_ITEM WorkQueueItem;
536 PIO_STACK_LOCATION Stack;
537 UCHAR MajorFunction;
538 UCHAR MinorFunction;
539 PFILE_OBJECT FileObject;
540 ULONG RefCount;
541 KEVENT Event;
542 CCHAR PriorityBoost;
543 } VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
544
545 typedef struct _VFAT_DIRENTRY_CONTEXT
546 {
547 ULONG StartIndex;
548 ULONG DirIndex;
549 DIR_ENTRY DirEntry;
550 UNICODE_STRING LongNameU;
551 UNICODE_STRING ShortNameU;
552 } VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_CONTEXT;
553
554 typedef struct _VFAT_MOVE_CONTEXT
555 {
556 ULONG FirstCluster;
557 ULONG FileSize;
558 USHORT CreationDate;
559 USHORT CreationTime;
560 BOOLEAN InPlace;
561 } VFAT_MOVE_CONTEXT, *PVFAT_MOVE_CONTEXT;
562
563 FORCEINLINE
564 NTSTATUS
565 VfatMarkIrpContextForQueue(PVFAT_IRP_CONTEXT IrpContext)
566 {
567 PULONG Flags = &IrpContext->Flags;
568
569 *Flags &= ~IRPCONTEXT_COMPLETE;
570 *Flags |= IRPCONTEXT_QUEUE;
571
572 return STATUS_PENDING;
573 }
574
575 FORCEINLINE
576 BOOLEAN
577 vfatFCBIsDirectory(PVFATFCB FCB)
578 {
579 return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_DIRECTORY);
580 }
581
582 FORCEINLINE
583 BOOLEAN
584 vfatFCBIsReadOnly(PVFATFCB FCB)
585 {
586 return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_READONLY);
587 }
588
589 FORCEINLINE
590 BOOLEAN
591 vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
592 {
593 return BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX);
594 }
595
596 /* blockdev.c */
597
598 NTSTATUS
599 VfatReadDisk(
600 IN PDEVICE_OBJECT pDeviceObject,
601 IN PLARGE_INTEGER ReadOffset,
602 IN ULONG ReadLength,
603 IN PUCHAR Buffer,
604 IN BOOLEAN Override);
605
606 NTSTATUS
607 VfatReadDiskPartial(
608 IN PVFAT_IRP_CONTEXT IrpContext,
609 IN PLARGE_INTEGER ReadOffset,
610 IN ULONG ReadLength,
611 IN ULONG BufferOffset,
612 IN BOOLEAN Wait);
613
614 NTSTATUS
615 VfatWriteDiskPartial(
616 IN PVFAT_IRP_CONTEXT IrpContext,
617 IN PLARGE_INTEGER WriteOffset,
618 IN ULONG WriteLength,
619 IN ULONG BufferOffset,
620 IN BOOLEAN Wait);
621
622 NTSTATUS
623 VfatBlockDeviceIoControl(
624 IN PDEVICE_OBJECT DeviceObject,
625 IN ULONG CtlCode,
626 IN PVOID InputBuffer,
627 IN ULONG InputBufferSize,
628 IN OUT PVOID OutputBuffer,
629 IN OUT PULONG pOutputBufferSize,
630 IN BOOLEAN Override);
631
632 /* cleanup.c */
633
634 NTSTATUS
635 VfatCleanup(
636 PVFAT_IRP_CONTEXT IrpContext);
637
638 /* close.c */
639
640 NTSTATUS
641 VfatClose(
642 PVFAT_IRP_CONTEXT IrpContext);
643
644 NTSTATUS
645 VfatCloseFile(
646 PDEVICE_EXTENSION DeviceExt,
647 PFILE_OBJECT FileObject);
648
649 /* create.c */
650
651 NTSTATUS
652 VfatCreate(
653 PVFAT_IRP_CONTEXT IrpContext);
654
655 NTSTATUS
656 FindFile(
657 PDEVICE_EXTENSION DeviceExt,
658 PVFATFCB Parent,
659 PUNICODE_STRING FileToFindU,
660 PVFAT_DIRENTRY_CONTEXT DirContext,
661 BOOLEAN First);
662
663 VOID
664 vfat8Dot3ToString(
665 PFAT_DIR_ENTRY pEntry,
666 PUNICODE_STRING NameU);
667
668 /* dir.c */
669
670 NTSTATUS
671 VfatDirectoryControl(
672 PVFAT_IRP_CONTEXT IrpContext);
673
674 BOOLEAN
675 FsdDosDateTimeToSystemTime(
676 PDEVICE_EXTENSION DeviceExt,
677 USHORT DosDate,
678 USHORT DosTime,
679 PLARGE_INTEGER SystemTime);
680
681 BOOLEAN
682 FsdSystemTimeToDosDateTime(
683 PDEVICE_EXTENSION DeviceExt,
684 PLARGE_INTEGER SystemTime,
685 USHORT *pDosDate,
686 USHORT *pDosTime);
687
688 /* direntry.c */
689
690 ULONG
691 vfatDirEntryGetFirstCluster(
692 PDEVICE_EXTENSION pDeviceExt,
693 PDIR_ENTRY pDirEntry);
694
695 /* dirwr.c */
696
697 NTSTATUS
698 VfatUpdateEntry(
699 PVFATFCB pFcb,
700 IN BOOLEAN IsFatX);
701
702 BOOLEAN
703 vfatFindDirSpace(
704 PDEVICE_EXTENSION DeviceExt,
705 PVFATFCB pDirFcb,
706 ULONG nbSlots,
707 PULONG start);
708
709 NTSTATUS
710 vfatRenameEntry(
711 IN PDEVICE_EXTENSION DeviceExt,
712 IN PVFATFCB pFcb,
713 IN PUNICODE_STRING FileName,
714 IN BOOLEAN CaseChangeOnly);
715
716 NTSTATUS
717 VfatMoveEntry(
718 IN PDEVICE_EXTENSION DeviceExt,
719 IN PVFATFCB pFcb,
720 IN PUNICODE_STRING FileName,
721 IN PVFATFCB ParentFcb);
722
723 /* ea.h */
724
725 NTSTATUS
726 VfatSetExtendedAttributes(
727 PFILE_OBJECT FileObject,
728 PVOID Ea,
729 ULONG EaLength);
730
731 /* fastio.c */
732
733 VOID
734 VfatInitFastIoRoutines(
735 PFAST_IO_DISPATCH FastIoDispatch);
736
737 BOOLEAN
738 NTAPI
739 VfatAcquireForLazyWrite(
740 IN PVOID Context,
741 IN BOOLEAN Wait);
742
743 VOID
744 NTAPI
745 VfatReleaseFromLazyWrite(
746 IN PVOID Context);
747
748 BOOLEAN
749 NTAPI
750 VfatAcquireForReadAhead(
751 IN PVOID Context,
752 IN BOOLEAN Wait);
753
754 VOID
755 NTAPI
756 VfatReleaseFromReadAhead(
757 IN PVOID Context);
758
759 /* fat.c */
760
761 NTSTATUS
762 FAT12GetNextCluster(
763 PDEVICE_EXTENSION DeviceExt,
764 ULONG CurrentCluster,
765 PULONG NextCluster);
766
767 NTSTATUS
768 FAT12FindAndMarkAvailableCluster(
769 PDEVICE_EXTENSION DeviceExt,
770 PULONG Cluster);
771
772 NTSTATUS
773 FAT12WriteCluster(
774 PDEVICE_EXTENSION DeviceExt,
775 ULONG ClusterToWrite,
776 ULONG NewValue,
777 PULONG OldValue);
778
779 NTSTATUS
780 FAT16GetNextCluster(
781 PDEVICE_EXTENSION DeviceExt,
782 ULONG CurrentCluster,
783 PULONG NextCluster);
784
785 NTSTATUS
786 FAT16FindAndMarkAvailableCluster(
787 PDEVICE_EXTENSION DeviceExt,
788 PULONG Cluster);
789
790 NTSTATUS
791 FAT16WriteCluster(
792 PDEVICE_EXTENSION DeviceExt,
793 ULONG ClusterToWrite,
794 ULONG NewValue,
795 PULONG OldValue);
796
797 NTSTATUS
798 FAT32GetNextCluster(
799 PDEVICE_EXTENSION DeviceExt,
800 ULONG CurrentCluster,
801 PULONG NextCluster);
802
803 NTSTATUS
804 FAT32FindAndMarkAvailableCluster(
805 PDEVICE_EXTENSION DeviceExt,
806 PULONG Cluster);
807
808 NTSTATUS
809 FAT32WriteCluster(
810 PDEVICE_EXTENSION DeviceExt,
811 ULONG ClusterToWrite,
812 ULONG NewValue,
813 PULONG OldValue);
814
815 NTSTATUS
816 OffsetToCluster(
817 PDEVICE_EXTENSION DeviceExt,
818 ULONG FirstCluster,
819 ULONG FileOffset,
820 PULONG Cluster,
821 BOOLEAN Extend);
822
823 ULONGLONG
824 ClusterToSector(
825 PDEVICE_EXTENSION DeviceExt,
826 ULONG Cluster);
827
828 NTSTATUS
829 GetNextCluster(
830 PDEVICE_EXTENSION DeviceExt,
831 ULONG CurrentCluster,
832 PULONG NextCluster);
833
834 NTSTATUS
835 GetNextClusterExtend(
836 PDEVICE_EXTENSION DeviceExt,
837 ULONG CurrentCluster,
838 PULONG NextCluster);
839
840 NTSTATUS
841 CountAvailableClusters(
842 PDEVICE_EXTENSION DeviceExt,
843 PLARGE_INTEGER Clusters);
844
845 NTSTATUS
846 WriteCluster(
847 PDEVICE_EXTENSION DeviceExt,
848 ULONG ClusterToWrite,
849 ULONG NewValue);
850
851 /* fcb.c */
852
853 PVFATFCB
854 vfatNewFCB(
855 PDEVICE_EXTENSION pVCB,
856 PUNICODE_STRING pFileNameU);
857
858 NTSTATUS
859 vfatSetFCBNewDirName(
860 PDEVICE_EXTENSION pVCB,
861 PVFATFCB Fcb,
862 PVFATFCB ParentFcb);
863
864 NTSTATUS
865 vfatUpdateFCB(
866 PDEVICE_EXTENSION pVCB,
867 PVFATFCB Fcb,
868 PVFAT_DIRENTRY_CONTEXT DirContext,
869 PVFATFCB ParentFcb);
870
871 VOID
872 vfatDestroyFCB(
873 PVFATFCB pFCB);
874
875 VOID
876 vfatDestroyCCB(
877 PVFATCCB pCcb);
878
879 VOID
880 vfatGrabFCB(
881 PDEVICE_EXTENSION pVCB,
882 PVFATFCB pFCB);
883
884 VOID
885 vfatReleaseFCB(
886 PDEVICE_EXTENSION pVCB,
887 PVFATFCB pFCB);
888
889 PVFATFCB
890 vfatGrabFCBFromTable(
891 PDEVICE_EXTENSION pDeviceExt,
892 PUNICODE_STRING pFileNameU);
893
894 PVFATFCB
895 vfatMakeRootFCB(
896 PDEVICE_EXTENSION pVCB);
897
898 PVFATFCB
899 vfatOpenRootFCB(
900 PDEVICE_EXTENSION pVCB);
901
902 BOOLEAN
903 vfatFCBIsDirectory(
904 PVFATFCB FCB);
905
906 BOOLEAN
907 vfatFCBIsRoot(
908 PVFATFCB FCB);
909
910 NTSTATUS
911 vfatAttachFCBToFileObject(
912 PDEVICE_EXTENSION vcb,
913 PVFATFCB fcb,
914 PFILE_OBJECT fileObject);
915
916 NTSTATUS
917 vfatDirFindFile(
918 PDEVICE_EXTENSION pVCB,
919 PVFATFCB parentFCB,
920 PUNICODE_STRING FileToFindU,
921 PVFATFCB *fileFCB);
922
923 NTSTATUS
924 vfatGetFCBForFile(
925 PDEVICE_EXTENSION pVCB,
926 PVFATFCB *pParentFCB,
927 PVFATFCB *pFCB,
928 PUNICODE_STRING pFileNameU);
929
930 NTSTATUS
931 vfatMakeFCBFromDirEntry(
932 PVCB vcb,
933 PVFATFCB directoryFCB,
934 PVFAT_DIRENTRY_CONTEXT DirContext,
935 PVFATFCB *fileFCB);
936
937 /* finfo.c */
938
939 NTSTATUS
940 VfatGetStandardInformation(
941 PVFATFCB FCB,
942 PFILE_STANDARD_INFORMATION StandardInfo,
943 PULONG BufferLength);
944
945 NTSTATUS
946 VfatGetBasicInformation(
947 PFILE_OBJECT FileObject,
948 PVFATFCB FCB,
949 PDEVICE_OBJECT DeviceObject,
950 PFILE_BASIC_INFORMATION BasicInfo,
951 PULONG BufferLength);
952
953 NTSTATUS
954 VfatQueryInformation(
955 PVFAT_IRP_CONTEXT IrpContext);
956
957 NTSTATUS
958 VfatSetInformation(
959 PVFAT_IRP_CONTEXT IrpContext);
960
961 NTSTATUS
962 VfatSetAllocationSizeInformation(
963 PFILE_OBJECT FileObject,
964 PVFATFCB Fcb,
965 PDEVICE_EXTENSION DeviceExt,
966 PLARGE_INTEGER AllocationSize);
967
968 /* flush.c */
969
970 NTSTATUS
971 VfatFlush(
972 PVFAT_IRP_CONTEXT IrpContext);
973
974 NTSTATUS
975 VfatFlushVolume(
976 PDEVICE_EXTENSION DeviceExt,
977 PVFATFCB VolumeFcb);
978
979 /* fsctl.c */
980
981 NTSTATUS
982 VfatFileSystemControl(
983 PVFAT_IRP_CONTEXT IrpContext);
984
985 /* iface.c */
986
987 NTSTATUS
988 NTAPI
989 DriverEntry(
990 PDRIVER_OBJECT DriverObject,
991 PUNICODE_STRING RegistryPath);
992
993
994 /* misc.c */
995
996 DRIVER_DISPATCH
997 VfatBuildRequest;
998
999 NTSTATUS
1000 NTAPI
1001 VfatBuildRequest(
1002 PDEVICE_OBJECT DeviceObject,
1003 PIRP Irp);
1004
1005 PVOID
1006 VfatGetUserBuffer(
1007 IN PIRP,
1008 IN BOOLEAN Paging);
1009
1010 NTSTATUS
1011 VfatLockUserBuffer(
1012 IN PIRP,
1013 IN ULONG,
1014 IN LOCK_OPERATION);
1015
1016 BOOLEAN
1017 VfatCheckForDismount(
1018 IN PDEVICE_EXTENSION DeviceExt,
1019 IN BOOLEAN Create);
1020
1021 /* pnp.c */
1022
1023 NTSTATUS
1024 VfatPnp(
1025 PVFAT_IRP_CONTEXT IrpContext);
1026
1027 /* rw.c */
1028
1029 NTSTATUS
1030 VfatRead(
1031 PVFAT_IRP_CONTEXT IrpContext);
1032
1033 NTSTATUS
1034 VfatWrite(
1035 PVFAT_IRP_CONTEXT IrpContext);
1036
1037 NTSTATUS
1038 NextCluster(
1039 PDEVICE_EXTENSION DeviceExt,
1040 ULONG FirstCluster,
1041 PULONG CurrentCluster,
1042 BOOLEAN Extend);
1043
1044 /* shutdown.c */
1045
1046 DRIVER_DISPATCH
1047 VfatShutdown;
1048
1049 NTSTATUS
1050 NTAPI
1051 VfatShutdown(
1052 PDEVICE_OBJECT DeviceObject,
1053 PIRP Irp);
1054
1055 /* string.c */
1056
1057 VOID
1058 vfatSplitPathName(
1059 PUNICODE_STRING PathNameU,
1060 PUNICODE_STRING DirNameU,
1061 PUNICODE_STRING FileNameU);
1062
1063 BOOLEAN
1064 vfatIsLongIllegal(
1065 WCHAR c);
1066
1067 BOOLEAN
1068 wstrcmpjoki(
1069 PWSTR s1,
1070 PWSTR s2);
1071
1072 /* volume.c */
1073
1074 NTSTATUS
1075 VfatQueryVolumeInformation(
1076 PVFAT_IRP_CONTEXT IrpContext);
1077
1078 NTSTATUS
1079 VfatSetVolumeInformation(
1080 PVFAT_IRP_CONTEXT IrpContext);
1081
1082 #endif /* _FASTFAT_PCH_ */