aboutsummaryrefslogtreecommitdiff
path: root/binaries
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-13 17:43:48 +0530
committerBobby <[email protected]>2026-02-13 17:43:48 +0530
commitc9d03d56bd2fb40a7784c1a0557bf8f1c609a4e5 (patch)
treefc169da8509ccf5b23c0cbd4fa322b565295483e /binaries
parentda6d54db5d741f2db0810cf7afb0b2d5bf0f7113 (diff)
downloadakiba-c9d03d56bd2fb40a7784c1a0557bf8f1c609a4e5.tar.xz
akiba-c9d03d56bd2fb40a7784c1a0557bf8f1c609a4e5.zip
Refactor and enhance filesystem navigation and communication between Katas
- Updated `mi.zig` to default target path to an empty string. - Improved context switching in `context.zig` by restoring registers from the context struct. - Enhanced `loader.zig` to inherit current location from the parent Kata. - Simplified `getkeychar.zig` by removing unnecessary serial import and error handling. - Added new invocations: `getlocation.zig` for retrieving current stack location and `postman.zig` for letter passing between Katas. - Introduced `setlocation.zig` to change current stack location with path resolution. - Created `nav.zig` for navigating the filesystem with commands to print current location or change it. - Added `nav.zon` for binary metadata. - Updated `limits.zig` to define maximum letter length. - Enhanced `ash.zig` to process navigation letters and improved command execution flow. - Updated syscall interface in `sys.zig` to handle variable arguments for invocations.
Diffstat (limited to 'binaries')
-rw-r--r--binaries/mi/mi.zig4
-rw-r--r--binaries/nav/nav.zig46
-rw-r--r--binaries/nav/nav.zon10
3 files changed, 58 insertions, 2 deletions
diff --git a/binaries/mi/mi.zig b/binaries/mi/mi.zig
index 0f5e400..1e158a9 100644
--- a/binaries/mi/mi.zig
+++ b/binaries/mi/mi.zig
@@ -18,8 +18,8 @@ const PERM_WORLD: u8 = 2;
const PERM_READ_ONLY: u8 = 3;
export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 {
- // Use first argument as path, or default to "/"
- var target_path: []const u8 = "/";
+ // Use first argument as path, or default to ""
+ var target_path: []const u8 = "";
if (pc > 1) {
// Get pv[1] as the target path
diff --git a/binaries/nav/nav.zig b/binaries/nav/nav.zig
new file mode 100644
index 0000000..98883d0
--- /dev/null
+++ b/binaries/nav/nav.zig
@@ -0,0 +1,46 @@
+//! nav - Navigate the filesystem
+//!
+//! nav - Print current location
+//! nav <path> - Navigate to path
+//! nav ^ - Navigate to parent
+//! nav / - Navigate to root
+
+const akiba = @import("akiba");
+
+const Color = struct {
+ const white: u32 = 0x00FFFFFF;
+ const green: u32 = 0x0088FF88;
+ const red: u32 = 0x00FF4444;
+};
+
+// Global buffer
+var location_buf: [256]u8 = undefined;
+
+export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 {
+ // No arguments - print current location
+ if (pc <= 1) {
+ const location = akiba.io.getlocation(&location_buf) catch {
+ _ = akiba.io.mark(akiba.io.stream, "nav: cannot get current location.\n", Color.red) catch 0;
+ return 1;
+ };
+ _ = akiba.io.mark(akiba.io.stream, location, Color.green) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, "\n", Color.white) catch 0;
+ return 0;
+ }
+
+ // Get target path from argument
+ const arg = pv[1];
+ var target_len: usize = 0;
+ while (arg[target_len] != 0) : (target_len += 1) {}
+ const target = arg[0..target_len];
+
+ // Navigate - setlocation auto-sends letter to parent
+ akiba.io.setlocation(target) catch {
+ _ = akiba.io.mark(akiba.io.stream, "nav: cannot navigate to '", Color.red) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, target, Color.white) catch 0;
+ _ = akiba.io.mark(akiba.io.stream, "': No such stack.\n", Color.red) catch 0;
+ return 1;
+ };
+
+ return 0;
+}
diff --git a/binaries/nav/nav.zon b/binaries/nav/nav.zon
new file mode 100644
index 0000000..8597b44
--- /dev/null
+++ b/binaries/nav/nav.zon
@@ -0,0 +1,10 @@
+.{
+ .name = "nav",
+ .version = "0.1.0",
+ .dependencies = .{
+ .akiba = .{ .path = "../../system/libraries/akiba" },
+ },
+ .paths = .{
+ "nav.zig",
+ },
+}