17f3c40a6SNhat Nguyen //===-- Linux implementation of fpathconf ---------------------------------===// 27f3c40a6SNhat Nguyen // 37f3c40a6SNhat Nguyen // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47f3c40a6SNhat Nguyen // See https://llvm.org/LICENSE.txt for license information. 57f3c40a6SNhat Nguyen // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67f3c40a6SNhat Nguyen // 77f3c40a6SNhat Nguyen //===----------------------------------------------------------------------===// 87f3c40a6SNhat Nguyen 97f3c40a6SNhat Nguyen #include "src/unistd/fpathconf.h" 107f3c40a6SNhat Nguyen #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 117f3c40a6SNhat Nguyen #include "src/__support/common.h" 12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 137f3c40a6SNhat Nguyen #include "src/sys/statvfs/linux/statfs_utils.h" 147f3c40a6SNhat Nguyen #include "src/unistd/linux/pathconf_utils.h" 157f3c40a6SNhat Nguyen 16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 177f3c40a6SNhat Nguyen 187f3c40a6SNhat Nguyen LLVM_LIBC_FUNCTION(long, fpathconf, (int fd, int name)) { 197f3c40a6SNhat Nguyen if (cpp::optional<statfs_utils::LinuxStatFs> result = 207f3c40a6SNhat Nguyen statfs_utils::linux_fstatfs(fd)) 217f3c40a6SNhat Nguyen return pathconfig(result.value(), name); 227f3c40a6SNhat Nguyen return -1; 237f3c40a6SNhat Nguyen } 247f3c40a6SNhat Nguyen 25*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 26