summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 22:58:58 -0300
committerGabriel Schneider <[email protected]>2026-11-05 00:57:13 -0300
commit406f9809cd69c1bcd69cdfc752b32e2a2e4e76c0 (patch)
treeef6f0090c4f3344e2125aa9f184cc156890daac6 /src
parent243ad6686a7ca5ae31cc8df366a0c9928414732f (diff)
downloadpardes-406f9809cd69c1bcd69cdfc752b32e2a2e4e76c0.tar.gz
pardes-406f9809cd69c1bcd69cdfc752b32e2a2e4e76c0.zip
pty/ctl: its stat counted the grid's `winsize` while its read says the size a winsize write set (14 bytes against 15 after `winsize 132 44`), and a mount reads up to the stat: both now come from pty.winsize; the every-verb test checks the stat
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/ninep/pane.zig4
-rw-r--r--src/ninep/pty.zig4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index d1668dd7..c12b2e80 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -380,8 +380,10 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 {
.pty_status => pty.status_len,
.pty_ctl => pty_ctl: {
var buf: [32]u8 = undefined;
+ // The size a read says: what winsize set, else the grid.
+ const size = pty.winsize(pane);
// unreachable: two u16s and 9 bytes fit 32
- break :pty_ctl (std.fmt.bufPrint(&buf, "winsize {d} {d}\n", .{ pane.cols, pane.rows }) catch unreachable).len;
+ break :pty_ctl (std.fmt.bufPrint(&buf, "winsize {d} {d}\n", .{ size[0], size[1] }) catch unreachable).len;
},
.pty_data => if (pf.pty_out.peek()) |chunk| chunk.len else 0,
.dir, .errors, .pty, .pty_run => 0,
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig
index 5a974adf..b913e83b 100644
--- a/src/ninep/pty.zig
+++ b/src/ninep/pty.zig
@@ -137,7 +137,7 @@ pub fn readCtl(p: *Pardes, req: Req, pane: *Pane) Reply {
}
/// The pty's size: what ctl's winsize set, else the pane's grid.
-fn winsize(pane: *const Pane) [2]u16 {
+pub fn winsize(pane: *const Pane) [2]u16 {
return pane.fs.winsize orelse .{ pane.cols, pane.rows };
}
@@ -591,6 +591,8 @@ test "every pty/ctl verb, and every refusal" {
try testing.expectEqual(rows, pane.rows);
// ctl and status read back the pty's size, until the pane resizes.
try testing.expectEqualStrings("winsize 132 44\n", rd(p, ctl, 0, 64).bytes);
+ // Its stat is that read's length, which a mount reads up to.
+ try testing.expectEqual(@as(u64, "winsize 132 44\n".len), call(p, .{ .tag = 1, .op = .getattr, .node = ctl }).reply.attr.size);
try testing.expect(std.mem.startsWith(u8, rd(p, Node.of(serialOf(p), .pty_status), 0, 64).bytes, " 132 44 "));
p.update(.{ .resize = .{ .cols = 76, .rows = 24 } });
try testing.expect(pane.cols != 132);