Skip to content

syscall: Statfs_t on OpenBSD with f_ #47958

@miraculli

Description

@miraculli

What version of Go are you using (go version)?

$ go version
go version go1.16.2 openbsd/amd64

Does this issue reproduce with the latest release?

Go 1.17 is not yet available on OpenBSD

What operating system and processor architecture are you using (go env)?

openbsd/amd64

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/.../.cache/go-build"
GOENV="/home/.../.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="openbsd"
GOINSECURE=""
GOMODCACHE="/home/.../go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="openbsd"
GOPATH="/home/.../go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/openbsd_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build521513831=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This is related to nats-io/nats-server#2445
I want to build nats-server on openbsd but it fails due to undefined fields in syscall.Statfs_t on OpenBSD.

I tracked it somewhat down and can tell that this syscalls to Statfs work fine when calling with an "F_" prefix:

var fs syscall.Statfs_t
if err := syscall.Statfs(path, &fs); err == nil {
    fmt.Println(fs.F_bavail)
    fmt.Println(fs.F_bsize)
}

The field definition on OpenBSD can be found here: http://man.openbsd.org/statfs
But they look the same (with that 'f_' prefix) on Linux and Darwin where nats-server builds fine.

What did you expect to see?

This should compile on OpenBSD

var fs syscall.Statfs_t
if err := syscall.Statfs(path, &fs); err == nil {
    fmt.Println(fs.Bavail)
    fmt.Println(fs.Bsize)
}

What did you see instead?

This compiles and runs on OpenBSD fine but is different from other OSes

var fs syscall.Statfs_t
if err := syscall.Statfs(path, &fs); err == nil {
	fmt.Println(fs.F_bavail)
	fmt.Println(fs.F_bsize)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions