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