mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
20 lines
714 B
Go
20 lines
714 B
Go
// Copyright 2023 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build (freebsd || netbsd) && (amd64 || arm64 || riscv64)
|
|
|
|
package unix
|
|
|
|
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)
|
|
}
|
|
return nil
|
|
}
|