1//===-- Linux implementation of stat --------------------------------------===//
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/stat.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
18namespace LIBC_NAMESPACE {
19
20LLVM_LIBC_FUNCTION(int, stat,
21 (const char *__restrict path,
22 struct stat *__restrict statbuf)) {
23 int err = statx(AT_FDCWD, path, flags: 0, statbuf);
24 if (err != 0) {
25 libc_errno = err;
26 return -1;
27 }
28 return 0;
29}
30
31} // namespace LIBC_NAMESPACE
32

source code of libc/src/sys/stat/linux/stat.cpp