mirror of
https://git.freebsd.org/ports.git
synced 2025-06-07 13:50:38 -04:00
lld: accept EINVAL to indicate posix_fallocate is unsupported As of r325320 posix_fallocate on a ZFS filesystem returns EINVAL to indicate that the operation is not supported. (I think this is a strange choice of errno on the part of POSIX.) PR: 223383, 223440 Reported by: Mark Millard
22 lines
788 B
C++
22 lines
788 B
C++
--- lib/Support/Unix/Path.inc.orig
|
|
+++ lib/Support/Unix/Path.inc
|
|
@@ -342,14 +342,15 @@
|
|
#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 != EINVAL && 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();
|
|
}
|