mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on netbsd
The posix_fallocate system call is available since NetBSD 7.0, see https://man.netbsd.org/posix_fallocate.2 Re-use the syscall wrappers already in place for freebsd. Note that posix_fallocate on netbsd also returns the result in r1 rather than in errno: > If successful, posix_fallocate() returns zero. It returns an error on failure, without > setting errno. Source: https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES Cq-Include-Trybots: luci.golang.try:gotip-netbsd-arm64 Change-Id: Iaa1f6a805d511645da7f1d2737235bfd42da3407 Reviewed-on: https://go-review.googlesource.com/c/go/+/480475 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
3dbef65bf3
commit
ce3f3e2ae7
8 changed files with 23 additions and 15 deletions
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || (freebsd && go1.21) || linux
|
||||
//go:build darwin || (freebsd && go1.21) || linux || (netbsd && go1.25)
|
||||
|
||||
package ld
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build freebsd && go1.21
|
||||
//go:build (freebsd && go1.21) || (netbsd && go1.25)
|
||||
|
||||
package ld
|
||||
|
||||
|
|
@ -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 != syscall.ENOTSUP && err != syscall.EPERM && err != errNoFallocate {
|
||||
if err != syscall.ENOTSUP && err != syscall.EOPNOTSUPP && err != syscall.EPERM && err != errNoFallocate {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !darwin && !(freebsd && go1.21) && !linux
|
||||
//go:build !darwin && !(freebsd && go1.21) && !linux && !(netbsd && go1.25)
|
||||
|
||||
package ld
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,17 @@ package unix
|
|||
import "syscall"
|
||||
|
||||
const (
|
||||
unlinkatTrap uintptr = syscall.SYS_UNLINKAT
|
||||
openatTrap uintptr = syscall.SYS_OPENAT
|
||||
fstatatTrap uintptr = syscall.SYS_FSTATAT
|
||||
readlinkatTrap uintptr = syscall.SYS_READLINKAT
|
||||
mkdiratTrap uintptr = syscall.SYS_MKDIRAT
|
||||
fchmodatTrap uintptr = syscall.SYS_FCHMODAT
|
||||
fchownatTrap uintptr = syscall.SYS_FCHOWNAT
|
||||
renameatTrap uintptr = syscall.SYS_RENAMEAT
|
||||
linkatTrap uintptr = syscall.SYS_LINKAT
|
||||
symlinkatTrap uintptr = syscall.SYS_SYMLINKAT
|
||||
unlinkatTrap uintptr = syscall.SYS_UNLINKAT
|
||||
openatTrap uintptr = syscall.SYS_OPENAT
|
||||
fstatatTrap uintptr = syscall.SYS_FSTATAT
|
||||
readlinkatTrap uintptr = syscall.SYS_READLINKAT
|
||||
mkdiratTrap uintptr = syscall.SYS_MKDIRAT
|
||||
fchmodatTrap uintptr = syscall.SYS_FCHMODAT
|
||||
fchownatTrap uintptr = syscall.SYS_FCHOWNAT
|
||||
renameatTrap uintptr = syscall.SYS_RENAMEAT
|
||||
linkatTrap uintptr = syscall.SYS_LINKAT
|
||||
symlinkatTrap uintptr = syscall.SYS_SYMLINKAT
|
||||
posixFallocateTrap uintptr = 479
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (freebsd || netbsd) && 386
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
|
@ -9,6 +11,7 @@ import "syscall"
|
|||
func PosixFallocate(fd int, off int64, size int64) error {
|
||||
// If successful, posix_fallocate() returns zero. It returns an error on failure, without
|
||||
// setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1
|
||||
// and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES
|
||||
r1, _, _ := syscall.Syscall6(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(size), uintptr(size>>32), 0)
|
||||
if r1 != 0 {
|
||||
return syscall.Errno(r1)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build freebsd && (amd64 || arm64 || riscv64)
|
||||
//go:build (freebsd || netbsd) && (amd64 || arm64 || riscv64)
|
||||
|
||||
package unix
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ import "syscall"
|
|||
func PosixFallocate(fd int, off int64, size int64) error {
|
||||
// If successful, posix_fallocate() returns zero. It returns an error on failure, without
|
||||
// setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1
|
||||
// and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES
|
||||
r1, _, _ := syscall.Syscall(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(size))
|
||||
if r1 != 0 {
|
||||
return syscall.Errno(r1)
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (freebsd || netbsd) && arm
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
|
@ -9,6 +11,7 @@ import "syscall"
|
|||
func PosixFallocate(fd int, off int64, size int64) error {
|
||||
// If successful, posix_fallocate() returns zero. It returns an error on failure, without
|
||||
// setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1
|
||||
// and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES
|
||||
//
|
||||
// The padding 0 argument is needed because the ARM calling convention requires that if an
|
||||
// argument (off in this case) needs double-word alignment (8-byte), the NCRN (next core
|
||||
Loading…
Add table
Add a link
Reference in a new issue