summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 06:34:56 -0300
committerGabriel Schneider <[email protected]>2026-10-01 07:16:43 -0300
commit0ac1b5a0c52357927a6e1eb525821144e4365474 (patch)
treec090df9f7a20764ab34194c45acb1723bbd40c8c /src/ninep/ctl.zig
parentbb9a5f19cf0ea6944fd8c67503e09aa5a2da4355 (diff)
downloadpardes-0ac1b5a0c52357927a6e1eb525821144e4365474.tar.gz
pardes-0ac1b5a0c52357927a6e1eb525821144e4365474.zip
A name write to a terminal, image or PDF and Edit on a pane with no text are refused EINVAL, in words a mount maps so: `invalid rename: ...` and the data write's own refusal
`rename not allowed: ...` went out EPERM, and `Edit ,d` on a PDF ran and failed late, EIO, while a data write there was EINVAL. The rename refusal now says `invalid rename` with EINVAL, and Edit on a pane with no text is refused before anything runs with the data write's words. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index fa6310bb..1bf916a9 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -991,6 +991,10 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply {
if (apply) _ = p.answerQuestion(id, if (choice[0] == '-') null else choice[0]);
} else if (!apply) {
if (checkBuiltin(p, req, line, .pane)) |refusal| return refusal;
+ // Edit on a pane with no text is the refusal a data write
+ // there gets, EINVAL, before anything runs.
+ if (std.mem.startsWith(u8, line, "Edit") and pane_files.fileOf(p.panes[p.paneBySerial(serial).?].?) == null)
+ return tree.failText(req.tag, E.INVAL, pane_files.e_no_text);
} else if (runBuiltin(p, req, p.paneBySerial(serial).?, line)) |refusal| {
return refusal;
}
@@ -4133,3 +4137,15 @@ test "a Rename that reaches other files previews them, says so, and is the pane
try testing.expectEqual(preview.serial, p.fs.lsp_result.?);
try testing.expect(th.logHas(p, "Rename: 2 edit(s) across files, previewed, not applied"));
}
+
+test "Edit on an image pane is refused as a data write there is, EINVAL, before it runs" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const doc = try p.newDocPane(p.freeSlot().?);
+ doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") };
+ const edit = wr(p, Node.of(doc.serial, .ctl), "Edit ,d\n");
+ const data = wr(p, Node.of(doc.serial, .data), "x");
+ try testing.expectEqual(E.INVAL, edit.errno());
+ try testing.expectEqualStrings(data.reply.ename, edit.reply.ename);
+ try testing.expectEqual(E.INVAL, wr(p, Node.of(doc.serial, .name), "/tmp/other.ppm\n").errno());
+}