summaryrefslogtreecommitdiffhomepage
path: root/Boot/BootKit/BootKit.hxx
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-04 17:47:13 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-04 17:48:40 +0200
commitfb0ca452cda3bdc4a13f278c115f2dcd9360d818 (patch)
tree788411aebd30ed446cb8c4bb5756a3e937c08f0a /Boot/BootKit/BootKit.hxx
parent34bb37c9a464ab0dfccfa5ff217a283e36b32693 (diff)
[IMP] [MHR-39] Ticket done.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Boot/BootKit/BootKit.hxx')
-rw-r--r--Boot/BootKit/BootKit.hxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/Boot/BootKit/BootKit.hxx b/Boot/BootKit/BootKit.hxx
index 1f6b7d95..680c9863 100644
--- a/Boot/BootKit/BootKit.hxx
+++ b/Boot/BootKit/BootKit.hxx
@@ -273,9 +273,9 @@ private:
constexpr auto cNewFSCatalogPadding = 4;
- NFS_CATALOG_STRUCT* catalogKind = (NFS_CATALOG_STRUCT*)bufCatalog;
- catalogKind->PrevSibling = startLba;
- catalogKind->NextSibling = (startLba + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding));
+ NFS_CATALOG_STRUCT* catalogKind = (NFS_CATALOG_STRUCT*)bufCatalog;
+ catalogKind->PrevSibling = startLba;
+ catalogKind->NextSibling = (startLba + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding));
/// Fill catalog kind.
catalogKind->Kind = blob->fKind;
@@ -288,6 +288,9 @@ private:
EFI::ThrowError(L"Developer-Error", L"This is caused by the developer of the bootloader.");
}
+ --partBlock.FreeCatalog;
+ --partBlock.FreeSectors;
+
writer.Write(L"newosldr: root directory: ").Write(blob->fFileName).Write(L"\r");
memcpy(catalogKind->Name, blob->fFileName, strlen(blob->fFileName));
@@ -297,11 +300,6 @@ private:
fDiskDev.Write((Char*)bufCatalog, sizeof(NFS_CATALOG_STRUCT));
- --partBlock.FreeCatalog;
- --partBlock.FreeSectors;
-
- memset(bufCatalog, 0, sizeof(NFS_CATALOG_STRUCT));
-
return true;
}
@@ -324,8 +322,8 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName,
return false; /// sanity check
/// convert the sector into something that the disk understands.
- SizeT sectorSz = BootDev::kSectorSize;
- Char buf[BootDev::kSectorSize] = {0};
+ SizeT sectorSz = BootDev::kSectorSize;
+ Char* buf = new Char[BootDev::kSectorSize];
NFS_ROOT_PARTITION_BLOCK* partBlock = reinterpret_cast<NFS_ROOT_PARTITION_BLOCK*>(buf);
@@ -340,6 +338,7 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName,
if (GIB(fDiskDev.GetDiskSize()) < cMinimumDiskSize)
{
+ delete buf;
EFI::ThrowError(L"Disk-Too-Tiny", L"Can't format a New Filesystem partition here.");
return false;
}
@@ -382,19 +381,22 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName,
CopyMem(epmBoot->Magic, reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), StrLen(kEPMMagic));
BTextWriter writer;
- writer.Write(L"newosldr: wrote partition.\r");
+ writer.Write(L"newosldr: wrote partition with success.\r");
fDiskDev.Leak().mBase = kEpmBase;
fDiskDev.Leak().mSize = sectorSz;
fDiskDev.Write(buf, sectorSz);
+ delete buf;
return true;
}
else
{
+ delete buf;
EFI::ThrowError(L"Filesystem-Failure-Part", L"Filesystem couldn't be partitioned.");
}
+ delete buf;
return false;
}