https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ef76709b3d2d376ed4747…
commit ef76709b3d2d376ed4747f337759383bc40a433c
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Tue Jul 30 01:27:36 2019 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue Jul 30 00:27:36 2019 +0200
[FREELDR] Fix remaining hwdisk and FATX bugs (#1766)
- DiskGetFileInformation() should return relative addresses -- relative to the
beginning of the "device" (partition, or disk) in question.
- FatXSearchDirectoryBufferForFile() should assign file attributes.
- Minor code style improvements in FatOpenVolume().
CORE-16216 CORE-16248
Co-authored-by: Victor Perevertkin <victor(a)perevertkin.ru>
---
boot/freeldr/freeldr/arch/i386/hwdisk.c | 4 ++--
boot/freeldr/freeldr/lib/fs/fat.c | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/boot/freeldr/freeldr/arch/i386/hwdisk.c
b/boot/freeldr/freeldr/arch/i386/hwdisk.c
index 50bb00e8406..bae615b0a09 100644
--- a/boot/freeldr/freeldr/arch/i386/hwdisk.c
+++ b/boot/freeldr/freeldr/arch/i386/hwdisk.c
@@ -65,8 +65,8 @@ DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information)
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
RtlZeroMemory(Information, sizeof(FILEINFORMATION));
- Information->EndingAddress.QuadPart = (Context->SectorOffset +
Context->SectorCount) * Context->SectorSize;
- Information->CurrentAddress.QuadPart = (Context->SectorOffset +
Context->SectorNumber) * Context->SectorSize;
+ Information->EndingAddress.QuadPart = Context->SectorCount *
Context->SectorSize;
+ Information->CurrentAddress.QuadPart = Context->SectorNumber *
Context->SectorSize;
return ESUCCESS;
}
diff --git a/boot/freeldr/freeldr/lib/fs/fat.c b/boot/freeldr/freeldr/lib/fs/fat.c
index 6af232b3acf..6daa1a0b4fa 100644
--- a/boot/freeldr/freeldr/lib/fs/fat.c
+++ b/boot/freeldr/freeldr/lib/fs/fat.c
@@ -266,12 +266,12 @@ BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR
BootSector, ULONG
{
Volume->BytesPerSector = 512;
Volume->SectorsPerCluster =
SWAPD(FatXVolumeBootSector->SectorsPerCluster);
- Volume->FatSectorStart = (4096 / Volume->BytesPerSector);
+ Volume->FatSectorStart = (0x1000 / Volume->BytesPerSector);
Volume->ActiveFatSectorStart = Volume->FatSectorStart;
Volume->NumberOfFats = 1;
FatSize = (ULONG)(PartitionSectorCount / Volume->SectorsPerCluster *
(Volume->FatType == FATX16 ? 2 : 4));
- Volume->SectorsPerFat = (((FatSize + 4095) / 4096) * 4096) /
Volume->BytesPerSector;
+ Volume->SectorsPerFat = ROUND_UP(FatSize, 0x1000) /
Volume->BytesPerSector;
Volume->RootDirSectorStart = Volume->FatSectorStart +
Volume->NumberOfFats * Volume->SectorsPerFat;
Volume->RootDirSectors = FatXVolumeBootSector->SectorsPerCluster;
@@ -720,6 +720,7 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO
Volume, PVOID D
/*
* We found the entry, now fill in the FAT_FILE_INFO struct
*/
+ FatFileInfoPointer->Attributes = DirEntry->Attr;
FatFileInfoPointer->FileSize = DirEntry->Size;
FatFileInfoPointer->FilePointer = 0;