Skip to content

Commit a1fe4f2

Browse files
committed
link: fix support for archs without fstat
Change-Id: I5db6a541dd9e3827d055dc7e9ea695c8f7d1324c
1 parent 8facfbb commit a1fe4f2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/link/MappedFile.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ pub fn init(file: std.Io.File, gpa: std.mem.Allocator) !MappedFile {
5353
else => std.heap.page_size_max,
5454
},
5555
};
56+
} else if (is_linux) {
57+
var statx: linux.Statx = undefined;
58+
switch (linux.errno(linux.statx(mf.file.handle, "", linux.AT.EMPTY_PATH, linux.STATX_TYPE | linux.STATX_SIZE, &statx))) {
59+
.SUCCESS => {},
60+
.INVAL, .LOOP => unreachable,
61+
.NOMEM => return error.SystemResources,
62+
.ACCES => return error.AccessDenied,
63+
else => |err| return std.posix.unexpectedErrno(err),
64+
}
65+
if (statx.mode != linux.S.IFREG) return error.PathAlreadyExists;
66+
break :stat .{ statx.size, @max(std.heap.pageSize(), statx.blksize) };
5667
}
5768
const stat = try std.posix.fstat(mf.file.handle);
5869
if (!std.posix.S.ISREG(stat.mode)) return error.PathAlreadyExists;

0 commit comments

Comments
 (0)