mirror of
https://github.com/golang/go.git
synced 2025-05-28 10:51:22 +00:00
The posix_fallocate syscall 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.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 Adjust the PosixFallocate wrappers on freebsd to account for that. Also, CL 479715 used the same syscall wrapper for 386 and arm. However, on arm the syscall argument order is different. The wrapper was generated using mksyscall.go from the golang.org/x/sys/unix package, adjusting the r1 check correspondingly. Fixes #59352 Change-Id: I9a4e8e4546237010bc5e730c4988a2a476264cf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/481621 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
20 lines
637 B
Go
20 lines
637 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 && (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
|
|
r1, _, _ := syscall.Syscall(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(size))
|
|
if r1 != 0 {
|
|
return syscall.Errno(r1)
|
|
}
|
|
return nil
|
|
}
|