Line 0
Link Here
|
|
|
1 |
--- gold/output.cc.orig 2017-03-02 08:23:53 UTC |
2 |
+++ gold/output.cc |
3 |
@@ -128,8 +128,13 @@ static int |
4 |
gold_fallocate(int o, off_t offset, off_t len) |
5 |
{ |
6 |
#ifdef HAVE_POSIX_FALLOCATE |
7 |
- if (parameters->options().posix_fallocate()) |
8 |
- return ::posix_fallocate(o, offset, len); |
9 |
+ if (parameters->options().posix_fallocate()) { |
10 |
+ int ret = ::posix_fallocate(o, offset, len); |
11 |
+ // posix_fallocate is not supported by some COW file systems |
12 |
+ // like ZFS. Fallback to ftruncate in this case. |
13 |
+ if (ret != EINVAL || offset < 0 || len <= 0) |
14 |
+ return ret; |
15 |
+ } |
16 |
#endif // defined(HAVE_POSIX_FALLOCATE) |
17 |
#ifdef HAVE_FALLOCATE |
18 |
if (::fallocate(o, 0, offset, len) == 0) |