Handle case where posix_fallocate is not supported for a filesystem.
authorCary Coutant <ccoutant@gmail.com>
Sat, 2 Dec 2017 17:56:40 +0000 (09:56 -0800)
committerCary Coutant <ccoutant@gmail.com>
Sat, 2 Dec 2017 17:56:40 +0000 (09:56 -0800)
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.

gold/ChangeLog
gold/output.cc

index 59dd8d5e4a97b212e29babcf8a9274e6e7aeb3be..e0048b54cc86cf6d99028c8268cc3d0b3b0ab394 100644 (file)
@@ -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
index 5b1e601d4912f2df8e6ab9a680c507110360e909..ed70c44867742b6bb861c7382b331220f19cf77e 100644 (file)
@@ -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;
This page took 0.026688 seconds and 4 git commands to generate.