public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [gold commit] PR 22540: Handle case where posix_fallocate is not supported for a filesystem
@ 2017-12-02 17:56 Cary Coutant
  0 siblings, 0 replies; only message in thread
From: Cary Coutant @ 2017-12-02 17:56 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Committed.

-cary


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.

[-- Attachment #2: pr22540.patch --]
[-- Type: application/octet-stream, Size: 1236 bytes --]

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.

diff --git a/gold/output.cc b/gold/output.cc
index 5b1e601d49..ed70c44867 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-02 17:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-02 17:56 [gold commit] PR 22540: Handle case where posix_fallocate is not supported for a filesystem Cary Coutant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).