From 22fb8b6147f7fb72407af80c36d5e99e4664fea2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 07:27:13 -0300 Subject: Mount dials its peer at once and fails if none answers; a peer out of reach is said as `dial failed: ` Mount took any well-formed dial and nothing was found out until the first look through it, which then said `look: look: dial`. Mount now probes the peer (version, attach, its root) with the turn out, and fails its write, mounting nothing, when none answers; the dial errors read as words, `no answer`, `timed out`, `hung up`, and a look through a peer gone since names its path: `look: /n/peer/f: dial failed: no answer`. Co-Authored-By: Claude Opus 5.5 --- src/9p_io.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/9p_io.zig') diff --git a/src/9p_io.zig b/src/9p_io.zig index bda1ad36..2130db27 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1761,6 +1761,16 @@ pub const Client = struct { return fetchBytes(gpa, sock, names[0..n], &remote, null, display_path, @min(max_bytes, limits.max_file_bytes)); } + /// Whether a peer answers at `dial`: a version and attach, and its root + /// read. Any answer from the peer, an error of its own included, is one. + pub fn probe(gpa: std.mem.Allocator, dial: []const u8) !void { + const got = readLimit(gpa, dial, "", "", 0) catch |err| switch (err) { + error.IsDirectory, error.NotFound, error.Remote, error.FileTooLarge => return, + else => return err, + }; + gpa.free(got); + } + pub fn write(gpa: std.mem.Allocator, dial: []const u8, path: []const u8, bytes: []const u8) !void { if (comptime !supported) return error.Unsupported; var names: [max_depth][]const u8 = undefined; -- cgit v1.3