510{
526
527 DPRINT(
"VfatMount(IrpContext %p)\n", IrpContext);
528
530
532 {
534 goto ByeBye;
535 }
536
539
542 {
543 goto ByeBye;
544 }
545
546 if (RecognizedFS ==
FALSE)
547 {
548 DPRINT(
"VFAT: Unrecognized Volume\n");
550 goto ByeBye;
551 }
552
553
555 {
556 HashTableSize = 4099;
557 }
560 {
561 HashTableSize = 16411;
562 }
563 else
564 {
565 HashTableSize = 65537;
566 }
567 DPRINT(
"VFAT: Recognized volume\n");
572 DeviceToMount->Characteristics,
576 {
577 goto ByeBye;
578 }
579
583 DeviceExt->HashTableSize = HashTableSize;
585
588 DeviceExt->OverflowQueueCount = 0;
589 DeviceExt->PostedRequestCount = 0;
590
591
593 DeviceToMount->Vpb =
Vpb;
594
596
597 DPRINT(
"BytesPerSector: %u\n", DeviceExt->FatInfo.BytesPerSector);
598 DPRINT(
"SectorsPerCluster: %u\n", DeviceExt->FatInfo.SectorsPerCluster);
599 DPRINT(
"FATCount: %u\n", DeviceExt->FatInfo.FATCount);
600 DPRINT(
"FATSectors: %u\n", DeviceExt->FatInfo.FATSectors);
601 DPRINT(
"RootStart: %u\n", DeviceExt->FatInfo.rootStart);
602 DPRINT(
"DataStart: %u\n", DeviceExt->FatInfo.dataStart);
603 if (DeviceExt->FatInfo.FatType ==
FAT32)
604 {
605 DPRINT(
"RootCluster: %u\n", DeviceExt->FatInfo.RootCluster);
606 }
607
608 switch (DeviceExt->FatInfo.FatType)
609 {
614
615
616
617 break;
618
626 break;
627
635 break;
636 }
637
638 if (DeviceExt->FatInfo.FatType ==
FATX16 ||
639 DeviceExt->FatInfo.FatType ==
FATX32)
640 {
642 DeviceExt->BaseDateYear = 2000;
644 }
645 else
646 {
647 DeviceExt->BaseDateYear = 1980;
649 }
650
651 DeviceExt->StorageDevice = DeviceToMount;
652 DeviceExt->StorageDevice->Vpb->DeviceObject =
DeviceObject;
653 DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
654 DeviceExt->StorageDevice->Vpb->Flags |=
VPB_MOUNTED;
655 DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
657
659
660
662
665 if (DeviceExt->SpareVPB ==
NULL)
666 {
668 goto ByeBye;
669 }
670
674 if (DeviceExt->Statistics ==
NULL)
675 {
677 goto ByeBye;
678 }
679
682 {
684 DeviceExt->Statistics[
i].Base.Version = 1;
685 DeviceExt->Statistics[
i].Base.SizeOfCompleteStructure =
sizeof(
STATISTICS);
686 }
687
691 {
693 goto ByeBye;
694 }
695
698 goto ByeBye;
699
700 DeviceExt->FATFileObject->PrivateCacheMap =
NULL;
702
707
709 {
715 }
717 {
719 goto ByeBye;
720 }
722
723 DeviceExt->LastAvailableCluster = 2;
726
728
729 VolumeFcb =
vfatNewFCB(DeviceExt, &VolumeNameU);
730 if (VolumeFcb ==
NULL)
731 {
733 goto ByeBye;
734 }
735
740 DeviceExt->VolumeFcb = VolumeFcb;
741
745
746
747 DeviceObject->Vpb->SerialNumber = DeviceExt->FatInfo.VolumeID;
748
749
754 Vpb->VolumeLabelLength = VolumeLabelU.
Length;
755
756
759 {
760
761 if (!Dirty)
762 {
763
766 }
767 else
768 {
769 DPRINT1(
"Mounting a dirty volume\n");
770 }
771 }
772
775 {
777 }
778
779
782
783
785
786
788
789 DPRINT(
"Mount success\n");
790
792
793ByeBye:
795 {
796
797 if (DeviceExt && DeviceExt->FATFileObject)
798 {
801
808 DeviceExt->FATFileObject =
NULL;
809 }
812 if (DeviceExt && DeviceExt->SpareVPB)
814 if (DeviceExt && DeviceExt->Statistics)
818 }
819
821}
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
NTSTATUS FAT32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster, PULONG NextCluster)
NTSTATUS FAT12FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
NTSTATUS CountAvailableClusters(PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER Clusters)
NTSTATUS FAT16SetDirtyStatus(PDEVICE_EXTENSION DeviceExt, BOOLEAN DirtyStatus)
NTSTATUS FAT16GetDirtyStatus(PDEVICE_EXTENSION DeviceExt, PBOOLEAN DirtyStatus)
NTSTATUS FAT32GetDirtyStatus(PDEVICE_EXTENSION DeviceExt, PBOOLEAN DirtyStatus)
NTSTATUS FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, ULONG NewValue, PULONG OldValue)
NTSTATUS FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, ULONG NewValue, PULONG OldValue)
NTSTATUS FAT16FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
NTSTATUS FAT12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster, PULONG NextCluster)
NTSTATUS FAT32SetDirtyStatus(PDEVICE_EXTENSION DeviceExt, BOOLEAN DirtyStatus)
NTSTATUS FAT16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster, PULONG NextCluster)
NTSTATUS FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, ULONG NewValue, PULONG OldValue)
NTSTATUS GetDirtyStatus(PDEVICE_EXTENSION DeviceExt, PBOOLEAN DirtyStatus)
NTSTATUS FAT32FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
#define InsertHeadList(ListHead, Entry)
NTSTATUS ExInitializeResourceLite(PULONG res)
#define DO_SYSTEM_BOOT_PARTITION
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define FSRTL_VOLUME_MOUNT
VOID NTAPI FsRtlNotifyInitializeSync(IN PNOTIFY_SYNC *NotifySync)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILESYSTEM_STATISTICS_TYPE_FAT
PDRIVER_OBJECT DriverObject
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
LIST_ENTRY VolumeListHead
PDEVICE_OBJECT DeviceObject
struct _IO_STACK_LOCATION::@3979::@3999 MountVolume
FSRTL_COMMON_FCB_HEADER RFCB
#define RTL_CONSTANT_STRING(s)
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNRECOGNIZED_VOLUME
struct _VFATCCB * PVFATCCB
FORCEINLINE BOOLEAN vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
NTSTATUS vfatAttachFCBToFileObject(PDEVICE_EXTENSION vcb, PVFATFCB fcb, PFILE_OBJECT fileObject)
VOID vfatDestroyCCB(PVFATCCB pCcb)
PVFATFCB vfatNewFCB(PDEVICE_EXTENSION pVCB, PUNICODE_STRING pFileNameU)
VFAT_DISPATCH FatXDispatch
static NTSTATUS VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount, PBOOLEAN RecognizedFS, PFATINFO pFatInfo, BOOLEAN Override)
VFAT_DISPATCH FatDispatch
static NTSTATUS ReadVolumeLabel(PVOID Device, ULONG Start, BOOLEAN IsFatX, PUNICODE_STRING VolumeLabel)
#define ObDereferenceObject