From: Jeremy Faller Date: Wed, 28 Oct 2020 14:52:02 +0000 (-0400) Subject: cmd/link: ignore "operation not permitted" fallocate errors. X-Git-Tag: go1.16beta1~425 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c45d78013f92a29285cd81488eb7a16819f01e18;p=gostls13.git cmd/link: ignore "operation not permitted" fallocate errors. 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 Run-TryBot: Jeremy Faller TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/link/internal/ld/outbuf.go b/src/cmd/link/internal/ld/outbuf.go index d696a68088..fa4d183337 100644 --- a/src/cmd/link/internal/ld/outbuf.go +++ b/src/cmd/link/internal/ld/outbuf.go @@ -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. diff --git a/src/cmd/link/internal/ld/outbuf_mmap.go b/src/cmd/link/internal/ld/outbuf_mmap.go index 53b14b09cc..807fe24375 100644 --- a/src/cmd/link/internal/ld/outbuf_mmap.go +++ b/src/cmd/link/internal/ld/outbuf_mmap.go @@ -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 } } diff --git a/src/cmd/link/internal/ld/outbuf_nofallocate.go b/src/cmd/link/internal/ld/outbuf_nofallocate.go index 51b4fe7aff..6bf96bcb2b 100644 --- a/src/cmd/link/internal/ld/outbuf_nofallocate.go +++ b/src/cmd/link/internal/ld/outbuf_nofallocate.go @@ -6,8 +6,6 @@ package ld -import "errors" - func (out *OutBuf) fallocate(size uint64) error { - return errors.New(fallocateNotSupportedErr) + return errNoFallocate }