From dc2b2cdf68efb7320d51cb4241f4878ceafb04da Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 7 Mar 2025 12:30:08 +0100 Subject: Replace endl with kendl, and add make_fs; a tool to format a filesystem under the EPM. -> EPM + NeFS, HPFS, ext? Signed-off-by: Amlal El Mahrouss --- public/tools/make_fs/make_fs.cc | 31 +++++++++++++++++++++++++++++++ public/tools/make_fs/make_fs.json | 5 +++-- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'public/tools') diff --git a/public/tools/make_fs/make_fs.cc b/public/tools/make_fs/make_fs.cc index e114113b..f75527b1 100644 --- a/public/tools/make_fs/make_fs.cc +++ b/public/tools/make_fs/make_fs.cc @@ -7,10 +7,41 @@ ------------------------------------------- */ +#include +#include +#include #include +#include +static const char* kDiskName = "Disk"; +static const int kDiskSectorSz = 512; +static const int kDiskBlockCnt = 1; + +/// @brief Filesystem tool entrypoint. int main(int argc, char** argv) { + std::cout << "make_fs: EPM image creator.\n"; + struct EPM_PART_BLOCK block{0}; + + block.NumBlocks = kDiskBlockCnt; + block.SectorSz = kDiskSectorSz; + block.Version = kEPMRevisionBcd; + block.LbaStart = sizeof(struct EPM_PART_BLOCK); + block.LbaEnd = 0; + block.FsVersion = kNeFSVersionInteger; + + ::memcpy(block.Name, kDiskName, strlen(kDiskName)); + ::memcpy(block.Magic, kEPMMagic86, strlen(kEPMMagic86)); + + uuid_generate_random((NeOS::UInt8*)&block.Guid); + + std::ofstream output_epm("disk.eimg"); + output_epm.write((NeOS::Char*)&block, sizeof(struct EPM_PART_BLOCK)); + + output_epm.close(); + + std::cout << "make_fs: EPM image has been written to disk.eimg.\n"; + return 0; } \ No newline at end of file diff --git a/public/tools/make_fs/make_fs.json b/public/tools/make_fs/make_fs.json index 8134bab3..13c66dbb 100644 --- a/public/tools/make_fs/make_fs.json +++ b/public/tools/make_fs/make_fs.json @@ -1,12 +1,13 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./"], + "headers_path": ["./", "../../../dev/Kernel", "../../../dev/"], "sources_path": ["make_fs.cc"], "output_name": "./dist/make_fs", "cpp_macros": [ "kMKFSVersion=0x0100", "kMKFSVersionHighest=0x0100", - "kMKFSVersionLowest=0x0100" + "kMKFSVersionLowest=0x0100", + "__NE_SDK__" ] } -- cgit v1.2.3