[PATCH] D60175: [Support] On AIX, Check ENOTSUP on posix_fallocate instead of EOPNOTSUPP

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 2 20:27:32 PDT 2019


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: xingxue, sfertile, jasonliu.
Herald added subscribers: jsji, kristina.
Herald added a project: LLVM.

`posix_fallocate` can fail if the underlying filesystem does not support it; and, on AIX, such a failure is reported by a return value of `ENOTSUP`. The existing code checks only for `EOPNOTSUPP`, which may share the same value as `ENOTSUP`, but is not required to.


Repository:
  rL LLVM

https://reviews.llvm.org/D60175

Files:
  lib/Support/Unix/Path.inc


Index: lib/Support/Unix/Path.inc
===================================================================
--- lib/Support/Unix/Path.inc
+++ lib/Support/Unix/Path.inc
@@ -492,7 +492,12 @@
   // If we have posix_fallocate use it. Unlike ftruncate it always allocates
   // space, so we get an error if the disk is full.
   if (int Err = ::posix_fallocate(FD, 0, Size)) {
-    if (Err != EINVAL && Err != EOPNOTSUPP)
+#ifdef _AIX
+    constexpr int NotSupportedError = ENOTSUP;
+#else
+    constexpr int NotSupportedError = EOPNOTSUPP;
+#endif
+    if (Err != EINVAL && Err != NotSupportedError)
       return std::error_code(Err, std::generic_category());
   }
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60175.193424.patch
Type: text/x-patch
Size: 662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/38ccfbb9/attachment.bin>


More information about the llvm-commits mailing list