[llvm] r302263 - If posix_fallocate returns EOPNOTSUPP, fallback to ftruncate.
Joerg Sonnenberger via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 10:55:58 PDT 2017
Author: joerg
Date: Fri May 5 12:55:58 2017
New Revision: 302263
URL: http://llvm.org/viewvc/llvm-project?rev=302263&view=rev
Log:
If posix_fallocate returns EOPNOTSUPP, fallback to ftruncate.
This can happen at least on NetBSD.
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=302263&r1=302262&r2=302263&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Fri May 5 12:55:58 2017
@@ -421,14 +421,15 @@ std::error_code resize_file(int FD, uint
#if defined(HAVE_POSIX_FALLOCATE)
// 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))
- return std::error_code(Err, std::generic_category());
-#else
+ if (int Err = ::posix_fallocate(FD, 0, Size)) {
+ if (Err != EOPNOTSUPP)
+ return std::error_code(Err, std::generic_category());
+ }
+#endif
// Use ftruncate as a fallback. It may or may not allocate space. At least on
// OS X with HFS+ it does.
if (::ftruncate(FD, Size) == -1)
return std::error_code(errno, std::generic_category());
-#endif
return std::error_code();
}
More information about the llvm-commits
mailing list