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