[FREELDR] Use the new volume size mechanism when loading a storage volume as a RamDisk (#8423)

CORE-14603

The differentiation between a regular file loaded as a RamDisk and a
storage device volume, is done by invoking `ArcGetFileInformation()`
and looking at the `Information.Type` value.
This commit is contained in:
Hermès Bélusca-Maïto
2025-10-04 16:30:30 +02:00
parent 0ac0eb251c
commit fa92d95800

View File

@@ -129,7 +129,7 @@ RamDiskLoadVirtualFile(
if (Status != ESUCCESS)
return Status;
/* Get the file size */
/* Get the file or device size */
Status = ArcGetFileInformation(RamFileId, &Information);
if (Status != ESUCCESS)
{
@@ -141,6 +141,18 @@ RamDiskLoadVirtualFile(
Information.EndingAddress.QuadPart -= Information.StartingAddress.QuadPart;
Information.StartingAddress.QuadPart = 0ULL;
/* If we are actually opening a RAW device, retrieve instead its usable volume size */
if (Information.FileNameLength == 0 && Information.FileName[0] == ANSI_NULL &&
(Information.Type == DiskPeripheral || Information.Type == FloppyDiskPeripheral))
{
ULONGLONG VolumeSize;
Status = FsGetVolumeSize(RamFileId, &VolumeSize);
if (Status != ESUCCESS)
ERR("Couldn't retrieve volume size on device '%s', falling back to RAW size\n", FileName);
else
Information.EndingAddress.QuadPart = VolumeSize;
}
TRACE("RAMDISK size: %I64u (High: %lu ; Low: %lu)\n",
Information.EndingAddress.QuadPart,
Information.EndingAddress.HighPart,