| 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 |
//go:build freebsd || (netbsd && go1.25) |
| 6 |
|
| 7 |
package ld |
| 8 |
|
| 9 |
import ( |
| 10 |
"internal/syscall/unix" |
| 11 |
"syscall" |
| 12 |
) |
| 13 |
|
| 14 |
func (out *OutBuf) fallocate(size uint64) error { |
| 15 |
err := unix.PosixFallocate(int(out.f.Fd()), 0, int64(size)) |
| 16 |
// ZFS on FreeBSD does not support posix_fallocate and returns EINVAL in that case. |
| 17 |
if err == syscall.EINVAL { |
| 18 |
return errNoFallocate |
| 19 |
} |
| 20 |
return err |
| 21 |
} |