|
Line 0
Link Here
|
|
|
1 |
--- gold/output.cc.orig 2017-03-02 08:23:53 UTC |
| 2 |
+++ gold/output.cc |
| 3 |
@@ -127,14 +127,26 @@ namespace gold |
| 4 |
static int |
| 5 |
gold_fallocate(int o, off_t offset, off_t len) |
| 6 |
{ |
| 7 |
+ if (len <= 0) |
| 8 |
+ return 0; |
| 9 |
+ |
| 10 |
#ifdef HAVE_POSIX_FALLOCATE |
| 11 |
if (parameters->options().posix_fallocate()) |
| 12 |
- return ::posix_fallocate(o, offset, len); |
| 13 |
+ { |
| 14 |
+ int err = ::posix_fallocate(o, offset, len); |
| 15 |
+ if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP) |
| 16 |
+ return err; |
| 17 |
+ } |
| 18 |
#endif // defined(HAVE_POSIX_FALLOCATE) |
| 19 |
+ |
| 20 |
#ifdef HAVE_FALLOCATE |
| 21 |
- if (::fallocate(o, 0, offset, len) == 0) |
| 22 |
- return 0; |
| 23 |
+ { |
| 24 |
+ int err = ::fallocate(o, 0, offset, len); |
| 25 |
+ if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP) |
| 26 |
+ return err; |
| 27 |
+ } |
| 28 |
#endif // defined(HAVE_FALLOCATE) |
| 29 |
+ |
| 30 |
if (::ftruncate(o, offset + len) < 0) |
| 31 |
return errno; |
| 32 |
return 0; |