summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 11:30:18 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1 (patch)
treed8c84364f51e3d9e136d5ad4e196235e12d37f66 /src/pardes.zig
parentfda2f546f66d0bb1b30da0ef6aae77fe82803b1c (diff)
downloadpardes-5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1.tar.gz
pardes-5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1.zip
A failure naming a long path keeps its reason, and name refuses a component over 255 bytes
A Save of a 3000-byte path failed with the record "err 2 ctl: Save…", which lost the reason. The first cause was reportError, which formatted into 256 bytes, so the operation's path filled the buffer before the reason was written. The second was the waiting write's late failure, which took the first 256 bytes of the message row, never its end. Now reportError has room for the longest path. reportFailure also keeps the words fitted as an err is (fitErr: the path gives up its middle, the reason stays), and the late failure of a Save, a Dump, a shell or a ThemeFile takes those words. fs.md already said a name holds up to 255 bytes a component, but a longer one was taken and only failed later at Save. Now it is refused when written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index ef713e0c..7fddf19f 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -5341,10 +5341,7 @@ pub const Pardes = struct {
}
// A 9P write that asked for the shell (pty/ctl's exec), waiting on
// it, fails with what was said, as a failed Save's does.
- const said = pane.msg[0..pane.msg_len];
- const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len);
- @memcpy(p.fs.late_failure[0..kept.len], kept);
- p.fs.late_failure_len = @intCast(kept.len);
+ p.noteLateFailure(id);
}
pub fn saveFailed(p: *Pardes, id: u8, path: []const u8, err: anyerror) void {
@@ -5362,10 +5359,7 @@ pub const Pardes = struct {
p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{path}) catch "Save: no such directory")
else
p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path}) catch "Save", err);
- const said = if (p.panes[id]) |pane| pane.msg[0..pane.msg_len] else "Save failed";
- const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len);
- @memcpy(p.fs.late_failure[0..kept.len], kept);
- p.fs.late_failure_len = @intCast(kept.len);
+ p.noteLateFailure(id);
}
/// A Dump the host could not write: said on the message row and in the
@@ -5388,10 +5382,7 @@ pub const Pardes = struct {
} else p.reportError(p.active, operation, err);
// In the words the message row has, so the write's err is the one
// record of it (its msg goes: 9p_io, dropMessage).
- const said = if (p.panes[p.active]) |pane| pane.msg[0..pane.msg_len] else "Dump failed";
- const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len);
- @memcpy(p.fs.late_failure[0..kept.len], kept);
- p.fs.late_failure_len = @intCast(kept.len);
+ p.noteLateFailure(p.active);
}
/// The path a watch is about: a real file's, or a PDF's.
@@ -6460,8 +6451,11 @@ pub const Pardes = struct {
/// What was said of a failure just now on pane `id` is also the waiting
/// 9P write's (9p_io, `fs.late_failure`).
pub fn noteLateFailure(p: *Pardes, id: usize) void {
- const pane = p.panes[id] orelse return;
- const said = pane.msg[0..pane.msg_len];
+ // Said by reportFailure just now: its words fitted whole, the
+ // reason kept; else what the message row has.
+ const said = if (p.fs.said_at == p.fs.failures and p.fs.said_len > 0)
+ p.fs.said[0..p.fs.said_len]
+ else if (p.panes[id]) |pane| pane.msg[0..pane.msg_len] else return;
const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len);
@memcpy(p.fs.late_failure[0..kept.len], kept);
p.fs.late_failure_len = @intCast(kept.len);