summaryrefslogtreecommitdiff
path: root/src/fs.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs.zig')
-rw-r--r--src/fs.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/fs.zig b/src/fs.zig
index d13e36bd..91edd429 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -1360,7 +1360,13 @@ fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 {
defer _ = libc.close(fd);
const end = libc.lseek(fd, 0, libc.SEEK.END);
- if (end < 0 and libc.errno(end) == .SPIPE) return error.NotAFile;
+ // 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
+ // its end, as one with no length is.
+ if (end < 0 and libc.errno(end) == .SPIPE) {
+ const facts = ninep_io.statNoFollow(path_z) orelse return error.NotAFile;
+ if (facts.mode & 0o170000 != 0o100000) return error.NotAFile;
+ }
const size: usize = if (end < 0) 0 else @intCast(end);
if (end >= 0 and libc.lseek(fd, 0, libc.SEEK.SET) < 0) return error.ReadFailed;
if (size == 0) {