mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Fixed handling of large FAT32 partitions.
svn path=/trunk/; revision=3928
This commit is contained in:
parent
0a4d96cc81
commit
267074bb2e
3 changed files with 9 additions and 55 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: fat.c,v 1.40 2002/10/01 19:27:18 chorns Exp $
|
* $Id: fat.c,v 1.41 2003/01/04 02:07:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -632,7 +632,7 @@ WriteCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG
|
ULONGLONG
|
||||||
ClusterToSector(PDEVICE_EXTENSION DeviceExt,
|
ClusterToSector(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG Cluster)
|
ULONG Cluster)
|
||||||
/*
|
/*
|
||||||
|
@ -641,7 +641,8 @@ ClusterToSector(PDEVICE_EXTENSION DeviceExt,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return DeviceExt->FatInfo.dataStart +
|
return DeviceExt->FatInfo.dataStart +
|
||||||
((Cluster - 2) * DeviceExt->FatInfo.SectorsPerCluster);
|
((ULONGLONG)(Cluster - 2) * DeviceExt->FatInfo.SectorsPerCluster);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -774,44 +775,4 @@ GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
GetNextSector(PDEVICE_EXTENSION DeviceExt,
|
|
||||||
ULONG CurrentSector,
|
|
||||||
PULONG NextSector,
|
|
||||||
BOOLEAN Extend)
|
|
||||||
/* Some functions don't have access to the cluster they're really reading from.
|
|
||||||
Maybe this is a dirty solution, but it will allow them to handle fragmentation. */
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("GetNextSector(DeviceExt %x, CurrentSector %x)\n",
|
|
||||||
DeviceExt,
|
|
||||||
CurrentSector);
|
|
||||||
if (CurrentSector<DeviceExt->FatInfo.dataStart || ((CurrentSector - DeviceExt->FatInfo.dataStart + 1) % DeviceExt->FatInfo.SectorsPerCluster))
|
|
||||||
/* Basically, if the next sequential sector would be on a cluster border, then we'll need to check in the FAT */
|
|
||||||
{
|
|
||||||
(*NextSector)=CurrentSector+1;
|
|
||||||
return (STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CurrentSector = (CurrentSector - DeviceExt->FatInfo.dataStart) / DeviceExt->FatInfo.SectorsPerCluster + 2;
|
|
||||||
|
|
||||||
Status = GetNextCluster(DeviceExt, CurrentSector, NextSector, Extend);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
if ((*NextSector) == 0 || (*NextSector) == 0xffffffff)
|
|
||||||
{
|
|
||||||
/* The caller wants to know a sector. These FAT codes don't correspond to any sector. */
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
(*NextSector) = ClusterToSector(DeviceExt,(*NextSector));
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
/* $Id: rw.c,v 1.51 2003/01/03 23:58:31 gvg Exp $
|
/* $Id: rw.c,v 1.52 2003/01/04 02:07:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -273,7 +273,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PVOID Buffer,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG BytesDone;
|
ULONG BytesDone;
|
||||||
ULONG BytesPerSector;
|
ULONG BytesPerSector;
|
||||||
LARGE_INTEGER BytesPerSectorLarge;
|
|
||||||
ULONG BytesPerCluster;
|
ULONG BytesPerCluster;
|
||||||
|
|
||||||
/* PRECONDITION */
|
/* PRECONDITION */
|
||||||
|
@ -293,7 +292,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PVOID Buffer,
|
||||||
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
|
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
|
||||||
Fcb = Ccb->pFcb;
|
Fcb = Ccb->pFcb;
|
||||||
BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
|
BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
|
||||||
BytesPerSectorLarge.QuadPart = BytesPerSector;
|
|
||||||
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
|
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
|
||||||
|
|
||||||
assert(ReadOffset.QuadPart + Length <= ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector));
|
assert(ReadOffset.QuadPart + Length <= ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector));
|
||||||
|
@ -377,7 +375,7 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PVOID Buffer,
|
||||||
while (Length > 0 && CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
|
while (Length > 0 && CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
StartCluster = CurrentCluster;
|
StartCluster = CurrentCluster;
|
||||||
StartOffset.QuadPart = ClusterToSector(DeviceExt, StartCluster) * BytesPerSectorLarge.QuadPart;
|
StartOffset.QuadPart = ClusterToSector(DeviceExt, StartCluster) * BytesPerSector;
|
||||||
BytesDone = 0;
|
BytesDone = 0;
|
||||||
ClusterCount = 0;
|
ClusterCount = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: vfat.h,v 1.49 2002/12/03 01:14:49 hbirr Exp $ */
|
/* $Id: vfat.h,v 1.50 2003/01/04 02:07:18 hbirr Exp $ */
|
||||||
|
|
||||||
#include <ddk/ntifs.h>
|
#include <ddk/ntifs.h>
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ NTSTATUS OffsetToCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
PULONG Cluster,
|
PULONG Cluster,
|
||||||
BOOLEAN Extend);
|
BOOLEAN Extend);
|
||||||
|
|
||||||
ULONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
|
ULONGLONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG Cluster);
|
ULONG Cluster);
|
||||||
|
|
||||||
NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
|
@ -405,11 +405,6 @@ NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
PULONG NextCluster,
|
PULONG NextCluster,
|
||||||
BOOLEAN Extend);
|
BOOLEAN Extend);
|
||||||
|
|
||||||
NTSTATUS GetNextSector (PDEVICE_EXTENSION DeviceExt,
|
|
||||||
ULONG CurrentSector,
|
|
||||||
PULONG NextSector,
|
|
||||||
BOOLEAN Extend);
|
|
||||||
|
|
||||||
NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
|
NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
|
||||||
PLARGE_INTEGER Clusters);
|
PLARGE_INTEGER Clusters);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue