diff options
Diffstat (limited to 'src/fs.zig')
| -rw-r--r-- | src/fs.zig | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 |
