3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/fs/vfat/fsctl.c
23 * PURPOSE: VFAT Filesystem
26 /* INCLUDES *****************************************************************/
33 extern VFAT_DISPATCH FatXDispatch
;
34 extern VFAT_DISPATCH FatDispatch
;
36 /* FUNCTIONS ****************************************************************/
38 #define CACHEPAGESIZE(pDeviceExt) ((pDeviceExt)->FatInfo.BytesPerCluster > PAGE_SIZE ? \
39 (pDeviceExt)->FatInfo.BytesPerCluster : PAGE_SIZE)
44 PDEVICE_OBJECT DeviceToMount
,
45 PBOOLEAN RecognizedFS
,
50 PARTITION_INFORMATION PartitionInfo
;
51 DISK_GEOMETRY DiskGeometry
;
56 struct _BootSector
* Boot
;
57 struct _BootSectorFatX
* BootFatX
;
58 BOOLEAN PartitionInfoIsValid
= FALSE
;
60 DPRINT("VfatHasFileSystem\n");
62 *RecognizedFS
= FALSE
;
64 Size
= sizeof(DISK_GEOMETRY
);
65 Status
= VfatBlockDeviceIoControl(DeviceToMount
,
66 IOCTL_DISK_GET_DRIVE_GEOMETRY
,
72 if (!NT_SUCCESS(Status
))
74 DPRINT("VfatBlockDeviceIoControl failed (%x)\n", Status
);
78 FatInfo
.FixedMedia
= DiskGeometry
.MediaType
== FixedMedia
? TRUE
: FALSE
;
79 if (DiskGeometry
.MediaType
== FixedMedia
|| DiskGeometry
.MediaType
== RemovableMedia
)
81 // We have found a hard disk
82 Size
= sizeof(PARTITION_INFORMATION
);
83 Status
= VfatBlockDeviceIoControl(DeviceToMount
,
84 IOCTL_DISK_GET_PARTITION_INFO
,
90 if (!NT_SUCCESS(Status
))
92 DPRINT("VfatBlockDeviceIoControl failed (%x)\n", Status
);
96 DPRINT("Partition Information:\n");
97 DPRINT("StartingOffset %I64x\n", PartitionInfo
.StartingOffset
.QuadPart
/ 512);
98 DPRINT("PartitionLength %I64x\n", PartitionInfo
.PartitionLength
.QuadPart
/ 512);
99 DPRINT("HiddenSectors %u\n", PartitionInfo
.HiddenSectors
);
100 DPRINT("PartitionNumber %u\n", PartitionInfo
.PartitionNumber
);
101 DPRINT("PartitionType %u\n", PartitionInfo
.PartitionType
);
102 DPRINT("BootIndicator %u\n", PartitionInfo
.BootIndicator
);
103 DPRINT("RecognizedPartition %u\n", PartitionInfo
.RecognizedPartition
);
104 DPRINT("RewritePartition %u\n", PartitionInfo
.RewritePartition
);
105 if (PartitionInfo
.PartitionType
)
107 if (PartitionInfo
.PartitionType
== PARTITION_FAT_12
||
108 PartitionInfo
.PartitionType
== PARTITION_FAT_16
||
109 PartitionInfo
.PartitionType
== PARTITION_HUGE
||
110 PartitionInfo
.PartitionType
== PARTITION_FAT32
||
111 PartitionInfo
.PartitionType
== PARTITION_FAT32_XINT13
||
112 PartitionInfo
.PartitionType
== PARTITION_XINT13
)
114 PartitionInfoIsValid
= TRUE
;
115 *RecognizedFS
= TRUE
;
118 else if (DiskGeometry
.MediaType
== RemovableMedia
&&
119 PartitionInfo
.PartitionNumber
> 0 &&
120 PartitionInfo
.StartingOffset
.QuadPart
== 0 &&
121 PartitionInfo
.PartitionLength
.QuadPart
> 0)
123 /* This is possible a removable media formated as super floppy */
124 PartitionInfoIsValid
= TRUE
;
125 *RecognizedFS
= TRUE
;
130 *RecognizedFS
= TRUE
;
135 Boot
= ExAllocatePoolWithTag(NonPagedPool
, DiskGeometry
.BytesPerSector
, TAG_VFAT
);
138 return STATUS_INSUFFICIENT_RESOURCES
;
143 /* Try to recognize FAT12/FAT16/FAT32 partitions */
144 Status
= VfatReadDisk(DeviceToMount
, &Offset
, DiskGeometry
.BytesPerSector
, (PUCHAR
) Boot
, Override
);
145 if (NT_SUCCESS(Status
))
147 if (Boot
->Signatur1
!= 0xaa55)
149 *RecognizedFS
= FALSE
;
153 Boot
->BytesPerSector
!= 512 &&
154 Boot
->BytesPerSector
!= 1024 &&
155 Boot
->BytesPerSector
!= 2048 &&
156 Boot
->BytesPerSector
!= 4096)
158 DPRINT1("BytesPerSector %u\n", Boot
->BytesPerSector
);
159 *RecognizedFS
= FALSE
;
163 Boot
->FATCount
!= 1 &&
166 DPRINT1("FATCount %u\n", Boot
->FATCount
);
167 *RecognizedFS
= FALSE
;
171 Boot
->Media
!= 0xf0 &&
172 Boot
->Media
!= 0xf8 &&
173 Boot
->Media
!= 0xf9 &&
174 Boot
->Media
!= 0xfa &&
175 Boot
->Media
!= 0xfb &&
176 Boot
->Media
!= 0xfc &&
177 Boot
->Media
!= 0xfd &&
178 Boot
->Media
!= 0xfe &&
181 DPRINT1("Media %02x\n", Boot
->Media
);
182 *RecognizedFS
= FALSE
;
186 Boot
->SectorsPerCluster
!= 1 &&
187 Boot
->SectorsPerCluster
!= 2 &&
188 Boot
->SectorsPerCluster
!= 4 &&
189 Boot
->SectorsPerCluster
!= 8 &&
190 Boot
->SectorsPerCluster
!= 16 &&
191 Boot
->SectorsPerCluster
!= 32 &&
192 Boot
->SectorsPerCluster
!= 64 &&
193 Boot
->SectorsPerCluster
!= 128)
195 DPRINT1("SectorsPerCluster %02x\n", Boot
->SectorsPerCluster
);
196 *RecognizedFS
= FALSE
;
200 Boot
->BytesPerSector
* Boot
->SectorsPerCluster
> 32 * 1024)
202 DPRINT1("ClusterSize %dx\n", Boot
->BytesPerSector
* Boot
->SectorsPerCluster
);
203 *RecognizedFS
= FALSE
;
208 FatInfo
.VolumeID
= Boot
->VolumeID
;
209 FatInfo
.FATStart
= Boot
->ReservedSectors
;
210 FatInfo
.FATCount
= Boot
->FATCount
;
211 FatInfo
.FATSectors
= Boot
->FATSectors
? Boot
->FATSectors
: ((struct _BootSector32
*) Boot
)->FATSectors32
;
212 FatInfo
.BytesPerSector
= Boot
->BytesPerSector
;
213 FatInfo
.SectorsPerCluster
= Boot
->SectorsPerCluster
;
214 FatInfo
.BytesPerCluster
= FatInfo
.BytesPerSector
* FatInfo
.SectorsPerCluster
;
215 FatInfo
.rootDirectorySectors
= ((Boot
->RootEntries
* 32) + Boot
->BytesPerSector
- 1) / Boot
->BytesPerSector
;
216 FatInfo
.rootStart
= FatInfo
.FATStart
+ FatInfo
.FATCount
* FatInfo
.FATSectors
;
217 FatInfo
.dataStart
= FatInfo
.rootStart
+ FatInfo
.rootDirectorySectors
;
218 FatInfo
.Sectors
= Sectors
= Boot
->Sectors
? Boot
->Sectors
: Boot
->SectorsHuge
;
219 Sectors
-= Boot
->ReservedSectors
+ FatInfo
.FATCount
* FatInfo
.FATSectors
+ FatInfo
.rootDirectorySectors
;
220 FatInfo
.NumberOfClusters
= Sectors
/ Boot
->SectorsPerCluster
;
221 if (FatInfo
.NumberOfClusters
< 4085)
224 FatInfo
.FatType
= FAT12
;
225 FatInfo
.RootCluster
= (FatInfo
.rootStart
- 1) / FatInfo
.SectorsPerCluster
;
226 RtlCopyMemory(&FatInfo
.VolumeLabel
, &Boot
->VolumeLabel
, sizeof(FatInfo
.VolumeLabel
));
228 else if (FatInfo
.NumberOfClusters
>= 65525)
231 FatInfo
.FatType
= FAT32
;
232 FatInfo
.RootCluster
= ((struct _BootSector32
*) Boot
)->RootCluster
;
233 FatInfo
.rootStart
= FatInfo
.dataStart
+ ((FatInfo
.RootCluster
- 2) * FatInfo
.SectorsPerCluster
);
234 FatInfo
.VolumeID
= ((struct _BootSector32
*) Boot
)->VolumeID
;
235 RtlCopyMemory(&FatInfo
.VolumeLabel
, &((struct _BootSector32
*)Boot
)->VolumeLabel
, sizeof(FatInfo
.VolumeLabel
));
240 FatInfo
.FatType
= FAT16
;
241 FatInfo
.RootCluster
= FatInfo
.rootStart
/ FatInfo
.SectorsPerCluster
;
242 RtlCopyMemory(&FatInfo
.VolumeLabel
, &Boot
->VolumeLabel
, sizeof(FatInfo
.VolumeLabel
));
245 if (PartitionInfoIsValid
&&
246 FatInfo
.Sectors
> PartitionInfo
.PartitionLength
.QuadPart
/ FatInfo
.BytesPerSector
)
248 *RecognizedFS
= FALSE
;
251 if (pFatInfo
&& *RecognizedFS
)
261 if (!*RecognizedFS
&& PartitionInfoIsValid
)
263 BootFatX
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(struct _BootSectorFatX
), TAG_VFAT
);
264 if (BootFatX
== NULL
)
267 return STATUS_INSUFFICIENT_RESOURCES
;
272 /* Try to recognize FATX16/FATX32 partitions (Xbox) */
273 Status
= VfatReadDisk(DeviceToMount
, &Offset
, sizeof(struct _BootSectorFatX
), (PUCHAR
) BootFatX
, Override
);
274 if (NT_SUCCESS(Status
))
276 *RecognizedFS
= TRUE
;
277 if (BootFatX
->SysType
[0] != 'F' ||
278 BootFatX
->SysType
[1] != 'A' ||
279 BootFatX
->SysType
[2] != 'T' ||
280 BootFatX
->SysType
[3] != 'X')
282 DPRINT1("SysType %c%c%c%c\n", BootFatX
->SysType
[0], BootFatX
->SysType
[1], BootFatX
->SysType
[2], BootFatX
->SysType
[3]);
287 BootFatX
->SectorsPerCluster
!= 1 &&
288 BootFatX
->SectorsPerCluster
!= 2 &&
289 BootFatX
->SectorsPerCluster
!= 4 &&
290 BootFatX
->SectorsPerCluster
!= 8 &&
291 BootFatX
->SectorsPerCluster
!= 16 &&
292 BootFatX
->SectorsPerCluster
!= 32 &&
293 BootFatX
->SectorsPerCluster
!= 64 &&
294 BootFatX
->SectorsPerCluster
!= 128)
296 DPRINT1("SectorsPerCluster %lu\n", BootFatX
->SectorsPerCluster
);
302 FatInfo
.BytesPerSector
= DiskGeometry
.BytesPerSector
;
303 FatInfo
.SectorsPerCluster
= BootFatX
->SectorsPerCluster
;
304 FatInfo
.rootDirectorySectors
= BootFatX
->SectorsPerCluster
;
305 FatInfo
.BytesPerCluster
= BootFatX
->SectorsPerCluster
* DiskGeometry
.BytesPerSector
;
306 FatInfo
.Sectors
= (ULONG
)(PartitionInfo
.PartitionLength
.QuadPart
/ DiskGeometry
.BytesPerSector
);
307 if (FatInfo
.Sectors
/ FatInfo
.SectorsPerCluster
< 65525)
310 FatInfo
.FatType
= FATX16
;
315 FatInfo
.FatType
= FATX32
;
317 FatInfo
.VolumeID
= BootFatX
->VolumeID
;
318 FatInfo
.FATStart
= sizeof(struct _BootSectorFatX
) / DiskGeometry
.BytesPerSector
;
319 FatInfo
.FATCount
= BootFatX
->FATCount
;
321 ROUND_UP(FatInfo
.Sectors
/ FatInfo
.SectorsPerCluster
* (FatInfo
.FatType
== FATX16
? 2 : 4), 4096) /
322 FatInfo
.BytesPerSector
;
323 FatInfo
.rootStart
= FatInfo
.FATStart
+ FatInfo
.FATCount
* FatInfo
.FATSectors
;
324 FatInfo
.RootCluster
= (FatInfo
.rootStart
- 1) / FatInfo
.SectorsPerCluster
;
325 FatInfo
.dataStart
= FatInfo
.rootStart
+ FatInfo
.rootDirectorySectors
;
326 FatInfo
.NumberOfClusters
= (FatInfo
.Sectors
- FatInfo
.dataStart
) / FatInfo
.SectorsPerCluster
;
328 if (pFatInfo
&& *RecognizedFS
)
334 ExFreePool(BootFatX
);
337 DPRINT("VfatHasFileSystem done\n");
342 * FUNCTION: Read the volume label
343 * WARNING: Read this comment carefully before using it (and using it wrong)
344 * Device parameter is expected to be the lower DO is start isn't 0
345 * otherwise, it is expected to be the VCB is start is 0
346 * Start parameter is expected to be, in bytes, the beginning of the root start.
347 * Set it to 0 if you wish to use the associated FCB with caching.
348 * In that specific case, Device parameter is expected to be the VCB!
349 * VolumeLabel parameter is expected to be a preallocated UNICODE_STRING (ie, with buffer)
350 * Its buffer has to be able to contain MAXIMUM_VOLUME_LABEL_LENGTH bytes
358 PUNICODE_STRING VolumeLabel
)
360 PDEVICE_EXTENSION DeviceExt
;
361 PDEVICE_OBJECT DeviceObject
;
362 PVOID Context
= NULL
;
366 LARGE_INTEGER FileOffset
;
368 ULONG EntriesPerPage
;
370 BOOLEAN NoCache
= (Start
!= 0);
372 NTSTATUS Status
= STATUS_SUCCESS
;
376 SizeDirEntry
= sizeof(FATX_DIR_ENTRY
);
377 EntriesPerPage
= FATX_ENTRIES_PER_PAGE
;
381 SizeDirEntry
= sizeof(FAT_DIR_ENTRY
);
382 EntriesPerPage
= FAT_ENTRIES_PER_PAGE
;
385 FileOffset
.QuadPart
= Start
;
390 /* FIXME: Check we really have a VCB
394 ExAcquireResourceExclusiveLite(&DeviceExt
->DirResource
, TRUE
);
395 pFcb
= vfatOpenRootFCB(DeviceExt
);
396 ExReleaseResourceLite(&DeviceExt
->DirResource
);
400 CcMapData(pFcb
->FileObject
, &FileOffset
, SizeDirEntry
, MAP_WAIT
, &Context
, (PVOID
*)&Entry
);
402 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
404 Status
= _SEH2_GetExceptionCode();
410 DeviceObject
= Device
;
412 ASSERT(DeviceObject
->Type
== 3);
414 Buffer
= ExAllocatePoolWithTag(NonPagedPool
, PAGE_SIZE
, TAG_VFAT
);
417 Status
= VfatReadDisk(DeviceObject
, &FileOffset
, PAGE_SIZE
, (PUCHAR
)Buffer
, TRUE
);
418 if (!NT_SUCCESS(Status
))
420 ExFreePoolWithTag(Buffer
, TAG_VFAT
);
429 Status
= STATUS_INSUFFICIENT_RESOURCES
;
433 if (NT_SUCCESS(Status
))
437 if (ENTRY_VOLUME(IsFatX
, Entry
))
439 /* copy volume label */
442 StringO
.Buffer
= (PCHAR
)Entry
->FatX
.Filename
;
443 StringO
.MaximumLength
= StringO
.Length
= Entry
->FatX
.FilenameLength
;
444 RtlOemStringToUnicodeString(VolumeLabel
, &StringO
, FALSE
);
448 vfat8Dot3ToString(&Entry
->Fat
, VolumeLabel
);
452 if (ENTRY_END(IsFatX
, Entry
))
457 Entry
= (PDIR_ENTRY
)((ULONG_PTR
)Entry
+ SizeDirEntry
);
458 if ((DirIndex
% EntriesPerPage
) == 0)
460 FileOffset
.u
.LowPart
+= PAGE_SIZE
;
464 CcUnpinData(Context
);
468 CcMapData(pFcb
->FileObject
, &FileOffset
, SizeDirEntry
, MAP_WAIT
, &Context
, (PVOID
*)&Entry
);
470 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
472 Status
= _SEH2_GetExceptionCode();
475 if (!NT_SUCCESS(Status
))
483 Status
= VfatReadDisk(DeviceObject
, &FileOffset
, PAGE_SIZE
, (PUCHAR
)Buffer
, TRUE
);
484 if (!NT_SUCCESS(Status
))
494 CcUnpinData(Context
);
498 ExFreePoolWithTag(Buffer
, TAG_VFAT
);
504 ExAcquireResourceExclusiveLite(&DeviceExt
->DirResource
, TRUE
);
505 vfatReleaseFCB(DeviceExt
, pFcb
);
506 ExReleaseResourceLite(&DeviceExt
->DirResource
);
509 return STATUS_SUCCESS
;
514 * FUNCTION: Mount the filesystem
519 PVFAT_IRP_CONTEXT IrpContext
)
521 PDEVICE_OBJECT DeviceObject
= NULL
;
522 PDEVICE_EXTENSION DeviceExt
= NULL
;
523 BOOLEAN RecognizedFS
;
526 PVFATFCB VolumeFcb
= NULL
;
528 PDEVICE_OBJECT DeviceToMount
;
530 UNICODE_STRING NameU
= RTL_CONSTANT_STRING(L
"\\$$Fat$$");
531 UNICODE_STRING VolumeNameU
= RTL_CONSTANT_STRING(L
"\\$$Volume$$");
532 UNICODE_STRING VolumeLabelU
;
538 DPRINT("VfatMount(IrpContext %p)\n", IrpContext
);
542 if (IrpContext
->DeviceObject
!= VfatGlobalData
->DeviceObject
)
544 Status
= STATUS_INVALID_DEVICE_REQUEST
;
548 DeviceToMount
= IrpContext
->Stack
->Parameters
.MountVolume
.DeviceObject
;
549 Vpb
= IrpContext
->Stack
->Parameters
.MountVolume
.Vpb
;
551 Status
= VfatHasFileSystem(DeviceToMount
, &RecognizedFS
, &FatInfo
, FALSE
);
552 if (!NT_SUCCESS(Status
))
557 if (RecognizedFS
== FALSE
)
559 DPRINT("VFAT: Unrecognized Volume\n");
560 Status
= STATUS_UNRECOGNIZED_VOLUME
;
564 /* Use prime numbers for the table size */
565 if (FatInfo
.FatType
== FAT12
)
567 HashTableSize
= 4099; // 4096 = 4 * 1024
569 else if (FatInfo
.FatType
== FAT16
||
570 FatInfo
.FatType
== FATX16
)
572 HashTableSize
= 16411; // 16384 = 16 * 1024
576 HashTableSize
= 65537; // 65536 = 64 * 1024;
578 DPRINT("VFAT: Recognized volume\n");
579 Status
= IoCreateDevice(VfatGlobalData
->DriverObject
,
580 ROUND_UP(sizeof (DEVICE_EXTENSION
), sizeof(ULONG
)) + sizeof(HASHENTRY
*) * HashTableSize
,
582 FILE_DEVICE_DISK_FILE_SYSTEM
,
583 DeviceToMount
->Characteristics
,
586 if (!NT_SUCCESS(Status
))
591 DeviceExt
= DeviceObject
->DeviceExtension
;
592 RtlZeroMemory(DeviceExt
, ROUND_UP(sizeof(DEVICE_EXTENSION
), sizeof(ULONG
)) + sizeof(HASHENTRY
*) * HashTableSize
);
593 DeviceExt
->FcbHashTable
= (HASHENTRY
**)((ULONG_PTR
)DeviceExt
+ ROUND_UP(sizeof(DEVICE_EXTENSION
), sizeof(ULONG
)));
594 DeviceExt
->HashTableSize
= HashTableSize
;
595 DeviceExt
->VolumeDevice
= DeviceObject
;
597 /* use same vpb as device disk */
598 DeviceObject
->Vpb
= Vpb
;
599 DeviceToMount
->Vpb
= Vpb
;
601 RtlCopyMemory(&DeviceExt
->FatInfo
, &FatInfo
, sizeof(FATINFO
));
603 DPRINT("BytesPerSector: %u\n", DeviceExt
->FatInfo
.BytesPerSector
);
604 DPRINT("SectorsPerCluster: %u\n", DeviceExt
->FatInfo
.SectorsPerCluster
);
605 DPRINT("FATCount: %u\n", DeviceExt
->FatInfo
.FATCount
);
606 DPRINT("FATSectors: %u\n", DeviceExt
->FatInfo
.FATSectors
);
607 DPRINT("RootStart: %u\n", DeviceExt
->FatInfo
.rootStart
);
608 DPRINT("DataStart: %u\n", DeviceExt
->FatInfo
.dataStart
);
609 if (DeviceExt
->FatInfo
.FatType
== FAT32
)
611 DPRINT("RootCluster: %u\n", DeviceExt
->FatInfo
.RootCluster
);
614 switch (DeviceExt
->FatInfo
.FatType
)
617 DeviceExt
->GetNextCluster
= FAT12GetNextCluster
;
618 DeviceExt
->FindAndMarkAvailableCluster
= FAT12FindAndMarkAvailableCluster
;
619 DeviceExt
->WriteCluster
= FAT12WriteCluster
;
620 DeviceExt
->CleanShutBitMask
= 0;
625 DeviceExt
->GetNextCluster
= FAT16GetNextCluster
;
626 DeviceExt
->FindAndMarkAvailableCluster
= FAT16FindAndMarkAvailableCluster
;
627 DeviceExt
->WriteCluster
= FAT16WriteCluster
;
628 DeviceExt
->CleanShutBitMask
= 0x8000;
633 DeviceExt
->GetNextCluster
= FAT32GetNextCluster
;
634 DeviceExt
->FindAndMarkAvailableCluster
= FAT32FindAndMarkAvailableCluster
;
635 DeviceExt
->WriteCluster
= FAT32WriteCluster
;
636 DeviceExt
->CleanShutBitMask
= 0x80000000;
640 if (DeviceExt
->FatInfo
.FatType
== FATX16
||
641 DeviceExt
->FatInfo
.FatType
== FATX32
)
643 DeviceExt
->Flags
|= VCB_IS_FATX
;
644 DeviceExt
->BaseDateYear
= 2000;
645 RtlCopyMemory(&DeviceExt
->Dispatch
, &FatXDispatch
, sizeof(VFAT_DISPATCH
));
649 DeviceExt
->BaseDateYear
= 1980;
650 RtlCopyMemory(&DeviceExt
->Dispatch
, &FatDispatch
, sizeof(VFAT_DISPATCH
));
653 DeviceExt
->StorageDevice
= DeviceToMount
;
654 DeviceExt
->StorageDevice
->Vpb
->DeviceObject
= DeviceObject
;
655 DeviceExt
->StorageDevice
->Vpb
->RealDevice
= DeviceExt
->StorageDevice
;
656 DeviceExt
->StorageDevice
->Vpb
->Flags
|= VPB_MOUNTED
;
657 DeviceObject
->StackSize
= DeviceExt
->StorageDevice
->StackSize
+ 1;
658 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
660 DPRINT("FsDeviceObject %p\n", DeviceObject
);
662 /* Initialize this resource early ... it's used in VfatCleanup */
663 ExInitializeResourceLite(&DeviceExt
->DirResource
);
665 DeviceExt
->IoVPB
= DeviceObject
->Vpb
;
666 DeviceExt
->SpareVPB
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(VPB
), TAG_VFAT
);
667 if (DeviceExt
->SpareVPB
== NULL
)
669 Status
= STATUS_INSUFFICIENT_RESOURCES
;
673 DeviceExt
->Statistics
= ExAllocatePoolWithTag(NonPagedPool
,
674 sizeof(STATISTICS
) * VfatGlobalData
->NumberProcessors
,
676 if (DeviceExt
->Statistics
== NULL
)
678 Status
= STATUS_INSUFFICIENT_RESOURCES
;
682 RtlZeroMemory(DeviceExt
->Statistics
, sizeof(STATISTICS
) * VfatGlobalData
->NumberProcessors
);
683 for (i
= 0; i
< VfatGlobalData
->NumberProcessors
; ++i
)
685 DeviceExt
->Statistics
[i
].Base
.FileSystemType
= FILESYSTEM_STATISTICS_TYPE_FAT
;
686 DeviceExt
->Statistics
[i
].Base
.Version
= 1;
687 DeviceExt
->Statistics
[i
].Base
.SizeOfCompleteStructure
= sizeof(STATISTICS
);
690 DeviceExt
->FATFileObject
= IoCreateStreamFileObject(NULL
, DeviceExt
->StorageDevice
);
691 Fcb
= vfatNewFCB(DeviceExt
, &NameU
);
694 Status
= STATUS_INSUFFICIENT_RESOURCES
;
698 Ccb
= ExAllocateFromNPagedLookasideList(&VfatGlobalData
->CcbLookasideList
);
701 Status
= STATUS_INSUFFICIENT_RESOURCES
;
705 RtlZeroMemory(Ccb
, sizeof (VFATCCB
));
706 DeviceExt
->FATFileObject
->FsContext
= Fcb
;
707 DeviceExt
->FATFileObject
->FsContext2
= Ccb
;
708 DeviceExt
->FATFileObject
->SectionObjectPointer
= &Fcb
->SectionObjectPointers
;
709 DeviceExt
->FATFileObject
->PrivateCacheMap
= NULL
;
710 DeviceExt
->FATFileObject
->Vpb
= DeviceObject
->Vpb
;
711 Fcb
->FileObject
= DeviceExt
->FATFileObject
;
713 Fcb
->Flags
|= FCB_IS_FAT
;
715 Fcb
->RFCB
.FileSize
.QuadPart
= DeviceExt
->FatInfo
.FATSectors
* DeviceExt
->FatInfo
.BytesPerSector
;
716 Fcb
->RFCB
.ValidDataLength
= Fcb
->RFCB
.FileSize
;
717 Fcb
->RFCB
.AllocationSize
= Fcb
->RFCB
.FileSize
;
721 CcInitializeCacheMap(DeviceExt
->FATFileObject
,
722 (PCC_FILE_SIZES
)(&Fcb
->RFCB
.AllocationSize
),
724 &VfatGlobalData
->CacheMgrCallbacks
,
727 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
729 Status
= _SEH2_GetExceptionCode();
734 DeviceExt
->LastAvailableCluster
= 2;
735 ExInitializeResourceLite(&DeviceExt
->FatResource
);
737 InitializeListHead(&DeviceExt
->FcbListHead
);
739 VolumeFcb
= vfatNewFCB(DeviceExt
, &VolumeNameU
);
740 if (VolumeFcb
== NULL
)
742 Status
= STATUS_INSUFFICIENT_RESOURCES
;
746 VolumeFcb
->Flags
= FCB_IS_VOLUME
;
747 VolumeFcb
->RFCB
.FileSize
.QuadPart
= (LONGLONG
) DeviceExt
->FatInfo
.Sectors
* DeviceExt
->FatInfo
.BytesPerSector
;
748 VolumeFcb
->RFCB
.ValidDataLength
= VolumeFcb
->RFCB
.FileSize
;
749 VolumeFcb
->RFCB
.AllocationSize
= VolumeFcb
->RFCB
.FileSize
;
750 DeviceExt
->VolumeFcb
= VolumeFcb
;
752 ExAcquireResourceExclusiveLite(&VfatGlobalData
->VolumeListLock
, TRUE
);
753 InsertHeadList(&VfatGlobalData
->VolumeListHead
, &DeviceExt
->VolumeListEntry
);
754 ExReleaseResourceLite(&VfatGlobalData
->VolumeListLock
);
756 /* read serial number */
757 DeviceObject
->Vpb
->SerialNumber
= DeviceExt
->FatInfo
.VolumeID
;
759 /* read volume label */
760 VolumeLabelU
.Buffer
= DeviceObject
->Vpb
->VolumeLabel
;
761 VolumeLabelU
.Length
= 0;
762 VolumeLabelU
.MaximumLength
= sizeof(DeviceObject
->Vpb
->VolumeLabel
);
763 ReadVolumeLabel(DeviceExt
, 0, vfatVolumeIsFatX(DeviceExt
), &VolumeLabelU
);
764 Vpb
->VolumeLabelLength
= VolumeLabelU
.Length
;
766 /* read clean shutdown bit status */
767 Status
= GetNextCluster(DeviceExt
, 1, &eocMark
);
768 if (NT_SUCCESS(Status
))
770 if (eocMark
& DeviceExt
->CleanShutBitMask
)
772 /* unset clean shutdown bit */
773 eocMark
&= ~DeviceExt
->CleanShutBitMask
;
774 WriteCluster(DeviceExt
, 1, eocMark
);
775 VolumeFcb
->Flags
|= VCB_CLEAR_DIRTY
;
779 VolumeFcb
->Flags
|= VCB_IS_DIRTY
;
781 FsRtlNotifyVolumeEvent(DeviceExt
->FATFileObject
, FSRTL_VOLUME_MOUNT
);
782 FsRtlNotifyInitializeSync(&DeviceExt
->NotifySync
);
783 InitializeListHead(&DeviceExt
->NotifyList
);
785 DPRINT("Mount success\n");
787 Status
= STATUS_SUCCESS
;
790 if (!NT_SUCCESS(Status
))
793 if (DeviceExt
&& DeviceExt
->FATFileObject
)
794 ObDereferenceObject (DeviceExt
->FATFileObject
);
795 if (DeviceExt
&& DeviceExt
->SpareVPB
)
796 ExFreePoolWithTag(DeviceExt
->SpareVPB
, TAG_VFAT
);
797 if (DeviceExt
&& DeviceExt
->Statistics
)
798 ExFreePoolWithTag(DeviceExt
->Statistics
, TAG_VFAT
);
804 IoDeleteDevice(DeviceObject
);
812 * FUNCTION: Verify the filesystem
817 PVFAT_IRP_CONTEXT IrpContext
)
819 PDEVICE_OBJECT DeviceToVerify
;
822 BOOLEAN RecognizedFS
;
823 PDEVICE_EXTENSION DeviceExt
;
826 ULONG ChangeCount
, BufSize
= sizeof(ChangeCount
);
828 DPRINT("VfatVerify(IrpContext %p)\n", IrpContext
);
830 DeviceToVerify
= IrpContext
->Stack
->Parameters
.VerifyVolume
.DeviceObject
;
831 DeviceExt
= DeviceToVerify
->DeviceExtension
;
832 Vpb
= IrpContext
->Stack
->Parameters
.VerifyVolume
.Vpb
;
833 AllowRaw
= BooleanFlagOn(IrpContext
->Stack
->Flags
, SL_ALLOW_RAW_MOUNT
);
835 if (!BooleanFlagOn(Vpb
->RealDevice
->Flags
, DO_VERIFY_VOLUME
))
837 DPRINT("Already verified\n");
838 return STATUS_SUCCESS
;
841 Status
= VfatBlockDeviceIoControl(DeviceExt
->StorageDevice
,
842 IOCTL_DISK_CHECK_VERIFY
,
848 if (!NT_SUCCESS(Status
) && Status
!= STATUS_VERIFY_REQUIRED
)
850 DPRINT("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status
);
851 Status
= (AllowRaw
? STATUS_WRONG_VOLUME
: Status
);
855 Status
= VfatHasFileSystem(DeviceExt
->StorageDevice
, &RecognizedFS
, &FatInfo
, TRUE
);
856 if (!NT_SUCCESS(Status
) || RecognizedFS
== FALSE
)
858 if (NT_SUCCESS(Status
) || AllowRaw
)
860 Status
= STATUS_WRONG_VOLUME
;
863 else if (sizeof(FATINFO
) == RtlCompareMemory(&FatInfo
, &DeviceExt
->FatInfo
, sizeof(FATINFO
)))
865 WCHAR BufferU
[MAXIMUM_VOLUME_LABEL_LENGTH
/ sizeof(WCHAR
)];
866 UNICODE_STRING VolumeLabelU
;
867 UNICODE_STRING VpbLabelU
;
869 VolumeLabelU
.Buffer
= BufferU
;
870 VolumeLabelU
.Length
= 0;
871 VolumeLabelU
.MaximumLength
= sizeof(BufferU
);
872 Status
= ReadVolumeLabel(DeviceExt
->StorageDevice
, FatInfo
.rootStart
* FatInfo
.BytesPerSector
, (FatInfo
.FatType
>= FATX16
), &VolumeLabelU
);
873 if (!NT_SUCCESS(Status
))
877 Status
= STATUS_WRONG_VOLUME
;
882 VpbLabelU
.Buffer
= Vpb
->VolumeLabel
;
883 VpbLabelU
.Length
= Vpb
->VolumeLabelLength
;
884 VpbLabelU
.MaximumLength
= sizeof(Vpb
->VolumeLabel
);
886 if (RtlCompareUnicodeString(&VpbLabelU
, &VolumeLabelU
, FALSE
) != 0)
888 Status
= STATUS_WRONG_VOLUME
;
892 DPRINT1("Same volume\n");
898 Status
= STATUS_WRONG_VOLUME
;
902 Vpb
->RealDevice
->Flags
&= ~DO_VERIFY_VOLUME
;
911 PVFAT_IRP_CONTEXT IrpContext
)
913 DPRINT("VfatGetVolumeBitmap (IrpContext %p)\n", IrpContext
);
914 return STATUS_INVALID_DEVICE_REQUEST
;
920 VfatGetRetrievalPointers(
921 PVFAT_IRP_CONTEXT IrpContext
)
923 PIO_STACK_LOCATION Stack
;
925 PRETRIEVAL_POINTERS_BUFFER RetrievalPointers
;
926 PFILE_OBJECT FileObject
;
927 ULONG MaxExtentCount
;
929 PDEVICE_EXTENSION DeviceExt
;
931 ULONG CurrentCluster
;
935 DPRINT("VfatGetRetrievalPointers(IrpContext %p)\n", IrpContext
);
937 DeviceExt
= IrpContext
->DeviceExt
;
938 FileObject
= IrpContext
->FileObject
;
939 Stack
= IrpContext
->Stack
;
940 if (Stack
->Parameters
.DeviceIoControl
.InputBufferLength
< sizeof(STARTING_VCN_INPUT_BUFFER
) ||
941 Stack
->Parameters
.DeviceIoControl
.Type3InputBuffer
== NULL
)
943 return STATUS_INVALID_PARAMETER
;
946 if (IrpContext
->Irp
->UserBuffer
== NULL
||
947 Stack
->Parameters
.DeviceIoControl
.OutputBufferLength
< sizeof(RETRIEVAL_POINTERS_BUFFER
))
949 return STATUS_BUFFER_TOO_SMALL
;
952 Fcb
= FileObject
->FsContext
;
954 ExAcquireResourceSharedLite(&Fcb
->MainResource
, TRUE
);
956 Vcn
= ((PSTARTING_VCN_INPUT_BUFFER
)Stack
->Parameters
.DeviceIoControl
.Type3InputBuffer
)->StartingVcn
;
957 RetrievalPointers
= IrpContext
->Irp
->UserBuffer
;
959 MaxExtentCount
= ((Stack
->Parameters
.DeviceIoControl
.OutputBufferLength
- sizeof(RetrievalPointers
->ExtentCount
) - sizeof(RetrievalPointers
->StartingVcn
)) / sizeof(RetrievalPointers
->Extents
[0]));
961 if (Vcn
.QuadPart
>= Fcb
->RFCB
.AllocationSize
.QuadPart
/ DeviceExt
->FatInfo
.BytesPerCluster
)
963 Status
= STATUS_INVALID_PARAMETER
;
967 CurrentCluster
= FirstCluster
= vfatDirEntryGetFirstCluster(DeviceExt
, &Fcb
->entry
);
968 Status
= OffsetToCluster(DeviceExt
, FirstCluster
,
969 Vcn
.u
.LowPart
* DeviceExt
->FatInfo
.BytesPerCluster
,
970 &CurrentCluster
, FALSE
);
971 if (!NT_SUCCESS(Status
))
976 RetrievalPointers
->StartingVcn
= Vcn
;
977 RetrievalPointers
->ExtentCount
= 0;
978 RetrievalPointers
->Extents
[0].Lcn
.u
.HighPart
= 0;
979 RetrievalPointers
->Extents
[0].Lcn
.u
.LowPart
= CurrentCluster
- 2;
981 while (CurrentCluster
!= 0xffffffff && RetrievalPointers
->ExtentCount
< MaxExtentCount
)
983 LastCluster
= CurrentCluster
;
984 Status
= NextCluster(DeviceExt
, CurrentCluster
, &CurrentCluster
, FALSE
);
986 if (!NT_SUCCESS(Status
))
991 if (LastCluster
+ 1 != CurrentCluster
)
993 RetrievalPointers
->Extents
[RetrievalPointers
->ExtentCount
].NextVcn
= Vcn
;
994 RetrievalPointers
->ExtentCount
++;
995 if (RetrievalPointers
->ExtentCount
< MaxExtentCount
)
997 RetrievalPointers
->Extents
[RetrievalPointers
->ExtentCount
].Lcn
.u
.HighPart
= 0;
998 RetrievalPointers
->Extents
[RetrievalPointers
->ExtentCount
].Lcn
.u
.LowPart
= CurrentCluster
- 2;
1003 IrpContext
->Irp
->IoStatus
.Information
= sizeof(RETRIEVAL_POINTERS_BUFFER
) + (sizeof(RetrievalPointers
->Extents
[0]) * (RetrievalPointers
->ExtentCount
- 1));
1004 Status
= STATUS_SUCCESS
;
1007 ExReleaseResourceLite(&Fcb
->MainResource
);
1015 PVFAT_IRP_CONTEXT IrpContext
)
1017 DPRINT("VfatMoveFile(IrpContext %p)\n", IrpContext
);
1018 return STATUS_INVALID_DEVICE_REQUEST
;
1024 PVFAT_IRP_CONTEXT IrpContext
)
1028 DPRINT("VfatIsVolumeDirty(IrpContext %p)\n", IrpContext
);
1030 if (IrpContext
->Stack
->Parameters
.FileSystemControl
.OutputBufferLength
!= sizeof(ULONG
))
1031 return STATUS_INVALID_BUFFER_SIZE
;
1032 else if (!IrpContext
->Irp
->AssociatedIrp
.SystemBuffer
)
1033 return STATUS_INVALID_USER_BUFFER
;
1035 Flags
= (PULONG
)IrpContext
->Irp
->AssociatedIrp
.SystemBuffer
;
1038 if (BooleanFlagOn(IrpContext
->DeviceExt
->VolumeFcb
->Flags
, VCB_IS_DIRTY
) &&
1039 !BooleanFlagOn(IrpContext
->DeviceExt
->VolumeFcb
->Flags
, VCB_CLEAR_DIRTY
))
1041 *Flags
|= VOLUME_IS_DIRTY
;
1044 IrpContext
->Irp
->IoStatus
.Information
= sizeof(ULONG
);
1046 return STATUS_SUCCESS
;
1051 VfatMarkVolumeDirty(
1052 PVFAT_IRP_CONTEXT IrpContext
)
1055 PDEVICE_EXTENSION DeviceExt
;
1056 NTSTATUS Status
= STATUS_SUCCESS
;
1058 DPRINT("VfatMarkVolumeDirty(IrpContext %p)\n", IrpContext
);
1059 DeviceExt
= IrpContext
->DeviceExt
;
1061 if (!BooleanFlagOn(DeviceExt
->VolumeFcb
->Flags
, VCB_IS_DIRTY
))
1063 Status
= GetNextCluster(DeviceExt
, 1, &eocMark
);
1064 if (NT_SUCCESS(Status
))
1066 /* unset clean shutdown bit */
1067 eocMark
&= ~DeviceExt
->CleanShutBitMask
;
1068 Status
= WriteCluster(DeviceExt
, 1, eocMark
);
1072 DeviceExt
->VolumeFcb
->Flags
&= ~VCB_CLEAR_DIRTY
;
1079 VfatLockOrUnlockVolume(
1080 PVFAT_IRP_CONTEXT IrpContext
,
1083 PFILE_OBJECT FileObject
;
1084 PDEVICE_EXTENSION DeviceExt
;
1088 DPRINT("VfatLockOrUnlockVolume(%p, %d)\n", IrpContext
, Lock
);
1090 DeviceExt
= IrpContext
->DeviceExt
;
1091 FileObject
= IrpContext
->FileObject
;
1092 Fcb
= FileObject
->FsContext
;
1093 Vpb
= DeviceExt
->FATFileObject
->Vpb
;
1095 /* Only allow locking with the volume open */
1096 if (!BooleanFlagOn(Fcb
->Flags
, FCB_IS_VOLUME
))
1098 return STATUS_ACCESS_DENIED
;
1101 /* Bail out if it's already in the demanded state */
1102 if ((BooleanFlagOn(DeviceExt
->Flags
, VCB_VOLUME_LOCKED
) && Lock
) ||
1103 (!BooleanFlagOn(DeviceExt
->Flags
, VCB_VOLUME_LOCKED
) && !Lock
))
1105 return STATUS_ACCESS_DENIED
;
1108 /* Bail out if it's already in the demanded state */
1109 if ((BooleanFlagOn(Vpb
->Flags
, VPB_LOCKED
) && Lock
) ||
1110 (!BooleanFlagOn(Vpb
->Flags
, VPB_LOCKED
) && !Lock
))
1112 return STATUS_ACCESS_DENIED
;
1115 /* Deny locking if we're not alone */
1116 if (Lock
&& DeviceExt
->OpenHandleCount
!= 1)
1118 return STATUS_ACCESS_DENIED
;
1121 /* Finally, proceed */
1124 DeviceExt
->Flags
|= VCB_VOLUME_LOCKED
;
1125 Vpb
->Flags
|= VPB_LOCKED
;
1129 DeviceExt
->Flags
&= ~VCB_VOLUME_LOCKED
;
1130 Vpb
->Flags
&= ~VPB_LOCKED
;
1133 return STATUS_SUCCESS
;
1139 PVFAT_IRP_CONTEXT IrpContext
)
1141 PDEVICE_EXTENSION DeviceExt
;
1142 PLIST_ENTRY NextEntry
;
1144 PFILE_OBJECT FileObject
;
1148 DPRINT("VfatDismountVolume(%p)\n", IrpContext
);
1150 DeviceExt
= IrpContext
->DeviceExt
;
1151 FileObject
= IrpContext
->FileObject
;
1153 /* We HAVE to be locked. Windows also allows dismount with no lock
1154 * but we're here mainly for 1st stage, so KISS
1156 if (!BooleanFlagOn(DeviceExt
->Flags
, VCB_VOLUME_LOCKED
))
1158 return STATUS_ACCESS_DENIED
;
1161 /* Race condition? */
1162 if (BooleanFlagOn(DeviceExt
->Flags
, VCB_DISMOUNT_PENDING
))
1164 return STATUS_VOLUME_DISMOUNTED
;
1167 /* Notify we'll dismount. Pass that point there's no reason we fail */
1168 FsRtlNotifyVolumeEvent(IrpContext
->Stack
->FileObject
, FSRTL_VOLUME_DISMOUNT
);
1170 ExAcquireResourceExclusiveLite(&DeviceExt
->FatResource
, TRUE
);
1172 if (BooleanFlagOn(DeviceExt
->VolumeFcb
->Flags
, VCB_CLEAR_DIRTY
))
1174 /* Set clean shutdown bit */
1175 Status
= GetNextCluster(DeviceExt
, 1, &eocMark
);
1176 if (NT_SUCCESS(Status
))
1178 eocMark
|= DeviceExt
->CleanShutBitMask
;
1179 if (NT_SUCCESS(WriteCluster(DeviceExt
, 1, eocMark
)))
1180 DeviceExt
->VolumeFcb
->Flags
&= ~VCB_IS_DIRTY
;
1184 /* Flush volume & files */
1185 VfatFlushVolume(DeviceExt
, (PVFATFCB
)FileObject
->FsContext
);
1187 /* Rebrowse the FCB in order to free them now */
1188 while (!IsListEmpty(&DeviceExt
->FcbListHead
))
1190 NextEntry
= RemoveHeadList(&DeviceExt
->FcbListHead
);
1191 Fcb
= CONTAINING_RECORD(NextEntry
, VFATFCB
, FcbListEntry
);
1192 vfatDestroyFCB(Fcb
);
1195 /* Mark we're being dismounted */
1196 DeviceExt
->Flags
|= VCB_DISMOUNT_PENDING
;
1197 #ifndef ENABLE_SWAPOUT
1198 IrpContext
->DeviceObject
->Vpb
->Flags
&= ~VPB_MOUNTED
;
1201 ExReleaseResourceLite(&DeviceExt
->FatResource
);
1203 /* Release a few resources and quit, we're done */
1204 ExDeleteResourceLite(&DeviceExt
->DirResource
);
1205 ExDeleteResourceLite(&DeviceExt
->FatResource
);
1206 ObDereferenceObject(DeviceExt
->FATFileObject
);
1208 return STATUS_SUCCESS
;
1214 PVFAT_IRP_CONTEXT IrpContext
)
1219 PDEVICE_EXTENSION DeviceExt
;
1221 DeviceExt
= IrpContext
->DeviceExt
;
1222 Length
= IrpContext
->Stack
->Parameters
.FileSystemControl
.OutputBufferLength
;
1223 Buffer
= IrpContext
->Irp
->AssociatedIrp
.SystemBuffer
;
1225 if (Length
< sizeof(FILESYSTEM_STATISTICS
))
1227 return STATUS_BUFFER_TOO_SMALL
;
1232 return STATUS_INVALID_USER_BUFFER
;
1235 if (Length
>= sizeof(STATISTICS
) * VfatGlobalData
->NumberProcessors
)
1237 Length
= sizeof(STATISTICS
) * VfatGlobalData
->NumberProcessors
;
1238 Status
= STATUS_SUCCESS
;
1242 Status
= STATUS_BUFFER_OVERFLOW
;
1245 RtlCopyMemory(Buffer
, DeviceExt
->Statistics
, Length
);
1246 IrpContext
->Irp
->IoStatus
.Information
= Length
;
1252 * FUNCTION: File system control
1255 VfatFileSystemControl(
1256 PVFAT_IRP_CONTEXT IrpContext
)
1260 DPRINT("VfatFileSystemControl(IrpContext %p)\n", IrpContext
);
1263 ASSERT(IrpContext
->Irp
);
1264 ASSERT(IrpContext
->Stack
);
1266 IrpContext
->Irp
->IoStatus
.Information
= 0;
1268 switch (IrpContext
->MinorFunction
)
1270 case IRP_MN_KERNEL_CALL
:
1271 case IRP_MN_USER_FS_REQUEST
:
1272 switch(IrpContext
->Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
1274 case FSCTL_GET_VOLUME_BITMAP
:
1275 Status
= VfatGetVolumeBitmap(IrpContext
);
1278 case FSCTL_GET_RETRIEVAL_POINTERS
:
1279 Status
= VfatGetRetrievalPointers(IrpContext
);
1282 case FSCTL_MOVE_FILE
:
1283 Status
= VfatMoveFile(IrpContext
);
1286 case FSCTL_IS_VOLUME_DIRTY
:
1287 Status
= VfatIsVolumeDirty(IrpContext
);
1290 case FSCTL_MARK_VOLUME_DIRTY
:
1291 Status
= VfatMarkVolumeDirty(IrpContext
);
1294 case FSCTL_LOCK_VOLUME
:
1295 Status
= VfatLockOrUnlockVolume(IrpContext
, TRUE
);
1298 case FSCTL_UNLOCK_VOLUME
:
1299 Status
= VfatLockOrUnlockVolume(IrpContext
, FALSE
);
1302 case FSCTL_DISMOUNT_VOLUME
:
1303 Status
= VfatDismountVolume(IrpContext
);
1306 case FSCTL_FILESYSTEM_GET_STATISTICS
:
1307 Status
= VfatGetStatistics(IrpContext
);
1311 Status
= STATUS_INVALID_DEVICE_REQUEST
;
1315 case IRP_MN_MOUNT_VOLUME
:
1316 Status
= VfatMount(IrpContext
);
1319 case IRP_MN_VERIFY_VOLUME
:
1320 DPRINT("VFATFS: IRP_MN_VERIFY_VOLUME\n");
1321 Status
= VfatVerify(IrpContext
);
1325 DPRINT("VFAT FSC: MinorFunction %u\n", IrpContext
->MinorFunction
);
1326 Status
= STATUS_INVALID_DEVICE_REQUEST
;