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