mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +03:00
Previously, it was not possible to compile netBSD binary due to missing OS constrains at lib/fs and lib/filestream packages. This commit fixes it by: * apply proper constrains at lib/filestream * Introduce statfs_t and statfs() to abstract unix internals: NetBSD needs to use unix.Statvfs_t and unix.Statvfs() unlike other Unix-es. * apply proper constrain for vmctl terminal package Related PR https://github.com/VictoriaMetrics/VictoriaMetrics/pull/9473
23 lines
411 B
Go
23 lines
411 B
Go
//go:build linux || freebsd || netbsd
|
|
|
|
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func fadviseSequentialRead(f *os.File, prefetch bool) error {
|
|
fd := int(f.Fd())
|
|
mode := unix.FADV_SEQUENTIAL
|
|
if prefetch {
|
|
mode |= unix.FADV_WILLNEED
|
|
}
|
|
if err := unix.Fadvise(int(fd), 0, 0, mode); err != nil {
|
|
return fmt.Errorf("error returned from unix.Fadvise(%d): %w", mode, err)
|
|
}
|
|
return nil
|
|
}
|