From d34c0a5abe06f0a5017f18e0857a3955a98e30f3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 11 Aug 2023 12:25:15 +0300 Subject: [PATCH] LibC: cleanup fstatat --- libc/sys/stat.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libc/sys/stat.cpp b/libc/sys/stat.cpp index c224ba06df..3f977f2a6f 100644 --- a/libc/sys/stat.cpp +++ b/libc/sys/stat.cpp @@ -11,13 +11,15 @@ int fstat(int fildes, struct stat* buf) int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag) { - if (flag & ~AT_SYMLINK_NOFOLLOW) + if (flag == AT_SYMLINK_NOFOLLOW) + flag = O_NOFOLLOW; + else if (flag) { errno = EINVAL; return -1; } - int target = openat(fd, path, (flag & AT_SYMLINK_NOFOLLOW) ? O_NOFOLLOW : 0); + int target = openat(fd, path, O_SEARCH | flag); if (target == -1) return -1; int ret = fstat(target, buf);