1 | //===-- Linux implementation of fstat -------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "src/sys/stat/fstat.h" |
10 | #include "kernel_statx.h" |
11 | #include "src/errno/libc_errno.h" |
12 | |
13 | #include "src/__support/common.h" |
14 | |
15 | #include <fcntl.h> |
16 | #include <sys/stat.h> |
17 | |
18 | namespace LIBC_NAMESPACE { |
19 | |
20 | LLVM_LIBC_FUNCTION(int, fstat, (int fd, struct stat *statbuf)) { |
21 | int err = statx(dirfd: fd, path: "", AT_EMPTY_PATH, statbuf); |
22 | if (err != 0) { |
23 | libc_errno = err; |
24 | return -1; |
25 | } |
26 | return 0; |
27 | } |
28 | |
29 | } // namespace LIBC_NAMESPACE |
30 |