1 | //===-- Linux implementation of lstat -------------------------------------===// |
---|---|
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/lstat.h" |
10 | #include "kernel_statx.h" |
11 | #include "src/__support/libc_errno.h" |
12 | #include "src/__support/macros/config.h" |
13 | |
14 | #include "src/__support/OSUtil/syscall.h" // For internal syscall function. |
15 | #include "src/__support/common.h" |
16 | |
17 | #include "hdr/fcntl_macros.h" |
18 | #include <sys/stat.h> |
19 | |
20 | namespace LIBC_NAMESPACE_DECL { |
21 | |
22 | LLVM_LIBC_FUNCTION(int, lstat, |
23 | (const char *__restrict path, |
24 | struct stat *__restrict statbuf)) { |
25 | int err = statx(AT_FDCWD, path, AT_SYMLINK_NOFOLLOW, statbuf); |
26 | if (err != 0) { |
27 | libc_errno = err; |
28 | return -1; |
29 | } |
30 | return 0; |
31 | } |
32 | |
33 | } // namespace LIBC_NAMESPACE_DECL |
34 |