summaryrefslogtreecommitdiffhomepage
path: root/public/tools
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-07 12:30:08 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-07 12:30:08 +0100
commitdc2b2cdf68efb7320d51cb4241f4878ceafb04da (patch)
tree7ea9268fb3c54220787ad6c508aaf6e5af386e70 /public/tools
parentac62a264fe08839b46160e8ce218a32012883cd7 (diff)
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 <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'public/tools')
-rw-r--r--public/tools/make_fs/make_fs.cc31
-rw-r--r--public/tools/make_fs/make_fs.json5
2 files changed, 34 insertions, 2 deletions
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 <iostream>
+#include <fstream>
+#include <FirmwareKit/EPM.h>
#include <FSKit/NeFS.h>
+#include <uuid/uuid.h>
+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__"
]
}