Author: pschweitzer
Date: Sat Jun 11 09:32:00 2016
New Revision: 71610
URL:
http://svn.reactos.org/svn/reactos?rev=71610&view=rev
Log:
[FASTFAT]
Properly round up 64b values.
This fixes reads on 4GB+ volumes.
Patch by Wim Hueskes.
CORE-10932 #resolve #comment Thanks for the patch! Commited in r71610
Modified:
trunk/reactos/drivers/filesystems/fastfat/fcb.c
trunk/reactos/drivers/filesystems/fastfat/finfo.c
trunk/reactos/drivers/filesystems/fastfat/fsctl.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] Sat Jun 11 09:32:00 2016
@@ -668,7 +668,7 @@
}
rcFCB->RFCB.FileSize.QuadPart = Size;
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
- rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP(Size,
vcb->FatInfo.BytesPerCluster);
+ rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP_64(Size,
vcb->FatInfo.BytesPerCluster);
rcFCB->RefCount = 1;
if (vfatFCBIsDirectory(rcFCB))
{
Modified: trunk/reactos/drivers/filesystems/fastfat/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] Sat Jun 11 09:32:00
2016
@@ -1114,7 +1114,7 @@
{
if (Size > 0)
{
- Fcb->RFCB.AllocationSize.QuadPart = ROUND_UP(Size, ClusterSize);
+ Fcb->RFCB.AllocationSize.QuadPart = ROUND_UP_64(Size, ClusterSize);
}
else
{
Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] Sat Jun 11 09:32:00
2016
@@ -576,7 +576,7 @@
}
VolumeFcb->Flags = FCB_IS_VOLUME;
- VolumeFcb->RFCB.FileSize.QuadPart = DeviceExt->FatInfo.Sectors *
DeviceExt->FatInfo.BytesPerSector;
+ VolumeFcb->RFCB.FileSize.QuadPart = (LONGLONG) DeviceExt->FatInfo.Sectors *
DeviceExt->FatInfo.BytesPerSector;
VolumeFcb->RFCB.ValidDataLength = VolumeFcb->RFCB.FileSize;
VolumeFcb->RFCB.AllocationSize = VolumeFcb->RFCB.FileSize;
DeviceExt->VolumeFcb = VolumeFcb;
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Sat Jun 11 09:32:00 2016
@@ -150,7 +150,7 @@
BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
- ASSERT(ReadOffset.QuadPart + Length <= ROUND_UP(Fcb->RFCB.FileSize.QuadPart,
BytesPerSector));
+ ASSERT(ReadOffset.QuadPart + Length <= ROUND_UP_64(Fcb->RFCB.FileSize.QuadPart,
BytesPerSector));
ASSERT(ReadOffset.u.LowPart % BytesPerSector == 0);
ASSERT(Length % BytesPerSector == 0);
@@ -711,9 +711,9 @@
else
{
// non cached read
- if (ByteOffset.QuadPart + Length > ROUND_UP(Fcb->RFCB.FileSize.QuadPart,
BytesPerSector))
- {
- Length = (ULONG)(ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector) -
ByteOffset.QuadPart);
+ if (ByteOffset.QuadPart + Length > ROUND_UP_64(Fcb->RFCB.FileSize.QuadPart,
BytesPerSector))
+ {
+ Length = (ULONG)(ROUND_UP_64(Fcb->RFCB.FileSize.QuadPart, BytesPerSector)
- ByteOffset.QuadPart);
}
Status = VfatReadFileData(IrpContext, Length, ByteOffset, &ReturnedLength);
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Sat Jun 11 09:32:00
2016
@@ -24,6 +24,12 @@
#define ROUND_UP(n, align) \
ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
+
+#define ROUND_DOWN_64(n, align) \
+ (((ULONGLONG)n) & ~((align) - 1LL))
+
+#define ROUND_UP_64(n, align) \
+ ROUND_DOWN_64(((ULONGLONG)n) + (align) - 1LL, (align))
#include <pshpack1.h>
struct _BootSector