1//===-- Linux implementation of statvfs -----------------------------------===//
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/statvfs/statvfs.h"
10#include "src/__support/common.h"
11#include "src/__support/libc_assert.h"
12#include "src/sys/statvfs/linux/statfs_utils.h"
13
14namespace LIBC_NAMESPACE {
15
16LLVM_LIBC_FUNCTION(int, statvfs,
17 (const char *__restrict path,
18 struct statvfs *__restrict buf)) {
19 using namespace statfs_utils;
20 cpp::optional<LinuxStatFs> result = linux_statfs(path);
21 if (result) {
22 LIBC_ASSERT(buf != nullptr);
23 *buf = statfs_to_statvfs(*result);
24 }
25 return result ? 0 : -1;
26}
27
28} // namespace LIBC_NAMESPACE
29

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