aboutsummaryrefslogtreecommitdiff
path: root/gold/output.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2017-12-02 09:56:40 -0800
committerCary Coutant <ccoutant@gmail.com>2017-12-02 09:56:40 -0800
commit222b39c283e3fd7823ad95ccc58ae94e76b63237 (patch)
tree760dd25601f20d8e6f6da0f2e831ba3afe540454 /gold/output.cc
parent158600eb989bcbc364c6d18259f1cb32ea9dc478 (diff)
downloadgdb-222b39c283e3fd7823ad95ccc58ae94e76b63237.zip
gdb-222b39c283e3fd7823ad95ccc58ae94e76b63237.tar.gz
gdb-222b39c283e3fd7823ad95ccc58ae94e76b63237.tar.bz2
Handle case where posix_fallocate is not supported for a filesystem.
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su> Cary Coutant <ccoutant@gmail.com> gold/ PR gold/22540 * output.cc (gold_fallocate): Trivial return for len == 0. Add fallback options when posix_fallocate and fallocate return not-supported errors.
Diffstat (limited to 'gold/output.cc')
-rw-r--r--gold/output.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/gold/output.cc b/gold/output.cc
index 5b1e601..ed70c44 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -127,14 +127,26 @@ namespace gold
static int
gold_fallocate(int o, off_t offset, off_t len)
{
+ if (len <= 0)
+ return 0;
+
#ifdef HAVE_POSIX_FALLOCATE
if (parameters->options().posix_fallocate())
- return ::posix_fallocate(o, offset, len);
+ {
+ int err = ::posix_fallocate(o, offset, len);
+ if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
+ return err;
+ }
#endif // defined(HAVE_POSIX_FALLOCATE)
+
#ifdef HAVE_FALLOCATE
- if (::fallocate(o, 0, offset, len) == 0)
- return 0;
+ {
+ int err = ::fallocate(o, 0, offset, len);
+ if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
+ return err;
+ }
#endif // defined(HAVE_FALLOCATE)
+
if (::ftruncate(o, offset + len) < 0)
return errno;
return 0;