Check cluster size when mounting a volume

svn path=/trunk/; revision=33779
This commit is contained in:
Pierre Schweitzer 2008-05-30 18:55:05 +00:00
parent 18eca01b10
commit 4db827d152

View file

@ -45,9 +45,9 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
{
PARTITION_INFORMATION PartitionInfo;
DISK_GEOMETRY DiskGeometry;
ULONG ClusterSize, Size, k;
PBOOT_SECTOR BootSector;
NTSTATUS Status;
ULONG Size, k;
DPRINT1("NtfsHasFileSystem() called\n");
@ -91,7 +91,7 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
DPRINT1("BytesPerSector: %lu\n", DiskGeometry.BytesPerSector);
BootSector = ExAllocatePoolWithTag(NonPagedPool,
DiskGeometry.BytesPerSector, TAG_NTFS);
DiskGeometry.BytesPerSector, TAG_NTFS);
if (BootSector == NULL)
{
return(STATUS_INSUFFICIENT_RESOURCES);
@ -138,6 +138,17 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
goto ByeBye;
}
}
/* Check cluster size */
ClusterSize = BootSector->BPB.BytesPerSector * BootSector->BPB.SectorsPerCluster;
if (ClusterSize != 512 && ClusterSize != 1024 &&
ClusterSize != 2048 && ClusterSize != 4096)
{
DPRINT1("Cluster size failed: %hu, %hu, %hu\n", BootSector->BPB.BytesPerSector,
BootSector->BPB.SectorsPerCluster,
ClusterSize);
Status = STATUS_UNRECOGNIZED_VOLUME;
goto ByeBye;
}
ByeBye:
ExFreePool(BootSector);