]> git.proxmox.com Git - wasi-libc.git/blame - libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c
bump version to 0.0~git20240411.9e8c542-1~bpo12+pve1
[wasi-libc.git] / libc-bottom-half / cloudlibc / src / libc / sys / stat / fstatat.c
CommitLineData
320054e8
DG
1// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
2//
3// SPDX-License-Identifier: BSD-2-Clause
4
320054e8
DG
5#include <sys/stat.h>
6
446cb3f1 7#include <wasi/api.h>
320054e8
DG
8#include <errno.h>
9#include <fcntl.h>
10#include <string.h>
11
12#include "stat_impl.h"
13
f2e779e5
DG
14int __wasilibc_nocwd_fstatat(int fd, const char *restrict path, struct stat *restrict buf,
15 int flag) {
320054e8 16 // Create lookup properties.
320054e8 17 __wasi_lookupflags_t lookup_flags = 0;
320054e8 18 if ((flag & AT_SYMLINK_NOFOLLOW) == 0)
446cb3f1 19 lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
320054e8
DG
20
21 // Perform system call.
22 __wasi_filestat_t internal_stat;
23 __wasi_errno_t error =
2b7e73ae 24 __wasi_path_filestat_get(fd, lookup_flags, path, &internal_stat);
320054e8 25 if (error != 0) {
099caae3 26 errno = error;
320054e8
DG
27 return -1;
28 }
29 to_public_stat(&internal_stat, buf);
30 return 0;
31}