forked from Bananymous/banan-os
LibC: cleanup fstatat
This commit is contained in:
parent
8f3348cf2b
commit
d34c0a5abe
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue