aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorHolger Berger <holger.berger@googlemail.com>2021-03-19 15:38:54 -0700
committerCary Coutant <ccoutant@gmail.com>2021-03-19 16:18:53 -0700
commit07b1c3dbd96ff68bcb9017d01feb6063b94d4bf1 (patch)
treea4f09ce64c5fff8d2932d38224854d59a2540542 /gold
parentcc1849716f5c217a38ee416b48da1914a8ab66cb (diff)
downloadgdb-07b1c3dbd96ff68bcb9017d01feb6063b94d4bf1.zip
gdb-07b1c3dbd96ff68bcb9017d01feb6063b94d4bf1.tar.gz
gdb-07b1c3dbd96ff68bcb9017d01feb6063b94d4bf1.tar.bz2
Fix call to system fallocate to handle errno correctly.
2021-03-19 Holger Berger <holger.berger@googlemail.com> gold/ PR gold/26541 * output.cc (gold_fallocate): Use errno when calling system fallocate.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog5
-rw-r--r--gold/output.cc6
2 files changed, 9 insertions, 2 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 2d4e609..4aec6d4 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-19 Holger Berger <holger.berger@googlemail.com>
+
+ PR gold/26541
+ * output.cc (gold_fallocate): Use errno when calling system fallocate.
+
2021-03-19 Cary Coutant <ccoutant@gmail.com>
PR gold/26585
diff --git a/gold/output.cc b/gold/output.cc
index b7505ff..afdba06 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -141,12 +141,14 @@ gold_fallocate(int o, off_t offset, off_t len)
#ifdef HAVE_FALLOCATE
{
+ errno = 0;
int err = ::fallocate(o, 0, offset, len);
- if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
- return err;
+ if (err < 0 && errno != EINVAL && errno != ENOSYS && errno != EOPNOTSUPP)
+ return errno;
}
#endif // defined(HAVE_FALLOCATE)
+ errno = 0;
if (::ftruncate(o, offset + len) < 0)
return errno;
return 0;