From 4db827d1520c86a90896293a55a40f3c5c4a471b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Fri, 30 May 2008 18:55:05 +0000 Subject: [PATCH] Check cluster size when mounting a volume svn path=/trunk/; revision=33779 --- reactos/drivers/filesystems/ntfs/fsctl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/filesystems/ntfs/fsctl.c b/reactos/drivers/filesystems/ntfs/fsctl.c index b956c06ba32..ab53c79a0a4 100644 --- a/reactos/drivers/filesystems/ntfs/fsctl.c +++ b/reactos/drivers/filesystems/ntfs/fsctl.c @@ -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);