summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-23 02:41:00 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-23 02:41:00 -0500
commit35a6a5c870164947ce4e865b30e8b93f320d0ab5 (patch)
tree6dc372290330fdba430b9821c327de9aba5d9de7
parentc0788e4d6ae801f13f242b252ea9d0084c30c04a (diff)
feat: libsteps: error handling and parsing functions/operators.
feat: mimick nekernel filesystem tree in repository as well. feat: update modules as well. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--README.md10
-rw-r--r--boot/.keep0
m---------dev/nekernel0
-rw-r--r--devices/.keep0
m---------lib/libocl0
-rw-r--r--lib/libsteps/dev/lib/steps.hpp23
-rw-r--r--media/.keep0
-rw-r--r--network/.keep0
-rw-r--r--system/.keep0
-rw-r--r--tools/steps.cc17
10 files changed, 39 insertions, 11 deletions
diff --git a/README.md b/README.md
index 41e933d..947a4fd 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,17 @@
<img src="./meta/readme-logo.png"/>
-This repository was made to put the NeKernel components together. Acting as the software distribution for NeKernel.
+The system repository was developed to hold the NeKernel components together. Acting as the software distribution for NeKernel.
-## Why?
+## Purpose
+
+The purpose is the following:
- Hold the codebase in a single repository, it is way more maintable than a fragmented one.
- Easier paths based on the `system` path, i.e (../nekernel -> /system/dev/nekernel)
- One system release is easier than releasing each component on its own.
+## Note:
+
+- `dev` stands for develop, not the device directory.
+
###### Copyright 2025 - Amlal El Mahrouss & NeKernel.org Contributors. Licensed under Apache 2.0.
diff --git a/boot/.keep b/boot/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/boot/.keep
diff --git a/dev/nekernel b/dev/nekernel
-Subproject e3fa27827e7647a0ecc466f4d92097fe48fbbb4
+Subproject e5cc7351f0577b54c528fb827a7c7e6306c3e84
diff --git a/devices/.keep b/devices/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/devices/.keep
diff --git a/lib/libocl b/lib/libocl
-Subproject 8470a48ef4c6ea4b16e9a764aaedc7158f9c37e
+Subproject 9a70f32ddaec0eef99efbf7ff5597c2adf08f45
diff --git a/lib/libsteps/dev/lib/steps.hpp b/lib/libsteps/dev/lib/steps.hpp
index d160506..ce6be51 100644
--- a/lib/libsteps/dev/lib/steps.hpp
+++ b/lib/libsteps/dev/lib/steps.hpp
@@ -6,8 +6,9 @@ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
#pragma once
-#include <libsteps/dev/lib/defines.hpp>
#include <cstring>
+#include <fstream>
+#include <libsteps/dev/lib/defines.hpp>
#define kStepsExtension ".stp"
#define kStepsStrLen (256U)
@@ -16,8 +17,8 @@ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
#define kStepsMagicLen (4U)
#define kStepsVersion (0x0100)
-namespace steps {
-struct record final {
+namespace ocl::steps {
+struct __attribute__((packed)) record final {
ocl::char_type magic[kStepsMagicLen] = {kStepsMagic[0], kStepsMagic[1],
kStepsMagic[2], kStepsMagic[3]};
ocl::char_type name[kStepsStrLen] = "";
@@ -28,7 +29,21 @@ struct record final {
int32_t check_page = 0, eula_page = 0;
};
+inline bool is_valid(record& r) noexcept {
+ return r.pages > 1 && r.version > 0 && strcmp(r.magic, kStepsMagic) == 0;
+}
+
namespace operators {
+inline std::ifstream &operator>>(std::ifstream &f, record &r) {
+ f.read((char *)&r, sizeof(r));
+ return f;
+}
+
+inline std::ofstream &operator<<(std::ofstream &f, record &r) {
+ f.write((char *)&r, sizeof(r));
+ return f;
+}
+
/// =========================================================== ///
/// @brief Equal operator for steps records.
/// =========================================================== ///
@@ -43,4 +58,4 @@ inline bool operator!=(const record &r, const record &l) {
return (std::strncmp(r.magic, l.magic, kStepsMagicLen) > 0);
}
} // namespace operators
-} // namespace steps
+} // namespace ocl::steps
diff --git a/media/.keep b/media/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/media/.keep
diff --git a/network/.keep b/network/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/network/.keep
diff --git a/system/.keep b/system/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/system/.keep
diff --git a/tools/steps.cc b/tools/steps.cc
index 3b61ef2..6b9a8f7 100644
--- a/tools/steps.cc
+++ b/tools/steps.cc
@@ -1,8 +1,8 @@
-/* -------------------------------------------
+/* ===========================================================
Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-------------------------------------------- */
+=========================================================== */
#include <libocl/dev/lib/io/print.hpp>
#include <libsteps/dev/lib/steps.hpp>
@@ -10,15 +10,22 @@ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
/// =========================================================== ///
/// Use operators from steps namespace to compare steps records.
/// =========================================================== ///
-using namespace steps::operators;
+using namespace ocl::steps::operators;
+
+const auto kStepsFileRoot = "/system/install.stp";
/// =========================================================== ///
/// @brief Main function for running steps on NeKernel.
/// =========================================================== ///
-int main(int argc, char **argv) {
+int main(void) {
ocl::io::print("steps: running steps for program...\n");
- steps::record steps;
+ std::ifstream file(kStepsFileRoot);
+ ocl::steps::record steps;
+
+ file >> steps;
+
+ if (!ocl::steps::is_valid(steps)) return EXIT_FAILURE;
/// AMLALE: Read steps from file and process them.