prometheus / procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Apache License 2.0
754 stars 311 forks source link

No longer compiles on plan9 #554

Closed ncw closed 9 months ago

ncw commented 11 months ago

This no longer compiles on plan9 which it used to.

This means that "github.com/prometheus/client_golang/prometheus" no longer compiles on plan9.

$ go get github.com/prometheus/procfs@master
$ GOOS=plan9 go build -v
github.com/prometheus/procfs
# github.com/prometheus/procfs
../../../../pkg/mod/github.com/prometheus/procfs@v0.11.1/fs_statfs_type.go:25:18: undefined: syscall.Statfs_t
../../../../pkg/mod/github.com/prometheus/procfs@v0.11.1/fs_statfs_type.go:26:17: undefined: syscall.Statfs
discordianfish commented 11 months ago

We need to move the types to a platform dependent file I guess.

dswarbrick commented 10 months ago

fs_statfs_type.go was initially checked in with build tags:

//go:build !netbsd && !openbsd && !solaris

and now has even more verbose tags:

//go:build !netbsd && !openbsd && !solaris && !windows && !nostatfs

!plan9 could be added to these, but maybe it's more concise to specify the GOOS values which do support Statfs_t.

GOOS which have a syscall.Statfs() func: aix, darwin, dragonfly, freebsd, linux, openbsd. GOOS which have a syscall.Statfs_t struct containing a Type member: aix, darwin, dragonfly, freebsd, linux.

Note the absence of openbsd in the latter. The intersection of those GOOS may be used as the build tags for fs_statfs_type.go, i.e.

//go:build aix || darwin || dragonfly || freebsd || linux

However, the isRealProc() function compares stat.Type to a magic number (PROC_SUPER_MAGIC, 0x9fa0), which is highly likely to be Linux-specific. It is defined on FreeBSD due to its Linux compatibility layer, but I'm skeptical that it would be defined (or relevant) on AIX, Darwin or DragonFly BSD.

I'm leaning towards the opinion that this function should be built on Linux (and maybe FreeBSD) only.

bozkayasalihx commented 9 months ago

I had same issue too