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