[llvm] r357662 - [Support] On AIX, Check ENOTSUP on posix_fallocate instead of EOPNOTSUPP

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 17:40:35 PDT 2019


Author: hubert.reinterpretcast
Date: Wed Apr  3 17:40:34 2019
New Revision: 357662

URL: http://llvm.org/viewvc/llvm-project?rev=357662&view=rev
Log:
[Support] On AIX, Check ENOTSUP on posix_fallocate instead of EOPNOTSUPP

Summary:
`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.

Reviewers: xingxue, sfertile, jasonliu

Reviewed By: xingxue

Subscribers: kristina, jsji, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60175

Modified:
    llvm/trunk/lib/Support/Unix/Path.inc

Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=357662&r1=357661&r2=357662&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Wed Apr  3 17:40:34 2019
@@ -492,7 +492,12 @@ std::error_code resize_file(int FD, uint
   // 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




More information about the llvm-commits mailing list