mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
std.fs.File: Fix metadata error check on Linux
On Linux, File.metadata calls the statx syscall directly. As such, the return value is the error code. Previously, it handled the error with `posix.errno`, which when libc is linked, treats the return value as a value set to -1 if there is an error with the error code in errno. If libc wasn't linked, it would be handled correctly. In the Linux with libc linked case, this would cause the error result to always be treated as success (err val != -1), even when an error occurred.
This commit is contained in:
parent
f2dcfe0e40
commit
a916bc7fdd
@ -1072,7 +1072,7 @@ pub fn metadata(self: File) MetadataError!Metadata {
|
|||||||
&stx,
|
&stx,
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (posix.errno(rc)) {
|
switch (linux.E.init(rc)) {
|
||||||
.SUCCESS => {},
|
.SUCCESS => {},
|
||||||
.ACCES => unreachable,
|
.ACCES => unreachable,
|
||||||
.BADF => unreachable,
|
.BADF => unreachable,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user