aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-20 18:08:45 +0530
committerBobby <[email protected]>2026-02-20 18:08:45 +0530
commit78c3c538e754ea43d5b52db0f64894cce78545ac (patch)
tree1782b4ee6816ea74f6cd6f86c46773a673170a90 /system
parent11529f20f7710771bd517648a71bc044ee37e825 (diff)
downloadakiba-78c3c538e754ea43d5b52db0f64894cce78545ac.tar.xz
akiba-78c3c538e754ea43d5b52db0f64894cce78545ac.zip
feat: Refactor path handling to use location utilities and update related structures
- Replaced path references with location in various modules for consistency. - Updated attachment management to use location instead of path. - Enhanced I/O operations to handle location parameters. - Removed deprecated path utilities and integrated location utilities. - Adjusted limits and parameters for kata and attachment management.
Diffstat (limited to 'system')
-rw-r--r--system/ash/ash.zig36
-rw-r--r--system/libraries/io/attachment.zig14
-rw-r--r--system/libraries/io/io.zig2
-rw-r--r--system/libraries/io/location.zig8
-rw-r--r--system/libraries/io/stream.zig4
-rw-r--r--system/libraries/io/types.zig10
-rw-r--r--system/libraries/kata/kata.zig8
7 files changed, 41 insertions, 41 deletions
diff --git a/system/ash/ash.zig b/system/ash/ash.zig
index 5149ab8..203becc 100644
--- a/system/ash/ash.zig
+++ b/system/ash/ash.zig
@@ -8,7 +8,7 @@ const string = @import("string");
const sys = @import("sys");
const MAX_INPUT = 256;
-const MAX_ARGS = 16;
+const MAX_PARAMETERS = 16;
var input_buffer: [MAX_INPUT]u8 = undefined;
var input_len: usize = 0;
@@ -16,8 +16,8 @@ var char_buffer: [1]u8 = undefined;
var location_buffer: [256]u8 = undefined;
var letter_buffer: [256]u8 = undefined;
-var arg_ptrs: [MAX_ARGS][*:0]const u8 = undefined;
-var arg_storage: [MAX_ARGS][128]u8 = undefined;
+var param_ptrs: [MAX_PARAMETERS][*:0]const u8 = undefined;
+var param_storage: [MAX_PARAMETERS][128]u8 = undefined;
export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 {
_ = pc;
@@ -60,10 +60,10 @@ export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 {
}
fn execute_command(input: []const u8) void {
- var argc: usize = 0;
+ var param_count: usize = 0;
var i: usize = 0;
- while (i < input.len and argc < MAX_ARGS) {
+ while (i < input.len and param_count < MAX_PARAMETERS) {
while (i < input.len and input[i] == ' ') : (i += 1) {}
if (i >= input.len) break;
@@ -72,26 +72,26 @@ fn execute_command(input: []const u8) void {
const end = i;
if (end > start) {
- const arg_len = end - start;
- if (arg_len < 127) {
+ const param_len = end - start;
+ if (param_len < 127) {
for (input[start..end], 0..) |c, j| {
- arg_storage[argc][j] = c;
+ param_storage[param_count][j] = c;
}
- arg_storage[argc][arg_len] = 0;
- arg_ptrs[argc] = @ptrCast(&arg_storage[argc]);
- argc += 1;
+ param_storage[param_count][param_len] = 0;
+ param_ptrs[param_count] = @ptrCast(&param_storage[param_count]);
+ param_count += 1;
}
}
}
- if (argc == 0) return;
+ if (param_count == 0) return;
- const cmd = arg_storage[0][0..string.findNull(&arg_storage[0])];
+ const cmd = param_storage[0][0..string.findNull(&param_storage[0])];
- var path_buf: [512]u8 = undefined;
- const path = string.concat3(&path_buf, "/binaries/", cmd, ".akiba");
+ var location_buf: [512]u8 = undefined;
+ const location = string.concat3(&location_buf, "/binaries/", cmd, ".akiba");
- if (try_spawn_with_args(path, arg_ptrs[0..argc])) {
+ if (try_spawn_with_params(location, param_ptrs[0..param_count])) {
process_letters();
return;
}
@@ -101,8 +101,8 @@ fn execute_command(input: []const u8) void {
format.println(".");
}
-fn try_spawn_with_args(path: []const u8, argv: [][*:0]const u8) bool {
- const pid = kata.spawnWithArgs(path, argv) catch {
+fn try_spawn_with_params(location: []const u8, params: [][*:0]const u8) bool {
+ const pid = kata.spawnWithParams(location, params) catch {
return false;
};
diff --git a/system/libraries/io/attachment.zig b/system/libraries/io/attachment.zig
index c68adf8..4672fec 100644
--- a/system/libraries/io/attachment.zig
+++ b/system/libraries/io/attachment.zig
@@ -5,28 +5,28 @@ const types = @import("types.zig");
const ERROR_RESULT: u64 = @bitCast(@as(i64, -1));
-pub fn attach(path: []const u8, flags: u32) types.Error!types.FileDescriptor {
- const result = sys.syscall(.attach, .{ @intFromPtr(path.ptr), flags });
+pub fn attach(location: []const u8, flags: u32) types.Error!types.Descriptor {
+ const result = sys.syscall(.attach, .{ @intFromPtr(location.ptr), flags });
if (result == ERROR_RESULT) {
return types.Error.NotFound;
}
return @truncate(result);
}
-pub fn seal(fd: types.FileDescriptor) void {
+pub fn seal(fd: types.Descriptor) void {
_ = sys.syscall(.seal, .{fd});
}
-pub fn viewstack(path: []const u8, entries: []types.StackEntry) types.Error!usize {
+pub fn viewstack(location: []const u8, entries: []types.StackEntry) types.Error!usize {
const result = sys.syscall(.viewstack, .{
- @intFromPtr(path.ptr),
- path.len,
+ @intFromPtr(location.ptr),
+ location.len,
@intFromPtr(entries.ptr),
entries.len,
});
if (result == ERROR_RESULT) {
- return types.Error.InvalidPath;
+ return types.Error.InvalidLocation;
}
return @intCast(result);
diff --git a/system/libraries/io/io.zig b/system/libraries/io/io.zig
index 588ff0c..f7c0da3 100644
--- a/system/libraries/io/io.zig
+++ b/system/libraries/io/io.zig
@@ -22,7 +22,7 @@ pub const sendLetter = letter.send;
pub const readLetter = letter.read;
pub const StackEntry = types.StackEntry;
-pub const FileDescriptor = types.FileDescriptor;
+pub const Descriptor = types.Descriptor;
pub const Letter = types.Letter;
pub const Error = types.Error;
diff --git a/system/libraries/io/location.zig b/system/libraries/io/location.zig
index 37d3115..0f1e114 100644
--- a/system/libraries/io/location.zig
+++ b/system/libraries/io/location.zig
@@ -18,13 +18,13 @@ pub fn get(buffer: []u8) types.Error![]u8 {
return buffer[0..@intCast(result)];
}
-pub fn set(path: []const u8) types.Error!void {
+pub fn set(location: []const u8) types.Error!void {
const result = sys.syscall(.setlocation, .{
- @intFromPtr(path.ptr),
- path.len,
+ @intFromPtr(location.ptr),
+ location.len,
});
if (result == ERROR_RESULT) {
- return types.Error.InvalidPath;
+ return types.Error.InvalidLocation;
}
}
diff --git a/system/libraries/io/stream.zig b/system/libraries/io/stream.zig
index 7f93c9d..8e65473 100644
--- a/system/libraries/io/stream.zig
+++ b/system/libraries/io/stream.zig
@@ -7,7 +7,7 @@ const types = @import("types.zig");
const ERROR_RESULT: u64 = @bitCast(@as(i64, -1));
const EAGAIN_RESULT: u64 = @bitCast(@as(i64, -2));
-pub fn view(fd: types.FileDescriptor, buffer: []u8) types.Error!usize {
+pub fn view(fd: types.Descriptor, buffer: []u8) types.Error!usize {
const result = sys.syscall(.view, .{ fd, @intFromPtr(buffer.ptr), buffer.len });
if (result == ERROR_RESULT) {
return types.Error.ReadFailed;
@@ -15,7 +15,7 @@ pub fn view(fd: types.FileDescriptor, buffer: []u8) types.Error!usize {
return result;
}
-pub fn mark(fd: types.FileDescriptor, data: []const u8, color: u32) types.Error!usize {
+pub fn mark(fd: types.Descriptor, data: []const u8, color: u32) types.Error!usize {
const result = sys.syscall(.mark, .{ fd, @intFromPtr(data.ptr), data.len, color });
if (result == ERROR_RESULT) {
return types.Error.WriteFailed;
diff --git a/system/libraries/io/types.zig b/system/libraries/io/types.zig
index d2ddb91..1b4336b 100644
--- a/system/libraries/io/types.zig
+++ b/system/libraries/io/types.zig
@@ -6,16 +6,16 @@ pub const Error = error{
InvalidDescriptor,
ReadFailed,
WriteFailed,
- InvalidPath,
+ InvalidLocation,
SendFailed,
GetLocationFailed,
};
-pub const FileDescriptor = u32;
+pub const Descriptor = u32;
-pub const source: FileDescriptor = 0;
-pub const stream: FileDescriptor = 1;
-pub const trace: FileDescriptor = 2;
+pub const source: Descriptor = 0;
+pub const stream: Descriptor = 1;
+pub const trace: Descriptor = 2;
pub const VIEW_ONLY: u32 = 0x01;
pub const MARK_ONLY: u32 = 0x02;
diff --git a/system/libraries/kata/kata.zig b/system/libraries/kata/kata.zig
index 951a742..39f4556 100644
--- a/system/libraries/kata/kata.zig
+++ b/system/libraries/kata/kata.zig
@@ -18,16 +18,16 @@ pub fn exit(code: u64) noreturn {
unreachable;
}
-pub fn spawn(path: []const u8) Error!u32 {
- const result = sys.syscall(.spawn, .{ @intFromPtr(path.ptr), path.len, @as(u64, 0), @as(u64, 0) });
+pub fn spawn(location: []const u8) Error!u32 {
+ const result = sys.syscall(.spawn, .{ @intFromPtr(location.ptr), location.len, @as(u64, 0), @as(u64, 0) });
if (result == ERROR_RESULT) {
return Error.SpawnFailed;
}
return @truncate(result);
}
-pub fn spawnWithArgs(path: []const u8, argv: [][*:0]const u8) Error!u32 {
- const result = sys.syscall(.spawn, .{ @intFromPtr(path.ptr), path.len, @intFromPtr(argv.ptr), argv.len });
+pub fn spawnWithParams(location: []const u8, params: [][*:0]const u8) Error!u32 {
+ const result = sys.syscall(.spawn, .{ @intFromPtr(location.ptr), location.len, @intFromPtr(params.ptr), params.len });
if (result == ERROR_RESULT) {
return Error.SpawnFailed;
}