diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-20 00:59:34 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 2ce8956c8e9843eba7407ab12593871ee451b991 (patch) | |
| tree | 3c19599045e65947535365f51bfa5339aaa4568f /src/ninep | |
| parent | c1990b3e6e196ad41379aa432bf3ccca8a65d9f0 (diff) | |
| download | pardes-2ce8956c8e9843eba7407ab12593871ee451b991.tar.gz pardes-2ce8956c8e9843eba7407ab12593871ee451b991.zip | |
Use cloud9's file-server engine instead of the private copy
src/9p.zig shrinks to an 88-line alias: the engine and the backend contract
(Req, Reply/ReplyWith, Op, Status, Attr, E, error strings) now come from
cloud9.fs. The editor's limits become cloud9.fs.Options values; the ESP32-P4
board backend drops its own copies of the contract types. No behaviour
change; fs-bench still allocates nothing per request. cloud9 re-pinned to
the commit that carries the engine.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/tree.zig | 100 |
1 files changed, 27 insertions, 73 deletions
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index f716bf5f..56c3112d 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1,11 +1,14 @@ //! The control tree served over 9P: its nodes, lookup, readdir and the -//! dispatch that answers the engine in src/9p.zig. The backend contract -//! (Req, Reply, Op, Status, E) lives here; fs.zig keeps host access and mounts. +//! dispatch that answers the engine (cloud9.fs.Server, configured in +//! src/9p.zig). The backend contract (Req, Reply, Op, Status, E) is cloud9's, +//! extended here with the editor's reply payload; fs.zig keeps host access +//! and mounts. //! //! /README /index /ctl /new /log /screen /listeners //! /pane/<serial>/{name,body,tag,ctl,addr,data,xdata,sel,errors,event,pty/} //! /os/... the host filesystem /src/... embedded sources (opt-in) const std = @import("std"); +const cloud9 = @import("cloud9"); const pardes = @import("../pardes.zig"); const fs = @import("../fs.zig"); pub const events = @import("events.zig"); @@ -22,84 +25,35 @@ const MAX_PANES = pardes.MAX_PANES; pub const name_capacity: usize = 255; -// ---- the backend contract ---- - -pub const Op = enum(u8) { - lookup, - getattr, - setattr, - open, - read, - write, - release, - readdir, -}; +comptime { + // The editor's engine (src/9p.zig) remembers names this long. + std.debug.assert(@import("../9p.zig").editor.name_capacity == name_capacity); +} -pub const Status = enum(u8) { - ok, - again, - err, -}; +// ---- the backend contract: cloud9.fs, with the editor's payload locator ---- -pub const Req = struct { - tag: u64, - op: Op, - node: u64, - handle: u32 = 0, - off: u64 = 0, - size: u32 = 0, - data: []const u8 = &.{}, - truncate: bool = false, +pub const Op = cloud9.fs.Op; +pub const Status = cloud9.fs.Status; +pub const Req = cloud9.fs.Req; +pub const E = cloud9.fs.E; - pub fn changesPane(req: Req) bool { - return switch (req.op) { - .write, .setattr => true, - .open => req.node == @intFromEnum(TopFile.new), - .lookup, .getattr, .read, .release, .readdir => false, - }; - } +/// Where a reply's bytes live. The engine ignores it; `Pardes.fsPayload` +/// resolves it into the slice that travels beside the reply. +pub const Payload = union(enum) { + none, + staged: u32, + region: struct { pane: u8, serial: u32, off: u32, len: u32 }, }; -pub const Reply = struct { - tag: u64, - status: Status = .ok, - errno: u16 = 0, - attr: Attr = .{}, - handle: u32 = 0, - payload: Payload = .none, - written: u32 = 0, - - pub const Attr = struct { - name: []const u8 = "", - node: u64 = 0, - dir: bool = false, - size: u64 = 0, - mode: u16 = 0o644, - mtime: u32 = 0, - }; +pub const Reply = cloud9.fs.ReplyWith(Payload); - pub const Payload = union(enum) { - none, - staged: u32, - region: struct { pane: u8, serial: u32, off: u32, len: u32 }, +pub fn changesPane(req: Req) bool { + return switch (req.op) { + .write, .setattr => true, + .open => req.node == @intFromEnum(TopFile.new), + .lookup, .getattr, .read, .release, .readdir => false, }; - - pub fn fail(tag: u64, e: u16) Reply { - return .{ .tag = tag, .status = .err, .errno = e }; - } -}; - -pub const E = struct { - pub const PERM: u16 = 1; - pub const NOENT: u16 = 2; - pub const IO: u16 = 5; - pub const NOMEM: u16 = 12; - pub const NOTDIR: u16 = 20; - pub const INVAL: u16 = 22; - pub const NFILE: u16 = 23; - pub const NOSPC: u16 = 28; - pub const NOSYS: u16 = 38; -}; +} pub const out_reserve = 4 * 1024; |
