diff options
| author | Amlal <amlal@nekernel.org> | 2025-05-01 08:30:58 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-05-01 08:30:58 +0200 |
| commit | 72fa8a81498a53491950f92d9e96fbe6dd65cc04 (patch) | |
| tree | 5d3e67a39d0864892a058634b7073797df615dff | |
| parent | fcea594f2df75dcd0f3d4bfeac988b748be89c13 (diff) | |
dev, kernel: HeFS spec and tooling, and PEF spec updates.
Signed-off-by: Amlal <amlal@nekernel.org>
| -rw-r--r-- | dev/kernel/FSKit/HeFS.h | 6 | ||||
| -rw-r--r-- | dev/kernel/KernelKit/PEF.h | 8 | ||||
| -rw-r--r-- | dev/kernel/src/FS/HeFS.cc | 8 | ||||
| -rw-r--r-- | docs/tex/hefs.tex | 8 | ||||
| -rw-r--r-- | tooling/hefs.h | 51 | ||||
| -rw-r--r-- | tooling/mkfs.hefs.cc | 1 |
6 files changed, 19 insertions, 63 deletions
diff --git a/dev/kernel/FSKit/HeFS.h b/dev/kernel/FSKit/HeFS.h index 80ef6646..da5da3c1 100644 --- a/dev/kernel/FSKit/HeFS.h +++ b/dev/kernel/FSKit/HeFS.h @@ -83,7 +83,7 @@ inline constexpr UInt16 kHeFSFileKindCount = 0x08; /// @brief HeFS blocks are array containing sparse blocks of data.
/// @details The blocks are used to store the data of a file. Each block is a pointer to a block of
/// data on the disk.
-inline constexpr UInt16 kHeFSBlockCount = 0x10;
+inline constexpr UInt16 kHeFSSliceCount = 0x10;
inline constexpr UInt16 kHeFSInvalidVID = 0xFFFF;
@@ -146,7 +146,7 @@ struct PACKED HEFS_INDEX_NODE final { Kernel::UInt32 fUID, fGID; /// @brief User ID and Group ID of the file.
Kernel::UInt32 fMode; /// @brief File mode. (read, write, execute, etc).
- Kernel::UInt64 fBlock[kHeFSBlockCount]; /// @brief block slice.
+ Kernel::UInt64 fBlock[kHeFSSliceCount]; /// @brief block slice.
Kernel::Char fPad[69];
};
@@ -180,7 +180,7 @@ struct PACKED HEFS_INDEX_NODE_DIRECTORY final { /// [0] = OFFSET
/// [1] = SIZE
/// @note Thus the += 2 when iterating over them.
- Kernel::UInt64 fIndexNode[kHeFSBlockCount]; /// @brief Start of the index node.
+ Kernel::UInt64 fIndexNode[kHeFSSliceCount]; /// @brief Start of the index node.
Kernel::UInt8 fColor; /// @brief Color of the node. (Red or Black).
Kernel::Lba fNext, fPrev, fChild, fParent; /// @brief Red-black tree pointers.
diff --git a/dev/kernel/KernelKit/PEF.h b/dev/kernel/KernelKit/PEF.h index 4c6ee5ae..03398b48 100644 --- a/dev/kernel/KernelKit/PEF.h +++ b/dev/kernel/KernelKit/PEF.h @@ -23,7 +23,7 @@ #define kPefMagicLen (5) -#define kPefVersion (3) +#define kPefVersion (4) #define kPefNameLen (256U) /* not mandatory, only for non fork based filesystems. */ @@ -59,7 +59,7 @@ enum { }; enum { - kPefSubArchAMD, + kPefSubArchAMD = 200, kPefSubArchIntel, kPefSubArchARM, kPefSubArchGeneric, @@ -67,7 +67,7 @@ enum { }; enum { - kPefKindExec = 1, /* .o */ + kPefKindExec = 1, /* .exec */ kPefKindDylib = 2, /* .dylib */ kPefKindObject = 4, /* .obj */ kPefKindDebug = 5, /* .dbg */ @@ -86,6 +86,7 @@ typedef struct PEFContainer final { UIntPtr Start; SizeT HdrSz; /* Size of header */ SizeT Count; /* container header count */ + UInt32 Checksum; } PACKED PEFContainer; /* First PEFCommandHeader starts after PEFContainer */ @@ -97,6 +98,7 @@ typedef struct PEFCommandHeader final { UInt32 Flags; /* container flags */ UInt16 Kind; /* container kind */ UIntPtr Offset; /* content offset */ + UIntPtr VMAddress; /* VM offset */ SizeT Size; /* content Size */ } PACKED PEFCommandHeader; diff --git a/dev/kernel/src/FS/HeFS.cc b/dev/kernel/src/FS/HeFS.cc index 605df480..2f5bb55d 100644 --- a/dev/kernel/src/FS/HeFS.cc +++ b/dev/kernel/src/FS/HeFS.cc @@ -204,7 +204,7 @@ namespace Detail { if (dir->fKind == kHeFSFileKindDirectory) { if (KStringBuilder::Equals(dir_name, dir->fName) || KStringBuilder::Equals(dir_name, kHeFSSearchAllStr)) { - for (SizeT inode_index = 0UL; inode_index < kHeFSBlockCount; inode_index += 2) { + for (SizeT inode_index = 0UL; inode_index < kHeFSSliceCount; inode_index += 2) { mnt->fPacket.fPacketLba = dir->fIndexNode[inode_index]; mnt->fPacket.fPacketSize = sizeof(HEFS_INDEX_NODE); mnt->fPacket.fPacketContent = node; @@ -329,7 +329,7 @@ namespace Detail { if (child > root->fEndIND) dirent->fChild = root->fEndIND; } - for (SizeT index = 0UL; index < (kHeFSBlockCount * 2); index += 2) { + for (SizeT index = 0UL; index < (kHeFSSliceCount * 2); index += 2) { dirent->fIndexNode[index] = root->fStartIN; dirent->fIndexNode[index + 1] = 0UL; } @@ -459,7 +459,7 @@ namespace Detail { dir->fChecksum) ke_panic(RUNTIME_CHECK_FILESYSTEM, "CRC32 failure on HeFS IND!"); - for (SizeT inode_index = 0UL; inode_index < (kHeFSBlockCount * 2); inode_index += 2) { + for (SizeT inode_index = 0UL; inode_index < (kHeFSSliceCount * 2); inode_index += 2) { if (dir->fIndexNode[inode_index] != 0) { mnt->fPacket.fPacketLba = dir->fIndexNode[inode_index]; mnt->fPacket.fPacketSize = sizeof(HEFS_INDEX_NODE); @@ -527,7 +527,7 @@ namespace Detail { mnt->fInput(mnt->fPacket); if (KStringBuilder::Equals(dir->fName, parent_dir_name)) { - for (SizeT inode_index = 0UL; inode_index < (kHeFSBlockCount * 2); inode_index += 2) { + for (SizeT inode_index = 0UL; inode_index < (kHeFSSliceCount * 2); inode_index += 2) { if (dir->fIndexNode[inode_index] != 0) { auto lba = dir->fIndexNode[inode_index]; diff --git a/docs/tex/hefs.tex b/docs/tex/hefs.tex index a88b2270..25b57f56 100644 --- a/docs/tex/hefs.tex +++ b/docs/tex/hefs.tex @@ -83,7 +83,7 @@ HeFS is a custom filesystem developed as part of the NeKernel project. It offers \end{itemize} \section{Index Node Structure} -Files are stored through block links, offering native recovery fields and MIME type support. +Files are stored through slice links, offering native recovery fields and MIME type support. \begin{lstlisting}[style=cstyle, caption={HEFS\_INDEX\_NODE structure}] struct HEFS_INDEX_NODE { @@ -128,9 +128,9 @@ struct HEFS_INDEX_NODE_DIRECTORY { HeFS is designed with the following objectives: \begin{itemize} \item Red-black tree navigation for efficient directory balancing - \item Journaling fields for block-level recovery + \item Journaling fields for slice-level recovery \item Multi-encoding support: UTF-8, UTF-16, UTF-32 - \item Advanced MIME type support + \item Advanced MIME type support (Feature has been scrapped) \item Redundant fields (checksums, recovery inodes) for crash resistance \item Extensible for future LVM (Logical Volume Management) and network filesystem support \end{itemize} @@ -146,7 +146,7 @@ Planned enhancements include: \item Full journaling implementation (recovery on crash) \item Advanced ACLs (Access Control Lists) and permissions \item Logical Volume Management (LVM) integration - \item Backup Superblock and dual-boot sectors + \item Backup boot node and dual-boot sectors \item Online filesystem checking and self-healing algorithms \end{itemize} diff --git a/tooling/hefs.h b/tooling/hefs.h index 2a04a1c3..52c951ef 100644 --- a/tooling/hefs.h +++ b/tooling/hefs.h @@ -56,9 +56,6 @@ enum { kHeFSEncodingCount, }; -// Block constants -constexpr std::size_t kHeFSBlockCount = 16; - // Time type using ATime = std::uint64_t; @@ -103,54 +100,10 @@ struct alignas(8) BootNode { std::uint16_t diskStatus{}; std::uint16_t diskFlags{}; std::uint16_t vid{}; - std::uint64_t reserved{}; - std::uint64_t reserved2{}; + std::uint64_t startIN{}; + std::uint64_t endIN{}; std::uint64_t reserved3{}; std::uint64_t reserved4{}; char pad[272]{}; }; - -// Index Node -struct alignas(8) IndexNode { - char8_t name[kHeFSFileNameLen]{}; - std::uint32_t flags{}; - std::uint16_t kind{}; - std::uint32_t size{}; - std::uint32_t checksum{}; - bool symbolicLink{false}; - ATime created{}; - ATime accessed{}; - ATime modified{}; - ATime deleted{}; - std::uint32_t uid{}; - std::uint32_t gid{}; - std::uint32_t mode{}; - std::uint64_t block[kHeFSBlockCount]{}; - char pad[62]{}; -}; - -// Index Node Directory (Red-Black Tree Node) -struct alignas(8) IndexNodeDirectory { - char8_t name[kHeFSFileNameLen]{}; - std::uint32_t flags{}; - std::uint16_t kind{}; - std::uint32_t entryCount{}; - std::uint32_t checksum{}; - std::uint32_t indexNodeChecksum{}; - ATime created{}; - ATime accessed{}; - ATime modified{}; - ATime deleted{}; - std::uint32_t uid{}; - std::uint32_t gid{}; - std::uint32_t mode{}; - std::uint64_t indexNode[kHeFSBlockCount]{}; - std::uint8_t color{}; - std::uint64_t next{}; - std::uint64_t prev{}; - std::uint64_t child{}; - std::uint64_t parent{}; - char pad[32]{}; -}; - } // namespace mkfs::hefs diff --git a/tooling/mkfs.hefs.cc b/tooling/mkfs.hefs.cc index 356504f9..4d7225fe 100644 --- a/tooling/mkfs.hefs.cc +++ b/tooling/mkfs.hefs.cc @@ -96,6 +96,7 @@ int main(int argc, char** argv) { bootNode.sectorSize = kSectorSize; bootNode.startIND = start_ind; bootNode.endIND = end_ind; + bootNode.indCount = 0UL; bootNode.diskStatus = mkfs::hefs::kHeFSStatusUnlocked; std::memcpy(bootNode.magic, kHeFSMagic, kHeFSMagicLen - 1); |
