summaryrefslogtreecommitdiff
path: root/libc/src/sys/stat/linux/lstat.cpp
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2023-03-14 01:12:11 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2023-03-14 04:02:45 +0000
commit55612b8ec4210ae9c67658cb83393e8b4e8169d4 (patch)
tree2aa8c86a4bd7892f63fcc883c5cb70a0be941965 /libc/src/sys/stat/linux/lstat.cpp
parenta1f8bab9bad7dc7ef5bae518bc3289f4111846f3 (diff)
[libc] Switch sys/stat implementations over to libc_errno.
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D146004
Diffstat (limited to 'libc/src/sys/stat/linux/lstat.cpp')
-rw-r--r--libc/src/sys/stat/linux/lstat.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libc/src/sys/stat/linux/lstat.cpp b/libc/src/sys/stat/linux/lstat.cpp
index 816760a8c145..15a721ba784b 100644
--- a/libc/src/sys/stat/linux/lstat.cpp
+++ b/libc/src/sys/stat/linux/lstat.cpp
@@ -8,6 +8,7 @@
#include "src/sys/stat/lstat.h"
#include "kernel_statx.h"
+#include "src/errno/libc_errno.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
@@ -20,7 +21,12 @@ namespace __llvm_libc {
LLVM_LIBC_FUNCTION(int, lstat,
(const char *__restrict path,
struct stat *__restrict statbuf)) {
- return statx(AT_FDCWD, path, AT_SYMLINK_NOFOLLOW, statbuf);
+ int err = statx(AT_FDCWD, path, AT_SYMLINK_NOFOLLOW, statbuf);
+ if (err != 0) {
+ libc_errno = err;
+ return -1;
+ }
+ return 0;
}
} // namespace __llvm_libc