[PATCH] D31831: posix_fallocate isn't support on all filesystems
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 25 06:34:00 PDT 2017
rafael added a comment.
This revision is now accepted and ready to land.
Please don't duplicate the code in the compile time and runtime checks. Can you do something like
#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.
int Err = ::posix_fallocate(FD, 0, Size);
if (!Err)
return std::error_code();
if (Err && Err != EOPNOTSUPP)
return std::error_code(Err, std::generic_category());
// Add a comment about which file systems don't support posix_fallocate.
#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());
Repository:
rL LLVM
https://reviews.llvm.org/D31831
More information about the llvm-commits
mailing list