mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 05:32:55 +00:00
Herve Poussineau <poussine@freesurf.fr>
Simpily the VFAT/FATX detection. svn path=/trunk/; revision=12963
This commit is contained in:
parent
1eb8f5f55d
commit
95ba8cd118
1 changed files with 14 additions and 58 deletions
|
@ -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,17 +110,11 @@ 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;
|
*RecognizedFS = FALSE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
if (*RecognizedFS &&
|
if (*RecognizedFS &&
|
||||||
Boot->BytesPerSector != 512 &&
|
Boot->BytesPerSector != 512 &&
|
||||||
|
@ -167,7 +123,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||||
Boot->BytesPerSector != 4096)
|
Boot->BytesPerSector != 4096)
|
||||||
{
|
{
|
||||||
DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
|
DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
|
||||||
*RecognizedFS=FALSE;
|
*RecognizedFS = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*RecognizedFS &&
|
if (*RecognizedFS &&
|
||||||
|
@ -175,7 +131,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||||
Boot->FATCount != 2)
|
Boot->FATCount != 2)
|
||||||
{
|
{
|
||||||
DPRINT1("FATCount %d\n", Boot->FATCount);
|
DPRINT1("FATCount %d\n", Boot->FATCount);
|
||||||
*RecognizedFS=FALSE;
|
*RecognizedFS = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*RecognizedFS &&
|
if (*RecognizedFS &&
|
||||||
|
@ -190,7 +146,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||||
Boot->Media != 0xff)
|
Boot->Media != 0xff)
|
||||||
{
|
{
|
||||||
DPRINT1("Media %02x\n", Boot->Media);
|
DPRINT1("Media %02x\n", Boot->Media);
|
||||||
*RecognizedFS=FALSE;
|
*RecognizedFS = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*RecognizedFS &&
|
if (*RecognizedFS &&
|
||||||
|
@ -204,14 +160,14 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||||
Boot->SectorsPerCluster != 128)
|
Boot->SectorsPerCluster != 128)
|
||||||
{
|
{
|
||||||
DPRINT1("SectorsPerCluster %02x\n", Boot->SectorsPerCluster);
|
DPRINT1("SectorsPerCluster %02x\n", Boot->SectorsPerCluster);
|
||||||
*RecognizedFS=FALSE;
|
*RecognizedFS = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*RecognizedFS &&
|
if (*RecognizedFS &&
|
||||||
Boot->BytesPerSector * Boot->SectorsPerCluster > 32 * 1024)
|
Boot->BytesPerSector * Boot->SectorsPerCluster > 32 * 1024)
|
||||||
{
|
{
|
||||||
DPRINT1("ClusterSize %dx\n", Boot->BytesPerSector * Boot->SectorsPerCluster);
|
DPRINT1("ClusterSize %dx\n", Boot->BytesPerSector * Boot->SectorsPerCluster);
|
||||||
*RecognizedFS=FALSE;
|
*RecognizedFS = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*RecognizedFS)
|
if (*RecognizedFS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue