From d9c6786e19567878e3c89ae212296ce941484096 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 10:18:59 -0300 Subject: Truncating data or xdata deletes only the addressed range, not the whole body A shell's echo NEW > data opens data with OTRUNC, and truncate() spliced the whole body away before the write replaced the addressed range: a five-byte replacement erased a buffer. data and xdata hold what addr names, so truncating one now deletes that range and nothing else; > on data replaces the range and : > data deletes it, and only truncating body clears the buffer. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/fs.py') diff --git a/test/fs.py b/test/fs.py index c7552a2b..ca1ca70e 100644 --- a/test/fs.py +++ b/test/fs.py @@ -338,6 +338,14 @@ def discovery(binary, embedded=False): assert client.read('/src/pardes.zig').startswith(b'const std') assert client.stat('/src/pardes.zig')['mode'] == 0o444 assert b'pub const Pardes' in client.read(f'/pane/{look(client, "/virtual/src/pardes.zig")}/body') + # An open of data with OTRUNC (a shell's >) deletes the addressed + # range only, so the write after it replaces that range. + scratch = new_pane(client, b'hello world\nsecond line\n') + client.write(f'/pane/{scratch}/addr', b'#0,#5') + client.write(f'/pane/{scratch}/data', b'HOWDY', truncate=True) + assert client.read(f'/pane/{scratch}/body') == b'HOWDY world\nsecond line\n' + client.remove(f'/pane/{scratch}') + print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel, log, ctl lock, focus, the ctl split and commands behave') -- cgit v1.3