From dd6a3c2c367cee12a8e2da81e7da6a2c8f3103d5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 23:20:19 -0300 Subject: Round 39's small ones: a name write past its one line is refused by that write; Get and Edit's e load over a scratch under 100 bytes unasked, as Del closes it; Putall saves a Zerox pair once; bare Tab on the root ctl says the width as from a pane, and a ctl check of Tab no longer sets it; a directory read is "is a directory" (EISDIR), an unreadable file "permission denied" (EACCES), Incl of a file "not a directory" (ENOTDIR), and a device "not a regular file", never read to the stream limit Co-Authored-By: Claude Opus 5.5 --- src/fs.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/fs.zig') diff --git a/src/fs.zig b/src/fs.zig index db07672e..fb76cee3 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1521,6 +1521,13 @@ fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { }; defer _ = libc.close(fd); + // A device (/dev/zero, a tty) is no file to read whole: said so, not + // read to the stream limit and called too large. + if (ninep_io.statNoFollow(path_z)) |facts| { + const kind = facts.mode & 0o170000; + if (kind == 0o040000) return error.IsDirectory; + if (kind == 0o020000 or kind == 0o060000) return error.NotAFile; + } const end = libc.lseek(fd, 0, libc.SEEK.END); // Not seekable: a pipe or a FIFO is no file; a regular file that is a // stream (a 9ns mount's log or screen, opened nonseekable) is read to -- cgit v1.3