summaryrefslogtreecommitdiff
path: root/src/ninep/pane.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 13:48:35 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitca362e190825862d5c0a1451d163d3c00be68314 (patch)
tree41ba9702527092b4e8cbc482c79d6651d6918fa0 /src/ninep/pane.zig
parenta2e466a874502b665807f620eb8edefb37be1e8c (diff)
downloadpardes-ca362e190825862d5c0a1451d163d3c00be68314.tar.gz
pardes-ca362e190825862d5c0a1451d163d3c00be68314.zip
A second line written to name is refused EINVAL, in one write or on the same open
bash writes printf 'a\nb\n' a line at a time, so each line arrived as a whole name on the held open and renamed the pane twice. An open that has named its pane now refuses a further line, as a two-line write already was. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/pane.zig')
-rw-r--r--src/ninep/pane.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index d48c8e71..66e3dad8 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -1124,6 +1124,24 @@ test "after a failed address, one that goes from it says there is none" {
try testing.expectEqual(Status.ok, wr(p, addr, ".").reply.status);
}
+test "a write of two lines to name is refused EINVAL, on a held open or not" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const serial = serialOf(p);
+ const node = Node.of(serial, .name);
+ try testing.expectEqual(E.INVAL, wr(p, node, "/tmp/a\n/tmp/b\n").errno());
+ const h = call(p, .{ .tag = 1, .op = .open, .node = node, .omode = 1 }).reply.handle;
+ try testing.expectEqual(E.INVAL, call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .data = "/tmp/a\n/tmp/b\n" }).errno());
+ _ = call(p, .{ .tag = 3, .op = .release, .node = node, .handle = h, .opened = true });
+ try testing.expectEqualStrings("/test.txt", nameOf(p.panes[p.paneBySerial(serial).?].?));
+ // Line by line, as bash writes it: the second line is refused.
+ const h2 = call(p, .{ .tag = 1, .op = .open, .node = node, .omode = 1 }).reply.handle;
+ try testing.expectEqual(Status.ok, call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h2, .data = "/tmp/pardes-a\n" }).reply.status);
+ try testing.expectEqual(E.INVAL, call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h2, .data = "/tmp/pardes-b\n" }).errno());
+ _ = call(p, .{ .tag = 3, .op = .release, .node = node, .handle = h2, .opened = true });
+ try testing.expectEqualStrings("/tmp/pardes-a", nameOf(p.panes[p.paneBySerial(serial).?].?));
+}
+
test "a name cut across writes is one name, applied once at its newline or its close" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();