diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
| commit | 7013c094668be2204b1245496236f0cf6afa07c2 (patch) | |
| tree | 2a15832577a580e51b55b758cb792d3225870157 /Private/Source/FS | |
| parent | e5a591054ea0992acc3cb786d3af9f358febca6d (diff) | |
MHR-5/MHR-3: Rename PowerPC to POWER, implement NewFSParser::Format
method, documenting code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/FS')
| -rw-r--r-- | Private/Source/FS/NewFS.cxx | 123 |
1 files changed, 88 insertions, 35 deletions
diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx index 1d7d3621..216db7c6 100644 --- a/Private/Source/FS/NewFS.cxx +++ b/Private/Source/FS/NewFS.cxx @@ -161,7 +161,53 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) { return false; } - return true; + Char sectorBuf[kNewFSMinimumSectorSz] = {0}; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fInput(&drive->fPacket); + + /// disk isnt faulty and data has been fetched. + if (drive->fPacket.fPacketGood) { + NewPartitionBlock* partBlock = (NewPartitionBlock*)sectorBuf; + if (partBlock->PartitionName[0] == 0 && + rt_string_cmp(partBlock->Ident, kNewFSIdent, kNewFSIdentLen) == 0) { + /// partition is free and valid. + + rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident, + kNewFSIdentLen); + rt_copy_memory((VoidPtr) "New OS\0", (VoidPtr)partBlock->PartitionName, + rt_string_len("New OS\0")); + + SizeT catalogCount = 0; + SizeT sectorCount = 0; + SizeT diskSize = 0; + + partBlock->Kind = kNewFSPartitionTypeStandard; + partBlock->StartCatalog = sizeof(NewPartitionBlock) + kNewFSAddressAsLba; + partBlock->CatalogCount = catalogCount; + partBlock->SectorCount = sectorCount; + partBlock->DiskSize = diskSize; + partBlock->FreeCatalog = partBlock->StartCatalog; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fOutput(&drive->fPacket); + + return true; + } + + kcout << "New OS: Partition already exists.\r\n"; + + /// return success as well, do not ignore that partition. + return true; + } + + return false; } /// @brief @@ -173,73 +219,80 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, return false; } -/// @brief -/// @param catalogName -/// @return +/// @brief +/// @param catalogName +/// @return _Output NewCatalog* NewFSParser::FindCatalog(_Input const char* catalogName) { return nullptr; } -/// @brief -/// @param name -/// @return +/// @brief +/// @param name +/// @return _Output NewCatalog* NewFSParser::GetCatalog(_Input const char* name) { return nullptr; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return Boolean NewFSParser::CloseCatalog(_Input _Output NewCatalog* catalog) { - return false; + return true; } -/// @brief -/// @param catalog -/// @return +/// @brief Mark catalog as removed. +/// @param catalog The catalog structure. +/// @return Boolean NewFSParser::RemoveCatalog(_Input _Output NewCatalog* catalog) { + catalog->Flags |= kNewFSFlagDeleted; + this->WriteCatalog(catalog, nullptr); + return false; } -/// @brief -/// @param catalog -/// @param dataSz -/// @return +/// ***************************************************************** /// +/// Reading,Seek,Tell are unimplemented on catalogs, refer to forks I/O instead. +/// ***************************************************************** /// + +/// @brief +/// @param catalog +/// @param dataSz +/// @return VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, SizeT dataSz) { return nullptr; } -/// @brief -/// @param catalog -/// @param off -/// @return +/// @brief +/// @param catalog +/// @param off +/// @return bool NewFSParser::Seek(_Input _Output NewCatalog* catalog, SizeT off) { return false; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return SizeT NewFSParser::Tell(_Input _Output NewCatalog* catalog) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_fork(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_data(SizeT sz) { return 0; } namespace NewOS::Detail { Boolean fs_init_newfs(Void) noexcept { return false; } } // namespace NewOS::Detail -#endif // ifdef __FSKIT_NEWFS__
\ No newline at end of file +#endif // ifdef __FSKIT_NEWFS__ |
