summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 14:42:03 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-05 14:42:03 +0200
commit432e68391357423914547a7b34311258d7598808 (patch)
treec2f7eeb45f99b910122257d1a9c2bcfcda4bddb3 /dev/ZKA
parent3e2b931d65582284e9716c42a902cab6d279c7f0 (diff)
[ FIX ] Fixing shortcomings of scheduler, filesystem and kernel.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA')
-rw-r--r--dev/ZKA/Docs/SPECIFICATION.md2
-rw-r--r--dev/ZKA/FSKit/NeFS.hxx (renamed from dev/ZKA/FSKit/NewFS.hxx)154
-rw-r--r--dev/ZKA/FirmwareKit/EPM.hxx2
-rw-r--r--dev/ZKA/FirmwareKit/Handover.hxx12
-rw-r--r--dev/ZKA/KernelKit/FileMgr.hxx12
-rw-r--r--dev/ZKA/NewKit/Macros.hxx9
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx130
-rw-r--r--dev/ZKA/Sources/FS/NeFS.cxx (renamed from dev/ZKA/Sources/FS/NewFS.cxx)201
-rw-r--r--dev/ZKA/Sources/FileMgr.cxx14
-rw-r--r--dev/ZKA/Sources/NewFS+FileMgr.cxx18
-rw-r--r--dev/ZKA/Sources/NewFS+IO.cxx18
-rw-r--r--dev/ZKA/Sources/NewFS+Journal.cxx4
12 files changed, 314 insertions, 262 deletions
diff --git a/dev/ZKA/Docs/SPECIFICATION.md b/dev/ZKA/Docs/SPECIFICATION.md
index d39a95d3..c38fa122 100644
--- a/dev/ZKA/Docs/SPECIFICATION.md
+++ b/dev/ZKA/Docs/SPECIFICATION.md
@@ -19,7 +19,7 @@
- Separation of Files/Devices.
- Networking.
- Hardware Abstraction Layer.
-- Native Filesystem support (NewFS, FAT32 and ffs2).
+- Native Filesystem support (NeFS, FAT32 and ffs2).
- Program Loaders interfaces.
- TLS (Thread Local Storage) support.
- Semaphore, Locks, Timers.
diff --git a/dev/ZKA/FSKit/NewFS.hxx b/dev/ZKA/FSKit/NeFS.hxx
index 4587b70f..d1c0c9c7 100644
--- a/dev/ZKA/FSKit/NewFS.hxx
+++ b/dev/ZKA/FSKit/NeFS.hxx
@@ -2,14 +2,14 @@
Copyright ZKA Technologies.
- File: NewFS.hxx
- Purpose:
+ FILE: NeFS.hxx
+ PURPOSE: NeFS (New FileSystem) kernel support.
Revision History:
?/?/?: Added file (amlel)
12/02/24: Add UUID macro for EPM and GPT partition schemes.
- 3/16/24: Add mandatory sector size, kNewFSSectorSz is set to 2048 by
+ 3/16/24: Add mandatory sector size, kNeFSSectorSz is set to 2048 by
default.
------------------------------------------- */
@@ -26,68 +26,68 @@ default.
@author Amlal EL Mahrouss
*/
-#define kNewFSInvalidFork (-1)
-#define kNewFSInvalidCatalog (-1)
-#define kNewFSNodeNameLen (256)
+#define kNeFSInvalidFork (-1)
+#define kNeFSInvalidCatalog (-1)
+#define kNeFSNodeNameLen (256)
-#define kNewFSSectorSz (512)
-#define kNewFSForkSz (8192)
+#define kNeFSSectorSz (512)
+#define kNeFSForkDataSz (gib_cast(16))
-#define kNewFSIdentLen (8)
-#define kNewFSIdent " NewFS"
-#define kNewFSPadLen (400)
+#define kNeFSIdentLen (8)
+#define kNeFSIdent " NewFS"
+#define kNeFSPadLen (400)
-#define kNewFSMetaFilePrefix '$'
+#define kNeFSMetaFilePrefix '$'
-#define kNewFSVersionInteger (0x0128)
-#define kNewFSVerionString "1.28"
+#define kNeFSVersionInteger (0x0128)
+#define kNeFSVerionString "1.28"
/// @brief Standard fork types.
-#define kNewFSDataFork "main_data"
-#define kNewFSResourceFork "main_rsrc"
+#define kNeFSDataFork "main_data"
+#define kNeFSResourceFork "main_rsrc"
-#define kNewFSCatalogKindFile (1)
-#define kNewFSCatalogKindDir (2)
-#define kNewFSCatalogKindAlias (3)
+#define kNeFSCatalogKindFile (1)
+#define kNeFSCatalogKindDir (2)
+#define kNeFSCatalogKindAlias (3)
-#define kNewFSForkSize (512)
+#define kNeFSForkSize (512)
//! shared between network or
//! other filesystems. Export forks as .zip when copying.
-#define kNewFSCatalogKindShared (4)
+#define kNeFSCatalogKindShared (4)
-#define kNewFSCatalogKindResource (5)
-#define kNewFSCatalogKindExecutable (6)
+#define kNeFSCatalogKindResource (5)
+#define kNeFSCatalogKindExecutable (6)
-#define kNewFSCatalogKindPage (8)
+#define kNeFSCatalogKindPage (8)
-#define kNewFSPartitionTypeStandard (7)
-#define kNewFSPartitionTypePage (8)
-#define kNewFSPartitionTypeBoot (9)
+#define kNeFSPartitionTypeStandard (7)
+#define kNeFSPartitionTypePage (8)
+#define kNeFSPartitionTypeBoot (9)
-#define kNewFSCatalogKindDevice (9)
-#define kNewFSCatalogKindLock (10)
+#define kNeFSCatalogKindDevice (9)
+#define kNeFSCatalogKindLock (10)
-#define kNewFSCatalogKindRLE (11)
+#define kNeFSCatalogKindRLE (11)
-#define kNewFSCatalogKindMetaFile (12)
+#define kNeFSCatalogKindMetaFile (12)
-#define kNewFSSeparator '\\'
-#define kNewFSSeparatorAlt '/'
+#define kNeFSSeparator '\\'
+#define kNeFSSeparatorAlt '/'
-#define kNewFSUpDir ".."
-#define kNewFSRoot "\\"
-#define kNewFSRootAlt "/"
+#define kNeFSUpDir ".."
+#define kNeFSRoot "\\"
+#define kNeFSRootAlt "/"
-#define kNewFSLF '\r'
-#define kNewFSEOF (-1)
+#define kNeFSLF '\r'
+#define kNeFSEOF (-1)
-#define kNewFSBitWidth (sizeof(Kernel::Char))
-#define kNewFSLbaType (Kernel::Lba)
+#define kNeFSBitWidth (sizeof(Kernel::Char))
+#define kNeFSLbaType (Kernel::Lba)
/// Start After the PM headers, pad 1024 bytes.
-#define kNewFSRootCatalogStartAddress (1024)
-#define kNewFSCatalogStartAddress ((2048) + sizeof(NFS_ROOT_PARTITION_BLOCK))
+#define kNeFSRootCatalogStartAddress (1024)
+#define kNeFSCatalogStartAddress ((2048) + sizeof(NFS_ROOT_PARTITION_BLOCK))
#define kResourceTypeDialog (10)
#define kResourceTypeString (11)
@@ -96,13 +96,13 @@ default.
#define kConfigLen (64)
#define kPartLen (32)
-#define kNewFSFlagDeleted (70)
-#define kNewFSFlagUnallocated (0)
-#define kNewFSFlagCreated (71)
+#define kNeFSFlagDeleted (70)
+#define kNeFSFlagUnallocated (0)
+#define kNeFSFlagCreated (71)
-#define kNewFSMimeNameLen (200)
+#define kNeFSMimeNameLen (200)
-#define kNewFSForkNameLen (200U)
+#define kNeFSForkNameLen (200U)
struct NFS_CATALOG_STRUCT;
struct NFS_FORK_STRUCT;
@@ -110,21 +110,21 @@ struct NFS_ROOT_PARTITION_BLOCK;
enum
{
- kNewFSHardDrive = 0xC0, // Hard Drive
- kNewFSSolidStateDrive = 0xC1, // Solid State Drive
- kNewFSOpticalDrive = 0x0C, // Blu-Ray/DVD
- kNewFSMassStorageDevice = 0xCC, // USB
- kNewFSScsi = 0xC4, // SCSI Hard Drive
- kNewFSFlashDrive = 0xC6,
- kNewFSUnknown = 0xFF, // Unknown device.
- kNewFSDriveCount = 7,
+ kNeFSHardDrive = 0xC0, // Hard Drive
+ kNeFSSolidStateDrive = 0xC1, // Solid State Drive
+ kNeFSOpticalDrive = 0x0C, // Blu-Ray/DVD
+ kNeFSMassStorageDevice = 0xCC, // USB
+ kNeFSScsi = 0xC4, // SCSI Hard Drive
+ kNeFSFlashDrive = 0xC6,
+ kNeFSUnknown = 0xFF, // Unknown device.
+ kNeFSDriveCount = 7,
};
/// @brief Catalog type.
struct PACKED NFS_CATALOG_STRUCT final
{
- Kernel::Char Name[kNewFSNodeNameLen];
- Kernel::Char Mime[kNewFSMimeNameLen];
+ Kernel::Char Name[kNeFSNodeNameLen];
+ Kernel::Char Mime[kNeFSMimeNameLen];
/// Catalog status flag.
Kernel::UInt16 Flags;
@@ -152,8 +152,8 @@ struct PACKED NFS_CATALOG_STRUCT final
/// whereas the data fork is reserved for file data.
struct PACKED NFS_FORK_STRUCT final
{
- Kernel::Char ForkName[kNewFSForkNameLen];
- Kernel::Char CatalogName[kNewFSNodeNameLen];
+ Kernel::Char ForkName[kNeFSForkNameLen];
+ Kernel::Char CatalogName[kNeFSNodeNameLen];
Kernel::Int32 Flags;
Kernel::Int32 Kind;
@@ -172,7 +172,7 @@ struct PACKED NFS_FORK_STRUCT final
/// @brief Partition block type
struct PACKED NFS_ROOT_PARTITION_BLOCK final
{
- Kernel::Char Ident[kNewFSIdentLen];
+ Kernel::Char Ident[kNeFSIdentLen];
Kernel::Char PartitionName[kPartLen];
Kernel::Int32 Flags;
@@ -193,41 +193,41 @@ struct PACKED NFS_ROOT_PARTITION_BLOCK final
Kernel::Lba EpmBlock;
- Kernel::Char Pad[kNewFSPadLen - sizeof(Kernel::Lba)];
+ Kernel::Char Pad[kNeFSPadLen - sizeof(Kernel::Lba)];
};
namespace Kernel
{
enum
{
- kNewFSSubDriveA,
- kNewFSSubDriveB,
- kNewFSSubDriveC,
- kNewFSSubDriveD,
- kNewFSSubDriveInvalid,
- kNewFSSubDriveCount,
+ kNeFSSubDriveA,
+ kNeFSSubDriveB,
+ kNeFSSubDriveC,
+ kNeFSSubDriveD,
+ kNeFSSubDriveInvalid,
+ kNeFSSubDriveCount,
};
/// \brief Resource fork kind.
enum
{
- kNewFSRsrcForkKind = 0,
- kNewFSDataForkKind = 1
+ kNeFSRsrcForkKind = 0,
+ kNeFSDataForkKind = 1
};
///
- /// \name NewFSParser
- /// \brief NewFS parser class. (catalog creation, remove removal, root,
+ /// \name NeFSParser
+ /// \brief NeFS parser class. (catalog creation, remove removal, root,
/// forks...) Designed like the DOM, detects the filesystem automatically.
///
- class NewFSParser final
+ class NeFSParser final
{
public:
- explicit NewFSParser() = default;
- ~NewFSParser() = default;
+ explicit NeFSParser() = default;
+ ~NeFSParser() = default;
public:
- ZKA_COPY_DEFAULT(NewFSParser);
+ ZKA_COPY_DEFAULT(NeFSParser);
public:
/// @brief Creates a new fork inside the New filesystem partition.
@@ -278,13 +278,13 @@ namespace Kernel
bool CloseCatalog(_InOut NFS_CATALOG_STRUCT* catalog);
- /// @brief Make a EPM+NewFS drive out of the disk.
+ /// @brief Make a EPM+NeFS drive out of the disk.
/// @param drive The drive to write on.
/// @return If it was sucessful, see ErrLocal().
bool Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name);
public:
- Int32 fDriveIndex{kNewFSSubDriveA};
+ Int32 fDriveIndex{kNeFSSubDriveA};
};
///
diff --git a/dev/ZKA/FirmwareKit/EPM.hxx b/dev/ZKA/FirmwareKit/EPM.hxx
index 0de288be..18f8558d 100644
--- a/dev/ZKA/FirmwareKit/EPM.hxx
+++ b/dev/ZKA/FirmwareKit/EPM.hxx
@@ -102,7 +102,7 @@ struct PACKED _BOOT_BLOCK_STRUCT
Kernel::Int64 LbaEnd; // addition of lba_start to get the end of partition.
Kernel::Int16 Kind;
Kernel::Int32 FsVersion;
- Kernel::Char Fs[kEPMFilesystemLength]; /* NewFS, ffs2... */
+ Kernel::Char Fs[kEPMFilesystemLength]; /* NeFS, ffs2... */
Kernel::Char Reserved[401]; // to fill a full sector.
};
diff --git a/dev/ZKA/FirmwareKit/Handover.hxx b/dev/ZKA/FirmwareKit/Handover.hxx
index 80d68afa..b4558560 100644
--- a/dev/ZKA/FirmwareKit/Handover.hxx
+++ b/dev/ZKA/FirmwareKit/Handover.hxx
@@ -24,13 +24,7 @@
#define kHandoverMagic 0xBADCC
#define kHandoverVersion 0x114
-#define kHandoverMaxCmdLine 8
-
-#define kHandoverBetterEFI "ZKA_EFI"
-#define kHandoverBetterEFI_U L"ZKA_EFI"
-
-#define kHandoverHeapSz gib_cast(2)
-
+#define kHandoverHeapSz gib_cast(3)
#define kHandoverStructSz sizeof(HEL::HandoverInformationHeader)
namespace Kernel::HEL
@@ -67,9 +61,13 @@ namespace Kernel::HEL
VoidPtr f_PhysicalStart;
VoidPtr f_KernelImage;
+ SizeT f_KernelSz;
VoidPtr f_StartupChime;
+ SizeT f_ChimeSz;
VoidPtr f_StartupImage;
+ SizeT f_StartupSz;
VoidPtr f_TTFallbackFont;
+ SizeT f_FontSz;
WideChar f_FirmwareVendorName[32];
SizeT f_FirmwareVendorLen;
diff --git a/dev/ZKA/KernelKit/FileMgr.hxx b/dev/ZKA/KernelKit/FileMgr.hxx
index 86c40b69..a46216db 100644
--- a/dev/ZKA/KernelKit/FileMgr.hxx
+++ b/dev/ZKA/KernelKit/FileMgr.hxx
@@ -12,7 +12,7 @@
Revision History:
31/01/24: Update documentation (amlel)
- 05/07/24: NewFS support, and fork support, updated constants and specs
+ 05/07/24: NeFS support, and fork support, updated constants and specs
as well.
------------------------------------------- */
@@ -20,7 +20,7 @@
#pragma once
#ifdef __FSKIT_USE_NEWFS__
-#include <FSKit/NewFS.hxx>
+#include <FSKit/NeFS.hxx>
#endif // __FSKIT_USE_NEWFS__
#include <CompilerKit/CompilerKit.hxx>
@@ -137,7 +137,7 @@ namespace Kernel
#ifdef __FSKIT_USE_NEWFS__
/**
- * @brief Based of FilesystemMgrInterface, takes care of managing NewFS
+ * @brief Based of FilesystemMgrInterface, takes care of managing NeFS
* disks.
*/
class NewFilesystemMgr final : public FilesystemMgrInterface
@@ -176,12 +176,12 @@ namespace Kernel
_Input SizeT sz) override;
public:
- /// @brief Get NewFS parser class.
+ /// @brief Get NeFS parser class.
/// @return The filesystem parser class.
- NewFSParser* GetParser() noexcept;
+ NeFSParser* GetParser() noexcept;
private:
- NewFSParser* fImpl{nullptr};
+ NeFSParser* fImpl{nullptr};
};
#endif // ifdef __FSKIT_USE_NEWFS__
diff --git a/dev/ZKA/NewKit/Macros.hxx b/dev/ZKA/NewKit/Macros.hxx
index b9242e79..0de25216 100644
--- a/dev/ZKA/NewKit/Macros.hxx
+++ b/dev/ZKA/NewKit/Macros.hxx
@@ -119,3 +119,12 @@
/// @brief The main system driver.
#define kSysDrv "\\System\\startup.sys"
+
+/// @brief The main font file.
+#define kSysTTF "\\System\\urbanist.ttf"
+
+/// @brief The main kernel file.
+#define kSysChime "\\System\\startup.wav"
+
+/// @brief The main kernel file.
+#define kSysKrnl "\\System\\newoskrnl.exe"
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index db1a80d1..0fa3a181 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -44,7 +44,7 @@ namespace Kernel::Detail
/// @brief Filesystem auto formatter, additional checks are also done by the class.
class FilesystemInstaller final
{
- Kernel::NewFilesystemMgr* fNewFS{nullptr};
+ Kernel::NewFilesystemMgr* fNeFS{nullptr};
public:
/// @brief wizard constructor.
@@ -52,17 +52,17 @@ namespace Kernel::Detail
{
if (Kernel::FilesystemMgrInterface::GetMounted())
{
- CG::CGDrawStringToWnd(cKernelWnd, "NewFS IFS already mounted by HAL (A:)", 10, 10, RGB(0, 0, 0));
- fNewFS = reinterpret_cast<Kernel::NewFilesystemMgr*>(Kernel::FilesystemMgrInterface::GetMounted());
+ CG::CGDrawStringToWnd(cKernelWnd, "NeFS IFS already mounted by HAL (A:)", 10, 10, RGB(0, 0, 0));
+ fNeFS = reinterpret_cast<Kernel::NewFilesystemMgr*>(Kernel::FilesystemMgrInterface::GetMounted());
}
else
{
- // Mounts a NewFS from main drive.
- fNewFS = new Kernel::NewFilesystemMgr();
+ // Mounts a NeFS from main drive.
+ fNeFS = new Kernel::NewFilesystemMgr();
- Kernel::FilesystemMgrInterface::Mount(fNewFS);
+ Kernel::FilesystemMgrInterface::Mount(fNeFS);
- CG::CGDrawStringToWnd(cKernelWnd, "Mounted NewFS IFS (A:)", 10, 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, "Mounted NeFS IFS (A:)", 10, 10, RGB(0, 0, 0));
}
const Kernel::SizeT cDirCount = 7UL;
@@ -71,11 +71,11 @@ namespace Kernel::Detail
"\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\",
"\\Users\\", "\\Library\\", "\\Mount\\"};
- if (fNewFS->GetParser())
+ if (fNeFS->GetParser())
{
for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx)
{
- auto catalogDir = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
+ auto catalogDir = fNeFS->GetParser()->GetCatalog(cDirStr[dirIndx]);
if (catalogDir)
{
@@ -86,8 +86,8 @@ namespace Kernel::Detail
continue;
}
- catalogDir = fNewFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0,
- kNewFSCatalogKindDir);
+ catalogDir = fNeFS->GetParser()->CreateCatalog(cDirStr[dirIndx], 0,
+ kNeFSCatalogKindDir);
CG::CGDrawStringToWnd(cKernelWnd, "Catalog directory has been created: ", 10 + (10 * (dirIndx + 1)), 10, RGB(0, 0, 0));
CG::CGDrawStringToWnd(cKernelWnd, catalogDir->Name, 10 + (10 * (dirIndx + 1)), 10 + (FONT_SIZE_X * rt_string_len("Catalog directory has been created: ")), RGB(0, 0, 0));
@@ -96,44 +96,93 @@ namespace Kernel::Detail
}
}
- NFS_CATALOG_STRUCT* catalogDisk =
- this->fNewFS->GetParser()->GetCatalog(kSysPage);
- const Kernel::Char* cSrcName = "8K_SYS_PAGE_KERNEL";
+ constexpr auto cFileToFormatCnt = 5;
- if (catalogDisk)
+ struct
{
- CG::CGDrawStringToWnd(cKernelWnd, "Catalog swap file already exists: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("Catalog swap file already exists: ")), RGB(0, 0, 0));
+ VoidPtr fBlob;
+ Size fBlobSz;
+ Int32 fFlags;
+ Char fName[kNeFSNodeNameLen];
+ } cFiles[cFileToFormatCnt] = {
+ {
+ .fBlob = kHandoverHeader->f_KernelImage,
+ .fBlobSz = kHandoverHeader->f_KernelSz,
+ .fFlags = kNeFSCatalogKindExecutable,
+ .fName = kSysKrnl,
+ },
+ {
+ .fBlob = kHandoverHeader->f_StartupImage,
+ .fBlobSz = kHandoverHeader->f_StartupSz,
+ .fFlags = kNeFSCatalogKindExecutable,
+ .fName = kSysDrv,
+ },
+ {
+ .fBlob = 0,
+ .fBlobSz = mib_cast(32),
+ .fFlags = kNeFSCatalogKindPage,
+ .fName = kSysPage,
+ },
+ {
+ .fBlob = kHandoverHeader->f_TTFallbackFont,
+ .fBlobSz = kHandoverHeader->f_FontSz,
+ .fFlags = kNeFSCatalogKindResource,
+ .fName = kSysTTF,
+ },
+ {
+ .fBlob = kHandoverHeader->f_StartupChime,
+ .fBlobSz = kHandoverHeader->f_ChimeSz,
+ .fFlags = kNeFSCatalogKindResource,
+ .fName = kSysChime,
+ }
- delete catalogDisk;
- }
- else
+ };
+
+ for (size_t i = 0; i < cFileToFormatCnt; i++)
{
- CG::CGDrawStringToWnd(cKernelWnd, "Catalog swap file created: ", 10 + (10 * (cDirCount + 1)), 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysPage, 10 + (10 * (cDirCount + 1)), 10 + (FONT_SIZE_X * rt_string_len("Catalog swap file created: ")), RGB(0, 0, 0));
+ NFS_CATALOG_STRUCT* catalogDisk =
+ this->fNeFS->GetParser()->GetCatalog(cFiles[i].fName);
+
+ const Kernel::Char* cSrcName = cFiles[i].fName;
- catalogDisk =
- (NFS_CATALOG_STRUCT*)this->Leak()->CreateSwapFile(kSysPage);
+ if (catalogDisk)
+ {
+ CG::CGDrawStringToWnd(cKernelWnd, "File already exists: ", 10 + (10 * (cDirCount + i + 1)), 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, cFiles[i].fName, 10 + (10 * (cDirCount + i+ 1)), 10 + (FONT_SIZE_X * rt_string_len("File already exists: ")), RGB(0, 0, 0));
+
+ delete catalogDisk;
+ }
+ else
+ {
+ CG::CGDrawStringToWnd(cKernelWnd, "File created: ", 10 + (10 * (cDirCount + i+ 1)), 10, RGB(0, 0, 0));
+ CG::CGDrawStringToWnd(cKernelWnd, cFiles[i].fName, 10 + (10 * (cDirCount + i + 1)), 10 + (FONT_SIZE_X * rt_string_len("File created: ")), RGB(0, 0, 0));
+
+ catalogDisk =
+ (NFS_CATALOG_STRUCT*)this->Leak()->CreateSwapFile(cFiles[i].fName);
- NFS_FORK_STRUCT theDiskFork{0};
+ NFS_FORK_STRUCT theDiskFork{0};
- Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theDiskFork.ForkName,
- Kernel::rt_string_len(cSrcName));
+ Kernel::rt_copy_memory((Kernel::VoidPtr)(cSrcName), theDiskFork.ForkName,
+ Kernel::rt_string_len(cSrcName));
- Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDisk->Name),
- theDiskFork.CatalogName,
- Kernel::rt_string_len(catalogDisk->Name));
+ Kernel::rt_copy_memory((Kernel::VoidPtr)(catalogDisk->Name),
+ theDiskFork.CatalogName,
+ Kernel::rt_string_len(catalogDisk->Name));
- Kernel::Size sz_hdr = kNewFSForkSz;
+ theDiskFork.DataSize = cFiles[i].fBlobSz;
+ theDiskFork.ResourceId = cFiles[i].fFlags;
+ theDiskFork.ResourceKind = Kernel::kNeFSDataForkKind;
+ theDiskFork.Kind = Kernel::kNeFSDataForkKind;
- theDiskFork.DataSize = sz_hdr;
- theDiskFork.ResourceId = kNewFSCatalogKindExecutable | kNewFSCatalogKindPage;
- theDiskFork.ResourceKind = Kernel::kNewFSDataForkKind;
- theDiskFork.Kind = Kernel::kNewFSDataForkKind;
+ fNeFS->GetParser()->CreateFork(catalogDisk, theDiskFork);
- fNewFS->GetParser()->CreateFork(catalogDisk, theDiskFork);
+ if (theDiskFork.ResourceId != kNeFSCatalogKindPage)
+ {
+ fNeFS->GetParser()->WriteCatalog(catalogDisk, false, cFiles[i].fBlob, cFiles[i].fBlobSz, theDiskFork.ForkName);
+ }
- delete catalogDisk;
+ delete catalogDisk;
+ }
}
}
@@ -141,11 +190,11 @@ namespace Kernel::Detail
ZKA_COPY_DEFAULT(FilesystemInstaller);
- /// @brief Grab the disk's NewFS reference.
+ /// @brief Grab the disk's NeFS reference.
/// @return NewFilesystemMgr the filesystem interface
Kernel::NewFilesystemMgr* Leak()
{
- return fNewFS;
+ return fNeFS;
}
};
} // namespace Kernel::Detail
@@ -154,7 +203,6 @@ EXTERN_C ATTRIBUTE(naked) Kernel::Void HangCPU(Kernel::Void)
{
while (Yes)
{
-
}
}
@@ -190,7 +238,7 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CG::CGDrawStringToWnd(cKernelWnd, "Starting ZKA System...", 20, 10, RGB(0, 0, 0));
Kernel::UserProcessHelper::Init();
-
+
Kernel::sched_execute_thread(HangCPU, "HANG TEST");
while (Yes)
diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NeFS.cxx
index 37b2a44c..5bae8d4a 100644
--- a/dev/ZKA/Sources/FS/NewFS.cxx
+++ b/dev/ZKA/Sources/FS/NeFS.cxx
@@ -9,7 +9,7 @@
#include <Modules/AHCI/AHCI.hxx>
#include <Modules/ATA/ATA.hxx>
#include <Modules/Flash/Flash.hxx>
-#include <FSKit/NewFS.hxx>
+#include <FSKit/NeFS.hxx>
#include <KernelKit/LPC.hxx>
#include <NewKit/Crc32.hxx>
#include <NewKit/KernelCheck.hxx>
@@ -59,17 +59,18 @@ STATIC MountpointInterface sMountpointInterface;
/// @param theFork the fork itself.
/// @return the fork
/***********************************************************************************/
-_Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
+_Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog,
_Input NFS_FORK_STRUCT& theFork)
{
- if (catalog && theFork.ForkName[0] != 0)
+ if (catalog && theFork.ForkName[0] != 0 &&
+ theFork.DataSize <= kNeFSForkDataSz)
{
- Lba lba = (theFork.Kind == kNewFSDataForkKind) ? catalog->DataFork
+ Lba lba = (theFork.Kind == kNeFSDataForkKind) ? catalog->DataFork
: catalog->ResourceFork;
kcout << "fork lba: " << hex_number(lba) << endl;
- if (lba <= kNewFSCatalogStartAddress)
+ if (lba <= kNeFSCatalogStartAddress)
return nullptr;
auto drv = sMountpointInterface.A();
@@ -85,7 +86,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
/// do not check for anything. Loop until we get what we want, that is a free fork zone.
while (true)
{
- if (lba <= kNewFSCatalogStartAddress)
+ if (lba <= kNeFSCatalogStartAddress)
break;
drv.fPacket.fLba = lba;
@@ -102,7 +103,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
kcout << "next fork: " << hex_number(curFork.NextSibling) << endl;
- if (curFork.Flags == kNewFSFlagCreated)
+ if (curFork.Flags == kNeFSFlagCreated)
{
kcout << "fork already exists.\r";
@@ -122,7 +123,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
{
/// This is a check that we have, in order to link the previous fork
/// entry.
- if (lba >= kNewFSCatalogStartAddress)
+ if (lba >= kNeFSCatalogStartAddress)
{
drv.fPacket.fLba = lbaOfPreviousFork;
drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -141,7 +142,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
constexpr auto cForkPadding =
4; /// this value gives us space for the data offset.
- theFork.Flags = kNewFSFlagCreated;
+ theFork.Flags = kNeFSFlagCreated;
theFork.DataOffset = lba - sizeof(NFS_FORK_STRUCT) * cForkPadding;
theFork.PreviousSibling = lbaOfPreviousFork;
theFork.NextSibling = theFork.DataOffset - theFork.DataSize;
@@ -170,7 +171,7 @@ _Output NFS_FORK_STRUCT* NewFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* cata
/// @param name the fork name.
/// @return the fork.
/***********************************************************************************/
-_Output NFS_FORK_STRUCT* NewFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
+_Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog,
_Input const Char* name,
Boolean isDataFork)
{
@@ -225,9 +226,9 @@ _Output NFS_FORK_STRUCT* NewFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalo
/// @param name
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name)
+_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name)
{
- return this->CreateCatalog(name, 0, kNewFSCatalogKindFile);
+ return this->CreateCatalog(name, 0, kNeFSCatalogKindFile);
}
/***********************************************************************************/
@@ -237,7 +238,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name)
/// @param kind the catalog kind.
/// @return catalog pointer.
/***********************************************************************************/
-_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
+_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name,
_Input const Int32& flags,
_Input const Int32& kind)
{
@@ -248,12 +249,12 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
kcout << "Checking for extension...\r";
/// a directory should have a slash in the end.
- if (kind == kNewFSCatalogKindDir &&
+ if (kind == kNeFSCatalogKindDir &&
name[rt_string_len(name) - 1] != NewFilesystemHelper::Separator())
return nullptr;
/// a file shouldn't have a slash in the end.
- if (kind != kNewFSCatalogKindDir &&
+ if (kind != kNeFSCatalogKindDir &&
name[rt_string_len(name) - 1] == NewFilesystemHelper::Separator())
return nullptr;
@@ -267,7 +268,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
return catalog_copy;
}
- Char parentName[kNewFSNodeNameLen] = {0};
+ Char parentName[kNeFSNodeNameLen] = {0};
for (SizeT indexName = 0UL; indexName < rt_string_len(name); ++indexName)
{
@@ -306,7 +307,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
auto drive = sMountpointInterface.A();
- if (catalog && catalog->Kind == kNewFSCatalogKindFile)
+ if (catalog && catalog->Kind == kNeFSCatalogKindFile)
{
kcout << "Parent name is file.\r";
delete catalog;
@@ -314,21 +315,21 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
}
else if (!catalog)
{
- Char sectorBufPartBlock[kNewFSSectorSz] = {0};
+ Char sectorBufPartBlock[kNeFSSectorSz] = {0};
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)sectorBufPartBlock;
out_lba = partBlock->StartCatalog;
}
- constexpr SizeT cDefaultForkSize = kNewFSForkSize;
+ constexpr SizeT cDefaultForkSize = kNeFSForkSize;
NFS_CATALOG_STRUCT* catalogChild = new NFS_CATALOG_STRUCT();
@@ -340,12 +341,12 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
catalogChild->NextSibling = out_lba;
catalogChild->PrevSibling = out_lba;
catalogChild->Kind = kind;
- catalogChild->Flags = kNewFSFlagCreated | flagsList;
+ catalogChild->Flags = kNeFSFlagCreated | flagsList;
rt_copy_memory((VoidPtr)name, (VoidPtr)catalogChild->Name,
rt_string_len(name));
- UInt16 catalogBuf[kNewFSSectorSz] = {0};
+ UInt16 catalogBuf[kNeFSSectorSz] = {0};
Lba start_free = out_lba;
@@ -353,7 +354,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
rt_string_len("fs/newfs-packet"));
drive.fPacket.fPacketContent = catalogBuf;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
drive.fPacket.fLba = start_free;
drive.fInput(&drive.fPacket);
@@ -371,7 +372,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
{
nextSibling = reinterpret_cast<NFS_CATALOG_STRUCT*>(catalogBuf);
- if (start_free <= kNewFSRootCatalogStartAddress)
+ if (start_free <= kNeFSRootCatalogStartAddress)
{
delete catalogChild;
delete catalog;
@@ -382,17 +383,17 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
// ========================== //
// Allocate catalog now...
// ========================== //
- if ((nextSibling->Flags & kNewFSFlagCreated) == 0)
+ if ((nextSibling->Flags & kNeFSFlagCreated) == 0)
{
- Char sectorBufPartBlock[kNewFSSectorSz] = {0};
+ Char sectorBufPartBlock[kNeFSSectorSz] = {0};
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)sectorBufPartBlock;
@@ -410,7 +411,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
if (!StringBuilder::Equals(parentName, nextSibling->Name))
{
catalogChild->NextSibling =
- start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ start_free + (sizeof(NFS_CATALOG_STRUCT) * cNeFSCatalogPadding);
}
drive.fPacket.fPacketContent = catalogChild;
@@ -419,11 +420,11 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
drive.fOutput(&drive.fPacket);
- // Get NewFS partition's block.
+ // Get NeFS partition's block.
drive.fPacket.fPacketContent = sectorBufPartBlock;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
@@ -441,19 +442,19 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
delete catalog;
return catalogChild;
}
- else if ((nextSibling->Flags & kNewFSFlagCreated) &&
+ else if ((nextSibling->Flags & kNeFSFlagCreated) &&
StringBuilder::Equals(nextSibling->Name, name))
{
return nextSibling;
}
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
//// @note that's how we find the next catalog in the partition block.
- start_free = start_free + (sizeof(NFS_CATALOG_STRUCT) * cNewFSCatalogPadding);
+ start_free = start_free + (sizeof(NFS_CATALOG_STRUCT) * cNeFSCatalogPadding);
drive.fPacket.fPacketContent = catalogBuf;
- drive.fPacket.fPacketSize = kNewFSSectorSz;
+ drive.fPacket.fPacketSize = kNeFSSectorSz;
drive.fPacket.fLba = start_free;
drive.fInput(&drive.fPacket);
@@ -463,10 +464,10 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name,
return nullptr;
}
-/// @brief Make a EPM+NewFS drive out of the disk.
+/// @brief Make a EPM+NeFS drive out of the disk.
/// @param drive The drive to write on.
/// @return If it was sucessful, see ErrLocal().
-bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name)
+bool NeFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name)
{
if (*part_name == 0 ||
endLba == 0)
@@ -485,40 +486,40 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
return false;
}
- Char fs_buf[kNewFSSectorSz] = {0};
+ Char fs_buf[kNeFSSectorSz] = {0};
- Lba start = kNewFSRootCatalogStartAddress;
+ Lba start = kNeFSRootCatalogStartAddress;
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = start;
drive->fInput(&drive->fPacket);
- if (flags & kNewFSPartitionTypeBoot)
+ if (flags & kNeFSPartitionTypeBoot)
{
// make it bootable when needed.
- Char bufEpmHdr[kNewFSSectorSz] = {0};
+ Char bufEpmHdr[kNeFSSectorSz] = {0};
BOOT_BLOCK_STRUCT* epmBoot = (BOOT_BLOCK_STRUCT*)bufEpmHdr;
// EPM header.
- constexpr auto cFsName = "NewFS";
+ constexpr auto cFsName = "NeFS";
constexpr auto cBlockName = "ZKA:";
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cFsName)), epmBoot->Fs, rt_string_len(cFsName));
- epmBoot->FsVersion = kNewFSVersionInteger;
+ epmBoot->FsVersion = kNeFSVersionInteger;
epmBoot->LbaStart = start;
- epmBoot->SectorSz = kNewFSSectorSz;
+ epmBoot->SectorSz = kNeFSSectorSz;
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(cBlockName)), epmBoot->Name, rt_string_len(cBlockName));
rt_copy_memory(reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), epmBoot->Magic, rt_string_len(kEPMMagic));
Lba outEpmLba = kEpmBase;
- Char buf[kNewFSSectorSz];
+ Char buf[kNeFSSectorSz];
Lba prevStart = 0;
SizeT cnt = 0;
@@ -526,7 +527,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
while (drive->fPacket.fPacketGood)
{
drive->fPacket.fPacketContent = buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = outEpmLba;
drive->fInput(&drive->fPacket);
@@ -542,7 +543,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
epmBoot->NumBlocks = cnt;
drive->fPacket.fPacketContent = bufEpmHdr;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = outEpmLba;
drive->fOutput(&drive->fPacket);
@@ -566,16 +567,16 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
// check for an empty partition here.
if (partBlock->PartitionName[0] == 0 &&
- rt_string_cmp(partBlock->Ident, kNewFSIdent, kNewFSIdentLen))
+ rt_string_cmp(partBlock->Ident, kNeFSIdent, kNeFSIdentLen))
{
// partition is free and valid.
- partBlock->Version = kNewFSVersionInteger;
+ partBlock->Version = kNeFSVersionInteger;
const auto cUntitledHD = part_name;
- rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident,
- kNewFSIdentLen);
+ rt_copy_memory((VoidPtr)kNeFSIdent, (VoidPtr)partBlock->Ident,
+ kNeFSIdentLen);
rt_copy_memory((VoidPtr)cUntitledHD, (VoidPtr)partBlock->PartitionName,
rt_string_len(cUntitledHD));
@@ -585,17 +586,17 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
SizeT sectorCount = drv_std_get_sector_count();
SizeT diskSize = drv_std_get_drv_size();
- partBlock->Kind = kNewFSPartitionTypeStandard;
- partBlock->StartCatalog = kNewFSCatalogStartAddress;
- partBlock->Flags = kNewFSPartitionTypeStandard;
+ partBlock->Kind = kNeFSPartitionTypeStandard;
+ partBlock->StartCatalog = kNeFSCatalogStartAddress;
+ partBlock->Flags = kNeFSPartitionTypeStandard;
partBlock->CatalogCount = sectorCount / sizeof(NFS_CATALOG_STRUCT);
partBlock->SectorCount = sectorCount;
partBlock->DiskSize = diskSize;
partBlock->FreeCatalog = sectorCount / sizeof(NFS_CATALOG_STRUCT);
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
- drive->fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
+ drive->fPacket.fLba = kNeFSRootCatalogStartAddress;
drive->fOutput(&drive->fPacket);
@@ -609,7 +610,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
kcout << "sector size: " << hex_number(partBlock->SectorSize) << endl;
// write the root catalog.
- this->CreateCatalog(kNewFSRoot, 0, kNewFSCatalogKindDir);
+ this->CreateCatalog(kNeFSRoot, 0, kNeFSCatalogKindDir);
return true;
}
@@ -619,7 +620,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
start += partBlock->DiskSize;
drive->fPacket.fPacketContent = fs_buf;
- drive->fPacket.fPacketSize = kNewFSSectorSz;
+ drive->fPacket.fPacketSize = kNeFSSectorSz;
drive->fPacket.fLba = start;
drive->fInput(&drive->fPacket);
@@ -632,8 +633,11 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL
/// @param catalog the catalog itself
/// @param data the data.
/// @return if the catalog w rote the contents successfully.
-bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, _Input const Char* forkName)
+bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, _Input const Char* forkName)
{
+ if (sizeOfData > kNeFSForkDataSz)
+ return No;
+
auto drive = sMountpointInterface.A();
rt_copy_memory((VoidPtr) "fs/newfs-packet", drive.fPacket.fPacketMime,
@@ -646,7 +650,7 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
NFS_FORK_STRUCT prevFork{};
// sanity check of the fork position as the condition to run the loop.
- while (startFork >= kNewFSCatalogStartAddress)
+ while (startFork >= kNeFSCatalogStartAddress)
{
drive.fPacket.fPacketContent = forkDataIn;
drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -655,7 +659,7 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
drive.fInput(&drive.fPacket);
// check the fork, if it's position is valid.
- if (forkDataIn->DataOffset <= kNewFSCatalogStartAddress)
+ if (forkDataIn->DataOffset <= kNeFSCatalogStartAddress)
{
ErrLocal() = kErrorDiskIsCorrupted;
@@ -664,29 +668,22 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
return false;
}
- if (forkDataIn->Flags != kNewFSFlagUnallocated &&
- forkDataIn->Flags != kNewFSFlagDeleted &&
+ if (forkDataIn->Flags != kNeFSFlagUnallocated &&
+ forkDataIn->Flags != kNeFSFlagDeleted &&
StringBuilder::Equals(forkDataIn->ForkName, forkName) &&
StringBuilder::Equals(forkDataIn->CatalogName, catalog->Name))
{
// ===================================================== //
- // Store size of blob now.
+ // Store the blob now.
// ===================================================== //
- if (forkDataIn->DataSize < sizeOfData &&
- forkDataIn->DataSize < 1)
- {
- startFork = forkDataIn->NextSibling;
- continue;
- }
-
- forkDataIn->Flags = kNewFSFlagCreated;
- forkDataIn->DataOffset = startFork + sizeof(NFS_FORK_STRUCT);
+ forkDataIn->Flags = kNeFSFlagCreated;
+ forkDataIn->DataOffset = startFork - sizeof(NFS_FORK_STRUCT);
forkDataIn->DataSize = sizeOfData;
drive.fPacket.fPacketContent = data;
drive.fPacket.fPacketSize = sizeOfData;
- drive.fPacket.fLba = startFork + sizeof(NFS_FORK_STRUCT);
+ drive.fPacket.fLba = forkDataIn->DataOffset;
kcout << "data offset: " << hex_number(forkDataIn->DataOffset) << endl;
@@ -718,7 +715,7 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool
/// @brief
/// @param catalogName the catalog name.
/// @return the newly found catalog.
-_Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogName,
+_Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogName,
Lba& out_lba)
{
kcout << "start finding catalog...\r";
@@ -731,7 +728,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
drive.fPacket.fPacketContent = &fs_buf;
drive.fPacket.fPacketSize = sizeof(NFS_ROOT_PARTITION_BLOCK);
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fInput(&drive.fPacket);
@@ -752,7 +749,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
if (!StringBuilder::Equals(catalogName, NewFilesystemHelper::Root()))
{
- Char parentName[kNewFSNodeNameLen] = {0};
+ Char parentName[kNeFSNodeNameLen] = {0};
for (SizeT indexFill = 0; indexFill < rt_string_len(catalogName); ++indexFill)
{
@@ -791,7 +788,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN
kcout << "fetching catalog...\r";
-NewFSSearchThroughCatalogList:
+NeFSSearchThroughCatalogList:
while (drive.fPacket.fPacketGood)
{
drive.fPacket.fLba = startCatalogList;
@@ -805,9 +802,9 @@ NewFSSearchThroughCatalogList:
if (StringBuilder::Equals(catalogName, catalog->Name))
{
/// ignore unallocated catalog, break
- if (!(catalog->Flags & kNewFSFlagCreated))
+ if (!(catalog->Flags & kNeFSFlagCreated))
{
- goto NewFSContinueSearch;
+ goto NeFSContinueSearch;
}
NFS_CATALOG_STRUCT* catalogPtr = new NFS_CATALOG_STRUCT();
@@ -820,10 +817,10 @@ NewFSSearchThroughCatalogList:
return catalogPtr;
}
- NewFSContinueSearch:
+ NeFSContinueSearch:
startCatalogList = catalog->NextSibling;
- if (startCatalogList <= kNewFSRootCatalogStartAddress)
+ if (startCatalogList <= kNeFSRootCatalogStartAddress)
break;
}
@@ -832,7 +829,7 @@ NewFSSearchThroughCatalogList:
localSearchFirst = false;
startCatalogList = cCtartCatalogList;
- goto NewFSSearchThroughCatalogList;
+ goto NeFSSearchThroughCatalogList;
}
out_lba = 0UL;
@@ -842,7 +839,7 @@ NewFSSearchThroughCatalogList:
/// @brief Get catalog from filesystem.
/// @param name the catalog's name/
/// @return
-_Output NFS_CATALOG_STRUCT* NewFSParser::GetCatalog(_Input const Char* name)
+_Output NFS_CATALOG_STRUCT* NeFSParser::GetCatalog(_Input const Char* name)
{
Lba unused = 0;
return this->FindCatalog(name, unused);
@@ -851,7 +848,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::GetCatalog(_Input const Char* name)
/// @brief Closes a catalog, (frees it).
/// @param catalog the catalog to close.
/// @return
-Boolean NewFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
+Boolean NeFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
{
if (!catalog)
return false;
@@ -865,7 +862,7 @@ Boolean NewFSParser::CloseCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog)
/// @brief Mark catalog as removed.
/// @param catalog The catalog structure.
/// @return if the catalog was removed or not.
-Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
+Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName)
{
if (!catalogName ||
StringBuilder::Equals(catalogName, NewFilesystemHelper::Root()))
@@ -877,10 +874,10 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
Lba out_lba = 0;
auto catalog = this->FindCatalog(catalogName, out_lba);
- if (out_lba >= kNewFSCatalogStartAddress ||
- catalog->Flags == kNewFSFlagCreated)
+ if (out_lba >= kNeFSCatalogStartAddress ||
+ catalog->Flags == kNeFSFlagCreated)
{
- catalog->Flags = kNewFSFlagDeleted;
+ catalog->Flags = kNeFSFlagDeleted;
auto drive = sMountpointInterface.A();
@@ -896,7 +893,7 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
Char partitionBlockBuf[sizeof(NFS_ROOT_PARTITION_BLOCK)] = {0};
- drive.fPacket.fLba = kNewFSRootCatalogStartAddress;
+ drive.fPacket.fLba = kNeFSRootCatalogStartAddress;
drive.fPacket.fPacketContent = partitionBlockBuf;
drive.fPacket.fPacketSize = sizeof(NFS_ROOT_PARTITION_BLOCK);
@@ -928,7 +925,7 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
/// @return
/***********************************************************************************/
-VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
+VoidPtr NeFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
_Input Bool isRsrcFork,
_Input SizeT dataSz,
_Input const Char* forkName)
@@ -939,7 +936,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
return nullptr;
}
- constexpr auto cNewFSCatalogPadding = 4;
+ constexpr auto cNeFSCatalogPadding = 4;
Lba dataForkLba = (!isRsrcFork) ? catalog->DataFork : catalog->ResourceFork;
Size dataForkSize = (!isRsrcFork) ? catalog->DataForkSize : catalog->ResourceForkSize;
@@ -955,7 +952,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
NFS_FORK_STRUCT* fs_fork_data = nullptr;
- while (dataForkLba > kNewFSCatalogStartAddress)
+ while (dataForkLba > kNeFSCatalogStartAddress)
{
drive.fPacket.fLba = dataForkLba;
drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT);
@@ -975,7 +972,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
dataForkLba = fs_fork_data->NextSibling;
}
- if (dataForkLba < kNewFSCatalogStartAddress)
+ if (dataForkLba < kNeFSCatalogStartAddress)
{
delete[] fs_buf;
return nullptr;
@@ -991,7 +988,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog,
/// @return if the seeking was successful.
/***********************************************************************************/
-bool NewFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
+bool NeFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
{
if (!catalog)
{
@@ -1009,7 +1006,7 @@ bool NewFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off)
/// @return The position on the file.
/***********************************************************************************/
-SizeT NewFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
+SizeT NeFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
{
if (!catalog)
{
@@ -1024,7 +1021,7 @@ SizeT NewFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog)
namespace Kernel::Detail
{
/***********************************************************************************/
- /// @brief Construct NewFS drives.
+ /// @brief Construct NeFS drives.
/***********************************************************************************/
Boolean fs_init_newfs(Void) noexcept
{
diff --git a/dev/ZKA/Sources/FileMgr.cxx b/dev/ZKA/Sources/FileMgr.cxx
index 270c13f2..cbd2a4f4 100644
--- a/dev/ZKA/Sources/FileMgr.cxx
+++ b/dev/ZKA/Sources/FileMgr.cxx
@@ -80,7 +80,7 @@ namespace Kernel
if (!size)
return;
- constexpr auto cDataForkName = kNewFSDataFork;
+ constexpr auto cDataForkName = kNeFSDataFork;
this->Write(cDataForkName, node, data, flags, size);
}
@@ -96,7 +96,7 @@ namespace Kernel
if (!size)
return nullptr;
- constexpr auto cDataForkName = kNewFSDataFork;
+ constexpr auto cDataForkName = kNeFSDataFork;
return this->Read(cDataForkName, node, flags, size);
}
@@ -107,7 +107,7 @@ namespace Kernel
_Input SizeT size)
{
if (!size ||
- size > kNewFSForkSize)
+ size > kNeFSForkSize)
return;
if (!data)
@@ -115,7 +115,7 @@ namespace Kernel
ZKA_UNUSED(flags);
- if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile)
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
fImpl->WriteCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), data, size,
name);
}
@@ -125,7 +125,7 @@ namespace Kernel
_Input Int32 flags,
_Input SizeT sz)
{
- if (sz > kNewFSForkSize)
+ if (sz > kNeFSForkSize)
return nullptr;
if (!sz)
@@ -133,7 +133,7 @@ namespace Kernel
ZKA_UNUSED(flags);
- if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile)
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
return fImpl->ReadCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), sz,
name);
@@ -182,7 +182,7 @@ namespace Kernel
/// @brief Returns the filesystem parser.
/// @return the Filesystem parser class.
- _Output NewFSParser* NewFilesystemMgr::GetParser() noexcept
+ _Output NeFSParser* NewFilesystemMgr::GetParser() noexcept
{
return fImpl;
}
diff --git a/dev/ZKA/Sources/NewFS+FileMgr.cxx b/dev/ZKA/Sources/NewFS+FileMgr.cxx
index 1ffa774a..29beda45 100644
--- a/dev/ZKA/Sources/NewFS+FileMgr.cxx
+++ b/dev/ZKA/Sources/NewFS+FileMgr.cxx
@@ -9,7 +9,7 @@
#ifdef __FSKIT_USE_NEWFS__
-/// @brief NewFS File manager.
+/// @brief NeFS File manager.
/// BUGS: 0
namespace Kernel
@@ -18,7 +18,7 @@ namespace Kernel
NewFilesystemMgr::NewFilesystemMgr()
{
MUST_PASS(Detail::fs_init_newfs());
- fImpl = new NewFSParser();
+ fImpl = new NeFSParser();
MUST_PASS(fImpl);
kcout << "We are done here... (NewFilesystemMgr).\r";
@@ -58,7 +58,7 @@ namespace Kernel
/// @return The Node pointer.
NodePtr NewFilesystemMgr::CreateDirectory(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindDir));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindDir));
}
/// @brief Creates a node with is a alias.
@@ -66,7 +66,7 @@ namespace Kernel
/// @return The Node pointer.
NodePtr NewFilesystemMgr::CreateAlias(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindAlias));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindAlias));
}
/// @brief Creates a node with is a page file.
@@ -74,35 +74,35 @@ namespace Kernel
/// @return The Node pointer.
NodePtr NewFilesystemMgr::CreateSwapFile(const Char* path)
{
- return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindPage));
+ return node_cast(fImpl->CreateCatalog(path, 0, kNeFSCatalogKindPage));
}
/// @brief Gets the root directory.
/// @return
const Char* NewFilesystemHelper::Root()
{
- return kNewFSRoot;
+ return kNeFSRoot;
}
/// @brief Gets the up-dir directory.
/// @return
const Char* NewFilesystemHelper::UpDir()
{
- return kNewFSUpDir;
+ return kNeFSUpDir;
}
/// @brief Gets the separator character.
/// @return
const Char NewFilesystemHelper::Separator()
{
- return kNewFSSeparator;
+ return kNeFSSeparator;
}
/// @brief Gets the metafile character.
/// @return
const Char NewFilesystemHelper::MetaFile()
{
- return kNewFSMetaFilePrefix;
+ return kNeFSMetaFilePrefix;
}
} // namespace Kernel
diff --git a/dev/ZKA/Sources/NewFS+IO.cxx b/dev/ZKA/Sources/NewFS+IO.cxx
index e1a6ac95..7917c1bb 100644
--- a/dev/ZKA/Sources/NewFS+IO.cxx
+++ b/dev/ZKA/Sources/NewFS+IO.cxx
@@ -9,7 +9,7 @@
/*************************************************************
*
- * File: NewFS+IO.cxx
+ * File: NeFS+IO.cxx
* Purpose: Filesystem to mountpoint interface.
* Date: 3/26/24
*
@@ -42,19 +42,19 @@ Int32 fs_newfs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvInd
switch (DrvIndex)
{
- case kNewFSSubDriveA: {
+ case kNeFSSubDriveA: {
NEWFS_READ(A, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveB: {
+ case kNeFSSubDriveB: {
NEWFS_READ(B, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveC: {
+ case kNeFSSubDriveC: {
NEWFS_READ(C, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveD: {
+ case kNeFSSubDriveD: {
NEWFS_READ(D, DrvTrait.fPacket, Mnt);
break;
}
@@ -77,19 +77,19 @@ Int32 fs_newfs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIn
switch (DrvIndex)
{
- case kNewFSSubDriveA: {
+ case kNeFSSubDriveA: {
NEWFS_WRITE(A, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveB: {
+ case kNeFSSubDriveB: {
NEWFS_WRITE(B, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveC: {
+ case kNeFSSubDriveC: {
NEWFS_WRITE(C, DrvTrait.fPacket, Mnt);
break;
}
- case kNewFSSubDriveD: {
+ case kNeFSSubDriveD: {
NEWFS_WRITE(D, DrvTrait.fPacket, Mnt);
break;
}
diff --git a/dev/ZKA/Sources/NewFS+Journal.cxx b/dev/ZKA/Sources/NewFS+Journal.cxx
index 2f63cc9a..f8d82fcd 100644
--- a/dev/ZKA/Sources/NewFS+Journal.cxx
+++ b/dev/ZKA/Sources/NewFS+Journal.cxx
@@ -10,8 +10,8 @@
#ifdef __FSKIT_USE_NEWFS__
///! BUGS: 0
-///! @file NewFS+Journal.cxx
-///! @brief Journaling for NewFS.
+///! @file NeFS+Journal.cxx
+///! @brief Journaling for NeFS.
namespace Kernel::Journal
{