This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Handle case where posix_fallocate is not supported for a filesystem.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=222b39c283e3fd7823ad95ccc58ae94e76b63237

commit 222b39c283e3fd7823ad95ccc58ae94e76b63237
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Dec 2 09:56:40 2017 -0800

    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:
---
 gold/ChangeLog |  8 ++++++++
 gold/output.cc | 18 +++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 59dd8d5..e0048b5 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2017-12-02  Vladimir Kondratyev  <vladimir@kondratyev.su>
+	    Cary Coutant  <ccoutant@gmail.com>
+
+	PR gold/22540
+	* output.cc (gold_fallocate): Trivial return for len == 0.
+	Add fallback options when posix_fallocate and fallocate return
+	not-supported errors.
+
 2017-12-01  Cary Coutant  <ccoutant@gmail.com>
 
 	PR gold/21090
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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]