From 302ee90916fde01771797f52d8a99aee562e4b1e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 16 Mar 2024 16:13:27 +0100 Subject: HCR-14: See below. - Improve HCFS data structures. Will work on a implementation soon. - NewFS to use UTF-8 now, for the sake of the size. Signed-off-by: Amlal El Mahrouss --- Private/FSKit/HCFS.hxx | 49 +++++++++++++++++++++++++++++++++++++++++---- Private/FSKit/NewFS.hxx | 20 +++++++++--------- Private/Tools/make_hcfs.hxx | 14 ------------- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/Private/FSKit/HCFS.hxx b/Private/FSKit/HCFS.hxx index dcbe1a7b..a9d4013d 100644 --- a/Private/FSKit/HCFS.hxx +++ b/Private/FSKit/HCFS.hxx @@ -2,6 +2,8 @@ Copyright Mahrouss Logic + 3/16/24: + ------------------------------------------- */ #pragma once @@ -9,22 +11,42 @@ #include #include +#define kHCFSIdentLen 8 #define kHCFSNameLen 256 +#define kHCFSPadLen 16 + +#define kHCFSGuid "@{0771b3c9-b977-440a-a9ca-396b6d3f07b5}" /// @brief HCFS Balanced Tree structure. /// @author Amlal El Mahrouss typedef struct HCFSBTree final { - HCore::WideChar fCatalogName[kHCFSNameLen]; - - struct { + /// @brief The Catalog Data record. + struct PACKED { HCore::Lba fDataCatalog; HCore::Lba fRsrcCatalog; HCore::SizeT fDataCatalogSize; HCore::SizeT fRsrcCatalogSize; } fCatalogData; + + HCore::Lba fRelatedTrees[12]; + HCore::Char fReserved[384]; } PACKED HCFSBTree; -#define kHCFSGuid "@{0771b3c9-b977-440a-a9ca-396b6d3f07b5}" +typedef struct HCFSCatalog { + HCore::Char fCatalogName[kHCFSNameLen]; + HCore::UInt32 fCatalogKind; + HCore::UInt32 fCatalogFlags; + + /// @brief Tree information structure. + /// 0: BTree LBA. + /// 1: Next BTree LBA. + /// 3: Last BTree LBA. + /// 4: First BTree LBA. + /// Everything else is reserved. + HCore::Lba fTreeInfo[12]; + + HCore::Char fReserved[152]; +} HCFSCatalog; enum { kHCFSHardDrive = 0xC0, // Hard Drive @@ -34,4 +56,23 @@ enum { kHCFSDriveCount = 4, }; +/// @brief This is a boot block, used by HCFS to boot the system (if formated using this filesystem.) +typedef struct HCFSBootBlock final { + HCore::Char Ident[kHCFSIdentLen]; + HCore::Char Shell[kHCFSNameLen]; + + HCore::Int64 NumParts; // number of sub-partitions. + HCore::Int64 FreeSectors; + HCore::Int64 SectorCount; + HCore::Int64 SectorSz; + + HCore::Int64 DiskSize; // size of media. + HCore::Int32 DiskKind; // kind of disk. + + HCore::Lba FirstPartBlock; + HCore::Lba LastPartBlock; + + HCore::Char Pad[kHCFSPadLen]; +} PACKED HCFSBootBlock; + // EOF. diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index db950fb4..e3469e73 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -9,6 +9,7 @@ ?/?/?: Added file (amlel) 12/02/24: Add UUID macro for EPM and GPT partition schemes. + 3/16/24: Add mandatory sector size, kNewFSMinimumSectorSz is set to 2048 by default. ------------------------------------------- */ @@ -27,17 +28,19 @@ #define kNewFSInvalidCatalog -1 #define kNewFSNodeNameLen 256 +#define kNewFSMinimumSectorSz 2048 + #define kNewFSIdentLen 8 #define kNewFSIdent " NEFS" -#define kPadLen 16 +#define kNewFSPadLen 16 //! On EPM and GPT disks. #define kNewFSUUID "@{DD997393-9CCE-4288-A8D5-C0FDE3908DBE}" -#define kNewFSVersionInteger 0x120 -#define kNewFSVerionString "1.2.0" +#define kNewFSVersionInteger 0x121 +#define kNewFSVerionString "1.2.1" -typedef HCore::WideChar NewCharType; +typedef HCore::Char NewCharType; enum { kNewFSHardDrive = 0xC0, // Hard Drive @@ -64,7 +67,7 @@ struct PACKED NewBootBlock final { HCore::Lba FirstPartBlock; HCore::Lba LastPartBlock; - HCore::WideChar Pad[kPadLen]; + NewCharType Pad[kNewFSPadLen]; }; #define kFlagDeleted 0xF0 @@ -136,7 +139,7 @@ struct PACKED NewPartitionBlock final { HCore::SizeT SectorCount; HCore::SizeT SectorSize; - HCore::Char Pad[kPadLen]; + HCore::Char Pad[kNewFSPadLen]; }; #define kCatalogKindFile 1 @@ -160,8 +163,7 @@ struct PACKED NewPartitionBlock final { #define kFilesystemUpDir ".." #define kFilesystemRoot "/" -#define kFilesystemCR '\r' -#define kFilesystemLF '\n' +#define kFilesystemLF '\r' #define kFilesystemEOF (-1) #define kFilesystemBitWidth (sizeof(NewCharType)) @@ -174,7 +176,7 @@ namespace HCore { /// /// \name NewFSParser /// \brief NewFS parser class. (catalog creation, remove removal, root, forks...) -/// Designed like the DOM. +/// Designed like the DOM, detects the filesystem automatically. /// class NewFSParser { diff --git a/Private/Tools/make_hcfs.hxx b/Private/Tools/make_hcfs.hxx index 3db4a764..27a446c2 100644 --- a/Private/Tools/make_hcfs.hxx +++ b/Private/Tools/make_hcfs.hxx @@ -27,17 +27,3 @@ typedef struct __sDISK uintptr_t fDiskCursor; size_t fDiskSize; } DISK, *PDISK; - -#define PACKED __attribute__((packed)) - -typedef struct HCFSBTree final { - wchar_t fCatalogName[255]; - struct { - uint64_t fDataCatalog; - uint64_t fRsrcCatalog; - size_t fDataCatalogSize; - size_t fRsrcCatalogSize; - } fCatalogData; - struct HCFSBTree* fPrevElement; - struct HCFSBTree* fNextElement; -} PACKED HCFSBTree; \ No newline at end of file -- cgit v1.2.3