aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-07-10 14:45:54 +0200
committerHimbeer <himbeer@disroot.org>2024-07-10 14:45:54 +0200
commit538fb19cd3394cbcd89d0dc9af60540d8b3cb19e (patch)
treeecba5bb8737dcb693f81b30b16310acbccc1a67c
parentad198f401be990b30e7756daef33b58e3ad28868 (diff)
syscall: Support removing resources from directory hooks
-rw-r--r--src/lib/syscall.zig13
-rw-r--r--src/lib/vfs.zig2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/syscall.zig b/src/lib/syscall.zig
index 5e9105b..3b7ed71 100644
--- a/src/lib/syscall.zig
+++ b/src/lib/syscall.zig
@@ -180,11 +180,14 @@ fn remove(trap_frame: *trap.Frame) void {
if (vfs.find(dirname)) |node| {
const basename = std.fs.path.basenamePosix(path);
- sysexchange.frameReturn(null, trap_frame, switch (node.data.resource) {
- .dir => |*dir| dir.remove(basename),
- .dir_hook => Error.Unimplemented,
- else => vfs.Error.NotADirectory,
- });
+ switch (node.data.resource) {
+ .dir => |*dir| sysexchange.frameReturn(null, trap_frame, dir.remove(basename)),
+ .dir_hook => |dir_hook| {
+ const result = dir_hook.removeFn(basename.ptr, basename.len);
+ sysexchange.frameReturnResult(void, trap_frame, result);
+ },
+ else => sysexchange.frameReturn(void, trap_frame, vfs.Error.NotADirectory),
+ }
} else {
sysexchange.frameReturn(void, trap_frame, vfs.Error.NotFound);
}
diff --git a/src/lib/vfs.zig b/src/lib/vfs.zig
index af3b05c..49a086a 100644
--- a/src/lib/vfs.zig
+++ b/src/lib/vfs.zig
@@ -64,7 +64,7 @@ pub const DirHook = struct {
pub const ProvideFn = *allowzero const fn (inode: Inode) sysexchange.Result(void);
pub const FindFn = *allowzero const fn (name: [*:0]const u8) ?Inode;
- pub const RemoveFn = *allowzero const fn (name: [*:0]const u8) sysexchange.Result(void);
+ pub const RemoveFn = *allowzero const fn (name: [*]const u8, name_len: usize) callconv(.C) sysexchange.Result(void);
};
pub const Resource = union(enum) {