summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBA
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-30 10:04:19 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-30 10:04:19 +0200
commit5229ca8ae190c0cb3db8d381a44be4113e81d5dc (patch)
tree03af438c8ae325294e801adb6ee6aa80430d30cb /dev/ZBA
parentd87eb24271671f4d7d1298c6c4bbdf4e73f774f3 (diff)
A lot of filesystem improvements.
+ Save NextSibling field if catalog name, has parent name in it. + Upgrade NewFS to 1.28. + Fix strcmp inside Support.cxx + BootKit formatter can update the partition now, but only if NewFS. + Fix broken logging window.
Diffstat (limited to 'dev/ZBA')
-rw-r--r--dev/ZBA/BootKit/BootKit.hxx58
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/Support.cxx2
2 files changed, 45 insertions, 15 deletions
diff --git a/dev/ZBA/BootKit/BootKit.hxx b/dev/ZBA/BootKit/BootKit.hxx
index 59b222c9..1d0dca94 100644
--- a/dev/ZBA/BootKit/BootKit.hxx
+++ b/dev/ZBA/BootKit/BootKit.hxx
@@ -271,8 +271,8 @@ private:
constexpr auto cNewFSCatalogPadding = 4;
- catalogKind.PrevSibling = startLba;
- catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ catalogKind.PrevSibling = startLba;
+ catalogKind.NextSibling = (startLba + sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
/// Fill catalog kind.
catalogKind.Kind = blob->fKind;
@@ -313,10 +313,6 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
/// convert the sector into something that the disk understands.
SizeT sectorSz = BootDev::kSectorSize;
- NFS_ROOT_PARTITION_BLOCK partBlock{0};
-
- CopyMem(partBlock.Ident, kNewFSIdent, kNewFSIdentLen - 1);
- CopyMem(partBlock.PartitionName, partName, strlen(partName));
/// @note A catalog roughly equal to a sector.
@@ -330,16 +326,50 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* partName,
return false;
}
- partBlock.Version = kNewFSVersionInteger;
+ fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
+ fDiskDev.Leak().mSize = sectorSz;
+
+ NFS_ROOT_PARTITION_BLOCK partBlock{0};
+
+ fDiskDev.Read((Char*)&partBlock, sizeof(NFS_ROOT_PARTITION_BLOCK));
+
+ if (strncmp(kNewFSIdent, partBlock.Ident, kNewFSIdentLen) == 0 &&
+ partBlock.Version != kNewFSVersionInteger)
+ {
+ BTextWriter writer;
+ writer.Write(L"newosldr: Disk partition updated.\r");
+
+ partBlock.Version = kNewFSVersionInteger;
+
+ fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
+ fDiskDev.Leak().mSize = sectorSz;
+
+ fDiskDev.Write((Char*)&partBlock, sectorSz);
+
+ return true;
+ }
+ else if (strncmp(kNewFSIdent, partBlock.Ident, kNewFSIdentLen))
+ {
+ BTextWriter writer;
+ writer.Write(L"newosldr: Disk partition error, not a valid one.\r");
+
+ // TODO: Find a way to use EFI::Stop.
+ while (1);
+ }
+
+ CopyMem(partBlock.Ident, kNewFSIdent, kNewFSIdentLen - 1);
+ CopyMem(partBlock.PartitionName, partName, strlen(partName));
+
+ partBlock.Version = kNewFSVersionInteger;
partBlock.CatalogCount = blobCount;
- partBlock.Kind = kNewFSHardDrive;
- partBlock.SectorSize = sectorSz;
- partBlock.FreeCatalog = fDiskDev.GetSectorsCount() / sizeof(NFS_CATALOG_STRUCT);
- partBlock.SectorCount = fDiskDev.GetSectorsCount();
- partBlock.FreeSectors = fDiskDev.GetSectorsCount();
+ partBlock.Kind = kNewFSHardDrive;
+ partBlock.SectorSize = sectorSz;
+ partBlock.FreeCatalog = fDiskDev.GetSectorsCount() / sizeof(NFS_CATALOG_STRUCT);
+ partBlock.SectorCount = fDiskDev.GetSectorsCount();
+ partBlock.FreeSectors = fDiskDev.GetSectorsCount();
partBlock.StartCatalog = kNewFSCatalogStartAddress;
- partBlock.DiskSize = fDiskDev.GetDiskSize();
- partBlock.Flags |= kNewFSPartitionTypeBoot | kNewFSPartitionTypeStandard;
+ partBlock.DiskSize = fDiskDev.GetDiskSize();
+ partBlock.Flags = kNewFSPartitionTypeBoot | kNewFSPartitionTypeStandard;
fDiskDev.Leak().mBase = kNewFSRootCatalogStartAddress;
fDiskDev.Leak().mSize = sectorSz;
diff --git a/dev/ZBA/Sources/HEL/AMD64/Support.cxx b/dev/ZBA/Sources/HEL/AMD64/Support.cxx
index 667bbfda..aa93318b 100644
--- a/dev/ZBA/Sources/HEL/AMD64/Support.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/Support.cxx
@@ -71,7 +71,7 @@ EXTERN_C int strcmp(const char* whatToCheck, const char* whatToCheckRight)
++len;
}
- return whatToCheck[len] == whatToCheckRight[len] ? 0 : len;
+ return len;
}
/// @brief somthing specific to the Microsoft's ABI, When the stack grows too big.