From a550753fb60be3cdc040c521ddaab9022f5d3248 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 09:11:37 -0300 Subject: Every EINVAL a write gets says why; DEL in an exec or look line is a control character An empty name, a word written to log other than follow, a data, sel, dot or dirty write to a pane with no text, a truncate other than to zero, and a control character in a look line written through a held open were refused with no words, logged as `Invalid argument`. Each says its reason now; and DEL is refused in exec and look lines as in names. Co-Authored-By: Claude Opus 5.5 --- src/fs.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fs.zig') diff --git a/src/fs.zig b/src/fs.zig index 4414c150..352aa0c4 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -224,12 +224,12 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { if (fd < 0) return Reply.fail(req.tag, E.PERM); defer _ = libc.close(fd); if (req.op == .setattr) { - if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return Reply.fail(req.tag, E.INVAL); + if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return tree.failText(req.tag, E.INVAL, "invalid truncate: only to zero"); var truncated = attr; truncated.size = 0; return .{ .tag = req.tag, .attr = truncated }; } - if (req.off > std.math.maxInt(i64)) return Reply.fail(req.tag, E.INVAL); + if (req.off > std.math.maxInt(i64)) return tree.failText(req.tag, E.INVAL, "invalid offset: past what a file may hold"); if (libc.lseek(fd, @intCast(req.off), libc.SEEK.SET) < 0) return Reply.fail(req.tag, E.IO); if (req.op == .write) { const written = libc.write(fd, req.data.ptr, req.data.len); -- cgit v1.3