1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package unix 6 7 import "syscall" 8 9 func PosixFallocate(fd int, off int64, size int64) error { 10 // If successful, posix_fallocate() returns zero. It returns an error on failure, without 11 // setting errno. See https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 12 // 13 // The padding 0 argument is needed because the ARM calling convention requires that if an 14 // argument (off in this case) needs double-word alignment (8-byte), the NCRN (next core 15 // register number) is rounded up to the next even register number. 16 // See https://github.com/ARM-software/abi-aa/blob/2bcab1e3b22d55170c563c3c7940134089176746/aapcs32/aapcs32.rst#parameter-passing 17 r1, _, _ := syscall.Syscall6(posixFallocateTrap, uintptr(fd), 0, uintptr(off), uintptr(off>>32), uintptr(size), uintptr(size>>32)) 18 if r1 != 0 { 19 return syscall.Errno(r1) 20 } 21 return nil 22 } 23