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