Skip to content

Commit c45d780

Browse files
committed
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 <[email protected]> Run-TryBot: Jeremy Faller <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 96bd0b1 commit c45d780

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/cmd/link/internal/ld/outbuf.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import (
1313
"os"
1414
)
1515

16-
// If fallocate is not supported on this platform, return this error.
17-
// Note this is the same error returned by filesystems that don't support
18-
// fallocate, and that is intentional. The error is ignored where needed, and
19-
// OutBuf writes to heap memory.
20-
const fallocateNotSupportedErr = "operation not supported"
16+
// If fallocate is not supported on this platform, return this error. The error
17+
// is ignored where needed, and OutBuf writes to heap memory.
18+
var errNoFallocate = errors.New("operation not supported")
19+
2120
const outbufMode = 0775
2221

2322
// OutBuf is a buffered file writer.

src/cmd/link/internal/ld/outbuf_mmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (out *OutBuf) Mmap(filesize uint64) (err error) {
2828
// Some file systems do not support fallocate. We ignore that error as linking
2929
// can still take place, but you might SIGBUS when you write to the mmapped
3030
// area.
31-
if err.Error() != fallocateNotSupportedErr {
31+
if err != syscall.ENOTSUP && err != syscall.EPERM && err != errNoFallocate {
3232
return err
3333
}
3434
}

src/cmd/link/internal/ld/outbuf_nofallocate.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
package ld
88

9-
import "errors"
10-
119
func (out *OutBuf) fallocate(size uint64) error {
12-
return errors.New(fallocateNotSupportedErr)
10+
return errNoFallocate
1311
}

0 commit comments

Comments
 (0)