Skip to content

Commit d40b0a1

Browse files
stevenhcherrymui
authored andcommitted
cmd/link: fix mode parameter to fallocate on Linux
Fix the mode parameter to fallocate on Linux which is the operation mode and not the file mode as with os.OpenFile. Also handle syscall.EINTR. Fixes #38950 Change-Id: Ieed20d9ab5c8a49be51c9f9a42b7263f394a5261 Reviewed-on: https://go-review.googlesource.com/c/go/+/232805 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: Jeremy Faller <[email protected]>
1 parent 57e32c4 commit d40b0a1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ package ld
77
import "syscall"
88

99
func (out *OutBuf) fallocate(size uint64) error {
10-
return syscall.Fallocate(int(out.f.Fd()), outbufMode, 0, int64(size))
10+
return syscall.Fallocate(int(out.f.Fd()), 0, 0, int64(size))
1111
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ import (
1010
"syscall"
1111
)
1212

13-
func (out *OutBuf) Mmap(filesize uint64) error {
14-
err := out.fallocate(filesize)
13+
func (out *OutBuf) Mmap(filesize uint64) (err error) {
14+
for {
15+
if err = out.fallocate(filesize); err != syscall.EINTR {
16+
break
17+
}
18+
}
1519
if err != nil {
1620
// Some file systems do not support fallocate. We ignore that error as linking
1721
// can still take place, but you might SIGBUS when you write to the mmapped

0 commit comments

Comments
 (0)