mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
e41342af83
Stephen Gregoratto (original author of the fallback) says: I read through both libcs again to compare: Musl: - `stat` path. Check error. - If path is a symlink, return `OPNOTSUPP`. - `openat` path as `O_PATH|O_NOFOLLOW|O_CLOEXEC`. Return `OPNOTSUPP` if we got `ELOOP`. - Build procfs filename. - `stat` procfs file. - If procfs file is a symlink, return `OPNOTSUPP`. - close path fd. Glibc: - open path as `O_PATH|O_NOFOLLOW|O_CLOEXEC`. - fstatat path fd. - If path is a symlink, return `OPNOTSUPP`. - Build procfs filename. - chmod procfs filename. Return `OPNOTSUPP` if we got `ENOENT`. - close path fd. I prefer glibc since you open the path first, which avoids a possible TOCTOU race.