mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 23:29:03 +00:00
link: fix support for archs without fstat
Change-Id: I5db6a541dd9e3827d055dc7e9ea695c8f7d1324c
This commit is contained in:
parent
8facfbbcad
commit
a1fe4f299d
1 changed files with 11 additions and 0 deletions
|
|
@ -53,6 +53,17 @@ pub fn init(file: std.Io.File, gpa: std.mem.Allocator) !MappedFile {
|
||||||
else => std.heap.page_size_max,
|
else => std.heap.page_size_max,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} else if (is_linux) {
|
||||||
|
var statx: linux.Statx = undefined;
|
||||||
|
switch (linux.errno(linux.statx(mf.file.handle, "", linux.AT.EMPTY_PATH, linux.STATX_TYPE | linux.STATX_SIZE, &statx))) {
|
||||||
|
.SUCCESS => {},
|
||||||
|
.INVAL, .LOOP => unreachable,
|
||||||
|
.NOMEM => return error.SystemResources,
|
||||||
|
.ACCES => return error.AccessDenied,
|
||||||
|
else => |err| return std.posix.unexpectedErrno(err),
|
||||||
|
}
|
||||||
|
if (statx.mode != linux.S.IFREG) return error.PathAlreadyExists;
|
||||||
|
break :stat .{ statx.size, @max(std.heap.pageSize(), statx.blksize) };
|
||||||
}
|
}
|
||||||
const stat = try std.posix.fstat(mf.file.handle);
|
const stat = try std.posix.fstat(mf.file.handle);
|
||||||
if (!std.posix.S.ISREG(stat.mode)) return error.PathAlreadyExists;
|
if (!std.posix.S.ISREG(stat.mode)) return error.PathAlreadyExists;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue