Herve Poussineau <poussine@freesurf.fr>

Simpily the VFAT/FATX detection.

svn path=/trunk/; revision=12963
This commit is contained in:
Filip Navara 2005-01-12 13:15:24 +00:00
parent 1eb8f5f55d
commit 95ba8cd118

View file

@ -86,59 +86,21 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
return Status; return Status;
} }
PartitionInfoIsValid = TRUE; PartitionInfoIsValid = TRUE;
DPRINT("Partition Information:\n"); }
DPRINT("StartingOffset %u\n", PartitionInfo.StartingOffset.QuadPart / 512); else if (DiskGeometry.MediaType == Unknown)
DPRINT("PartitionLength %u\n", PartitionInfo.PartitionLength.QuadPart / 512);
DPRINT("HiddenSectors %u\n", PartitionInfo.HiddenSectors);
DPRINT("PartitionNumber %u\n", PartitionInfo.PartitionNumber);
DPRINT("PartitionType %u\n", PartitionInfo.PartitionType);
DPRINT("BootIndicator %u\n", PartitionInfo.BootIndicator);
DPRINT("RecognizedPartition %u\n", PartitionInfo.RecognizedPartition);
DPRINT("RewritePartition %u\n", PartitionInfo.RewritePartition);
if (PartitionInfo.PartitionType)
{ {
if (PartitionInfo.PartitionType == PARTITION_FAT_12 ||
PartitionInfo.PartitionType == PARTITION_FAT_16 ||
PartitionInfo.PartitionType == PARTITION_HUGE ||
PartitionInfo.PartitionType == PARTITION_FAT32 ||
PartitionInfo.PartitionType == PARTITION_FAT32_XINT13 ||
PartitionInfo.PartitionType == PARTITION_XINT13)
{
*RecognizedFS = TRUE;
}
}
else if (DiskGeometry.MediaType == RemovableMedia &&
PartitionInfo.PartitionNumber > 0 &&
PartitionInfo.StartingOffset.QuadPart == 0LL &&
PartitionInfo.PartitionLength.QuadPart > 0LL)
{
/* This is possible a removable media formated as super floppy */
*RecognizedFS = TRUE;
}
}
/* /*
* Floppy disk driver can return Unknown as media type if it * Floppy disk driver can return Unknown as media type if it
* doesn't know yet what floppy in the drive really is. This is * doesn't know yet what floppy in the drive really is. This is
* perfectly correct to do under Windows. * perfectly correct to do under Windows.
*/ */
if (DiskGeometry.MediaType == Unknown)
{
*RecognizedFS = TRUE; *RecognizedFS = TRUE;
DiskGeometry.BytesPerSector = 512; DiskGeometry.BytesPerSector = 512;
} }
if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType < RemovableMedia )
{
*RecognizedFS = TRUE;
}
if (*RecognizedFS == FALSE)
{
return STATUS_SUCCESS;
}
Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector); Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector);
if (Boot == NULL) if (Boot == NULL)
{ {
*RecognizedFS=FALSE;
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -148,16 +110,10 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE); Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*RecognizedFS = TRUE;
if (Boot->Signatur1 != 0xaa55) if (Boot->Signatur1 != 0xaa55)
{ {
BootFatX = (struct _BootSectorFatX *) Boot;
if (BootFatX->SysType[0] != 'F' ||
BootFatX->SysType[1] != 'A' ||
BootFatX->SysType[2] != 'T' ||
BootFatX->SysType[3] != 'X')
{
DPRINT1("Signature %04x\n", Boot->Signatur1);
}
*RecognizedFS = FALSE; *RecognizedFS = FALSE;
} }
if (*RecognizedFS && if (*RecognizedFS &&