2023-03-27 20:52:43 +02:00
|
|
|
// 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.
|
|
|
|
|
|
2025-08-06 17:50:14 +02:00
|
|
|
//go:build (freebsd || netbsd) && (amd64 || arm64 || riscv64)
|
2023-03-27 22:24:28 +02:00
|
|
|
|
2023-03-27 20:52:43 +02:00
|
|
|
package unix
|
|
|
|
|
|
|
|
|
|
import "syscall"
|
|
|
|
|
|
|
|
|
|
func PosixFallocate(fd int, off int64, size int64) error {
|
2023-04-05 13:16:58 +02:00
|
|
|
// 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
|
2025-08-06 17:50:14 +02:00
|
|
|
// and https://man.netbsd.org/posix_fallocate.2#RETURN%20VALUES
|
2023-04-05 13:16:58 +02:00
|
|
|
r1, _, _ := syscall.Syscall(posixFallocateTrap, uintptr(fd), uintptr(off), uintptr(size))
|
|
|
|
|
if r1 != 0 {
|
|
|
|
|
return syscall.Errno(r1)
|
2023-03-27 20:52:43 +02:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|