[libc-commits] [libc] [libc] implement pathconf/fpathconf (PR #87165)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Thu Jun 20 08:22:28 PDT 2024


================
@@ -0,0 +1,122 @@
+//===-- Linux implementation of pathconf_utils ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+#include "src/sys/statvfs/linux/statfs_utils.h"
+#include <linux/bfs_fs.h>
+#if __has_include(<linux/ufs_fs.h>)
+#include <linux/ufs_fs.h>
+#else
+// from https://elixir.bootlin.com/linux/latest/source/fs/ufs/ufs_fs.h
+#define UFS_MAGIC 0x00011954
+#endif
+#include "hdr/limits_macros.h"
+#include "hdr/unistd_macros.h"
+#include <linux/limits.h> // For LINK_MAX and other limits
+#include <linux/magic.h>  // For common FS magics
+
+namespace LIBC_NAMESPACE {
+
+long filesizebits(const statfs_utils::LinuxStatFs &s) {
+  switch (s.f_type) {
+  case JFFS2_SUPER_MAGIC:
+  case MSDOS_SUPER_MAGIC:
+  case NCP_SUPER_MAGIC:
+    return 32;
+  }
+  return 64;
+}
+
+long link_max(const statfs_utils::LinuxStatFs &s) {
+  switch (s.f_type) {
+  case EXT2_SUPER_MAGIC:
+    return 32000;
+  case MINIX_SUPER_MAGIC:
+    return 250;
+  case MINIX2_SUPER_MAGIC:
+    return 65530;
+  case REISERFS_SUPER_MAGIC:
+    return 0xffff - 1000;
+  case UFS_MAGIC:
+    return 32000;
+  }
+  return LINK_MAX;
+}
+
+long _2_symlinks(const statfs_utils::LinuxStatFs &s) {
----------------
nickdesaulniers wrote:

What's up with this function name? Please follow existing conventions, and give it a more descriptive identifier.

https://github.com/llvm/llvm-project/pull/87165


More information about the libc-commits mailing list