diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2017-05-05 17:55:58 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2017-05-05 17:55:58 +0000 |
commit | ecfb876eac1edf733a8be163c52421e7eeea02b4 (patch) | |
tree | 231bfa0237379d6365baff85e1fbaa899483a0c5 /llvm/lib | |
parent | f0aeee01c36b9b84afd4ccc5834df61b6b9f6a13 (diff) | |
download | bcm5719-llvm-ecfb876eac1edf733a8be163c52421e7eeea02b4.tar.gz bcm5719-llvm-ecfb876eac1edf733a8be163c52421e7eeea02b4.zip |
If posix_fallocate returns EOPNOTSUPP, fallback to ftruncate.
This can happen at least on NetBSD.
llvm-svn: 302263
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 93f8982196b..fa28ba1b6ab 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -421,14 +421,15 @@ std::error_code resize_file(int FD, uint64_t Size) { #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(); } |