From c20093e554f35bde56e7be5118559141da6e6f15 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Tue, 16 Mar 2004 08:30:28 +0000 Subject: [PATCH] Arty's summary: drivers/fs/cdfs/fsctl: Allocate wide chars. CD title was being truncated drivers/fs/vfat/fsctl: Tolerate a zero bytes-per-sector Patches by Herve Poussineau svn path=/trunk/; revision=8761 --- reactos/drivers/fs/cdfs/fsctl.c | 4 +- reactos/drivers/fs/vfat/fsctl.c | 69 ++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/reactos/drivers/fs/cdfs/fsctl.c b/reactos/drivers/fs/cdfs/fsctl.c index 7257cf7c172..d21d0cb9143 100644 --- a/reactos/drivers/fs/cdfs/fsctl.c +++ b/reactos/drivers/fs/cdfs/fsctl.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fsctl.c,v 1.18 2004/03/08 08:51:26 ekohl Exp $ +/* $Id: fsctl.c,v 1.19 2004/03/16 08:30:28 arty Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -83,7 +83,7 @@ CdfsGetPVDData(PUCHAR Buffer, *pw++ = (WCHAR)*pc++; } *pw = 0; - CdInfo->VolumeLabelLength = i; + CdInfo->VolumeLabelLength = i * sizeof(WCHAR); CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL; CdInfo->RootStart = Pvd->RootDirRecord.ExtentLocationL; diff --git a/reactos/drivers/fs/vfat/fsctl.c b/reactos/drivers/fs/vfat/fsctl.c index 18761725623..51adc4d8379 100644 --- a/reactos/drivers/fs/vfat/fsctl.c +++ b/reactos/drivers/fs/vfat/fsctl.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fsctl.c,v 1.27 2004/01/28 20:53:46 ekohl Exp $ +/* $Id: fsctl.c,v 1.28 2004/03/16 08:30:28 arty Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -127,40 +127,47 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount, Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE); if (NT_SUCCESS(Status)) { - FatInfo.VolumeID = Boot->VolumeID; - FatInfo.FATStart = Boot->ReservedSectors; - FatInfo.FATCount = Boot->FATCount; - FatInfo.FATSectors = Boot->FATSectors ? Boot->FATSectors : ((struct _BootSector32*) Boot)->FATSectors32; - FatInfo.BytesPerSector = Boot->BytesPerSector; - FatInfo.SectorsPerCluster = Boot->SectorsPerCluster; - FatInfo.BytesPerCluster = FatInfo.BytesPerSector * FatInfo.SectorsPerCluster; - FatInfo.rootDirectorySectors = ((Boot->RootEntries * 32) + Boot->BytesPerSector - 1) / Boot->BytesPerSector; - FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors; - FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors; - FatInfo.Sectors = Sectors = Boot->Sectors ? Boot->Sectors : Boot->SectorsHuge; - Sectors -= Boot->ReservedSectors + FatInfo.FATCount * FatInfo.FATSectors + FatInfo.rootDirectorySectors; - FatInfo.NumberOfClusters = Sectors / Boot->SectorsPerCluster; - if (FatInfo.NumberOfClusters < 4085) + if (Boot->BytesPerSector != 0) { - DPRINT("FAT12\n"); - FatInfo.FatType = FAT12; - } - else if (FatInfo.NumberOfClusters >= 65525) - { - DPRINT("FAT32\n"); - FatInfo.FatType = FAT32; - FatInfo.RootCluster = ((struct _BootSector32*) Boot)->RootCluster; - FatInfo.rootStart = FatInfo.dataStart + ((FatInfo.RootCluster - 2) * FatInfo.SectorsPerCluster); - FatInfo.VolumeID = ((struct _BootSector32*) Boot)->VolumeID; + FatInfo.VolumeID = Boot->VolumeID; + FatInfo.FATStart = Boot->ReservedSectors; + FatInfo.FATCount = Boot->FATCount; + FatInfo.FATSectors = Boot->FATSectors ? Boot->FATSectors : ((struct _BootSector32*) Boot)->FATSectors32; + FatInfo.BytesPerSector = Boot->BytesPerSector; + FatInfo.SectorsPerCluster = Boot->SectorsPerCluster; + FatInfo.BytesPerCluster = FatInfo.BytesPerSector * FatInfo.SectorsPerCluster; + FatInfo.rootDirectorySectors = ((Boot->RootEntries * 32) + Boot->BytesPerSector - 1) / Boot->BytesPerSector; + FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors; + FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors; + FatInfo.Sectors = Sectors = Boot->Sectors ? Boot->Sectors : Boot->SectorsHuge; + Sectors -= Boot->ReservedSectors + FatInfo.FATCount * FatInfo.FATSectors + FatInfo.rootDirectorySectors; + FatInfo.NumberOfClusters = Sectors / Boot->SectorsPerCluster; + if (FatInfo.NumberOfClusters < 4085) + { + DPRINT("FAT12\n"); + FatInfo.FatType = FAT12; + } + else if (FatInfo.NumberOfClusters >= 65525) + { + DPRINT("FAT32\n"); + FatInfo.FatType = FAT32; + FatInfo.RootCluster = ((struct _BootSector32*) Boot)->RootCluster; + FatInfo.rootStart = FatInfo.dataStart + ((FatInfo.RootCluster - 2) * FatInfo.SectorsPerCluster); + FatInfo.VolumeID = ((struct _BootSector32*) Boot)->VolumeID; + } + else + { + DPRINT("FAT16\n"); + FatInfo.FatType = FAT16; + } + if (pFatInfo) + { + *pFatInfo = FatInfo; + } } else { - DPRINT("FAT16\n"); - FatInfo.FatType = FAT16; - } - if (pFatInfo) - { - *pFatInfo = FatInfo; + Status = STATUS_INSUFFICIENT_RESOURCES; } } ExFreePool(Boot);