]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: ignore "operation not permitted" fallocate errors.
authorJeremy Faller <jeremy@golang.org>
Wed, 28 Oct 2020 14:52:02 +0000 (10:52 -0400)
committerJeremy Faller <jeremy@golang.org>
Thu, 29 Oct 2020 13:53:33 +0000 (13:53 +0000)
Ignore an additional class of errors form fallocate, falling back to
heap allocated buffers for output.

Fixes #41356

Change-Id: Iaaa91620cec644c78978e0b258f166bc204a3f85
Reviewed-on: https://go-review.googlesource.com/c/go/+/254777
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/outbuf.go
src/cmd/link/internal/ld/outbuf_mmap.go
src/cmd/link/internal/ld/outbuf_nofallocate.go

index d696a68088d46ee63c2eb1de7614fe8403ff3ee4..fa4d18333714cc6b9a1d7c531b3a89c228d21555 100644 (file)
@@ -13,11 +13,10 @@ import (
        "os"
 )
 
-// If fallocate is not supported on this platform, return this error.
-// Note this is the same error returned by filesystems that don't support
-// fallocate, and that is intentional. The error is ignored where needed, and
-// OutBuf writes to heap memory.
-const fallocateNotSupportedErr = "operation not supported"
+// If fallocate is not supported on this platform, return this error. The error
+// is ignored where needed, and OutBuf writes to heap memory.
+var errNoFallocate = errors.New("operation not supported")
+
 const outbufMode = 0775
 
 // OutBuf is a buffered file writer.
index 53b14b09cc9b8d75783f12495ad277eeaaf50094..807fe24375220c45edbb3a241993500bf2906b31 100644 (file)
@@ -28,7 +28,7 @@ func (out *OutBuf) Mmap(filesize uint64) (err error) {
                // Some file systems do not support fallocate. We ignore that error as linking
                // can still take place, but you might SIGBUS when you write to the mmapped
                // area.
-               if err.Error() != fallocateNotSupportedErr {
+               if err != syscall.ENOTSUP && err != syscall.EPERM && err != errNoFallocate {
                        return err
                }
        }
index 51b4fe7affedcbd752f81c144dbce8159680f66d..6bf96bcb2baea2ce9867a8bb77b6efca306dd94e 100644 (file)
@@ -6,8 +6,6 @@
 
 package ld
 
-import "errors"
-
 func (out *OutBuf) fallocate(size uint64) error {
-       return errors.New(fallocateNotSupportedErr)
+       return errNoFallocate
 }