summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 0e92f5ce..4e096c97 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -29,6 +29,11 @@ const image_pane = @import("image_pane.zig");
const config = @import("config.zig");
const runtime_config = @import("runtime_config.zig");
const board_memory = @import("board_memory.zig");
+/// The host half of the 9P client, for the `9p` word at the bottom. Imported
+/// unconditionally and gated on `fs9_client.supported`, exactly like
+/// board_memory above: nothing in it is analysed for a build whose platform
+/// has no unix sockets, because the word is not registered there at all.
+const fs9_client = @import("fs9_client.zig");
/// The platform's runtime-setting facilities, stated once as plain data.
/// Registry generation, leader paths, Config, and EffectCode all consume this
@@ -1065,3 +1070,38 @@ pub const Gpio = struct {
c.p.reportError(c.id, "gpio", err);
}
};
+
+// ---- somebody else's tree ----
+
+/// `9p <dial> <path>` — walk to a file in ANOTHER pardes's tree, read it, and
+/// open the bytes in a pane.
+///
+/// THE OTHER END OF `--fs9`, and the reason the client in `src/9p.zig` is not a
+/// library with no caller: one pardes serves acme's control filesystem over
+/// 9P2000 on a unix socket, and this word is the second one reading it. `9p
+/// work /1/body` shows you what pane 1 of the session called `work` is holding,
+/// from a pane in this session, with no mount and no `plan9port` in the way.
+///
+/// A DIAL IS A NAME OR A PATH: `work` resolves through the same
+/// `fs9_service.socketPath` that bound it, and anything with a `/` in it is a
+/// socket path taken as given. Unix sockets only for now — a 9P server across a
+/// network is tunnelled (docs/9p.typ §10), and this word is not the place to
+/// decide otherwise.
+///
+/// It BLOCKS while it fetches, bounded by `fs9_client.budget_ms`, exactly the
+/// way Look blocks on a disk read; `src/fs9_client.zig` argues that at length
+/// and enforces it with a deadline rather than a promise.
+pub const @"9p" = struct {
+ pub const takes_arg = true;
+ pub const enabled = fs9_client.supported;
+ /// Prose and not a list: the bytes are a file's, so n/N walks its words the
+ /// way it walks any document's, and there is nothing here to step to.
+ pub const output: OutputTraits = .{ .name = config.ninep_buffer, .doc = true };
+ pub fn run(c: Ctx) void {
+ if (comptime enabled) apply(c) else unreachable;
+ }
+ fn apply(c: Ctx) void {
+ fs9_client.fetch(c.p, c.id, c.arg orelse "") catch |err|
+ c.p.reportError(c.id, "9p", err);
+ }
+};