diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-01 15:35:26 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-01 15:35:26 +0200 |
commit | eef85056c996cf86e88c2589dc95429d59362c7b (patch) | |
tree | c680d102ca6f0bced9435f84083f3267664496df /src/lib/vfs.zig | |
parent | c188a18be912a03b00d501cd83eeaff63f6ff950 (diff) |
syscall: Add provideFile, provideHook and provideDirHook and mkdir stub
Diffstat (limited to 'src/lib/vfs.zig')
-rw-r--r-- | src/lib/vfs.zig | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/lib/vfs.zig b/src/lib/vfs.zig index c324c48..798813f 100644 --- a/src/lib/vfs.zig +++ b/src/lib/vfs.zig @@ -22,18 +22,45 @@ pub const Stream = struct { readFn: ?ReadFn, writeFn: ?WriteFn, - pub const ReadFn = *const fn (context: u16, buffer: []u8) sysexchange.Result(usize); - pub const WriteFn = *const fn (context: u16, bytes: []const u8) sysexchange.Result(usize); + pub const ReadFn = *const fn (buffer: []u8) sysexchange.Result(usize); + pub const WriteFn = *const fn (bytes: []const u8) sysexchange.Result(usize); }; // A file is a resource that creates a unique data stream with a driver. -pub const File = struct {}; +pub const File = struct { + openFn: OpenFn, + readFn: ?ReadFn, + writeFn: ?WriteFn, + closeFn: ?CloseFn, + + pub const OpenFn = *allowzero const fn (pid: u16) sysexchange.Result(*anyopaque); + pub const ReadFn = *const fn (context: *anyopaque, buffer: []u8) sysexchange.Result(usize); + pub const WriteFn = *const fn (context: *anyopaque, bytes: []const u8) sysexchange.Result(usize); + pub const CloseFn = *const fn (context: *anyopaque) void; +}; // A hook is a resource that invokes raw driver callbacks when interacted with. -pub const Hook = struct {}; +pub const Hook = struct { + callback: Callback, + + pub const Callback = *allowzero const fn (pid: u16, data: usize) sysexchange.Result(usize); +}; + +pub const MkdirOptions = packed struct(usize) { + full: u1, + reserved: u63, +}; // A directory hook is a resource that provides other resources via driver callbacks. -pub const DirHook = struct {}; +pub const DirHook = struct { + provideFn: ProvideFn, + findFn: FindFn, + removeFn: RemoveFn, + + pub const ProvideFn = *allowzero const fn (inode: Inode) sysexchange.Result(void); + pub const FindFn = *allowzero const fn (name: []const u8) ?Inode; + pub const RemoveFn = *allowzero const fn (name: []const u8) sysexchange.Result(void); +}; pub const Resource = union(enum) { stream: Stream, |