summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/9p_io.zig')
-rw-r--r--src/9p_io.zig19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 0f5e0a77..2130db27 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -255,7 +255,7 @@ pub const Listener = struct {
const refused = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO);
return conn.reply(&refused, "");
}
- if (!quiet and pardes.ctlfs.needsQuiet(req)) {
+ if (!quiet and pardes.ctlfs.needsQuiet(l.core, req)) {
pardes.turn.parked = true;
const later: pardes.ctlfs.Reply = .{ .tag = req.tag, .status = .again };
return conn.reply(&later, "");
@@ -263,6 +263,8 @@ pub const Listener = struct {
const core = l.core;
const epoch = pardes.turn.epoch;
const restores = pardes.turn.restores;
+ // Asked first: a release that runs a held line has none after.
+ const changes = pardes.ctlfs.changesPane(core, req);
const reply = core.serveFs(req);
if (req.op == .release and quiet) l.collectOs();
// A read with nothing yet stays parked in the engine, and the core
@@ -289,7 +291,7 @@ pub const Listener = struct {
o.held = .{ .asker = conn, .req = req, .ticket = ticket };
return;
}
- if (!pardes.ctlfs.changesPane(req)) return conn.reply(&reply, core.fsPayload(reply));
+ if (!changes) return conn.reply(&reply, core.fsPayload(reply));
// The editor draws the change and performs what it asked for; when
// it asked for something -- a save, a shell, a watch -- the answer
// waits until that is done, so `echo Save > exec` returns with the
@@ -314,6 +316,9 @@ pub const Listener = struct {
// settle in the same wait is told to this write too.
if (l.core == core and core.fs.late_failure_len != 0) {
const failed = pardes.ctlfs.failText(req.tag, pardes.ctlfs.E.IO, core.fs.late_failure[0..core.fs.late_failure_len]);
+ // Its err record says it (the path in it); the msg the failure
+ // was also said as goes, as a builtin's failing a write does.
+ pardes.ctlfs.events.dropMessage(core, core.fs.late_failure[0..core.fs.late_failure_len]);
pardes.ctlfs.events.noteError(core, req, failed);
return conn.reply(&failed, "");
}
@@ -1756,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;