Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix []int8 to []byte in disk/disk_openbsd.go due to x/sys/unix type change #1310

Merged
merged 2 commits into from Jun 7, 2022

Conversation

cipherboy
Copy link
Contributor

@cipherboy cipherboy commented Jun 6, 2022

This was noticed in the Hashicorp Vault CI pipelines during cross-compilation to OpenBSD.

See also: #1309 for context around this change in upstream x/sys/unix.

Resolves: #1309


N.B.: I don't have access to a OpenBSD box to test this out natively. See comment below, thanks @schultz-is!

Per change in x/sys/unix, these Statfs_t fields are now converted to
[]byte rather than []int8. Callers with updated x/sys/unix versions will
now see something like:

> Error: ../../../go/pkg/mod/github.com/shirou/gopsutil@v3.21.5+incompatible/disk/disk_openbsd.go:59:53: cannot use stat.F_mntfromname[:] (type []byte) as type []int8 in argument to common.IntToString
> Error: ../../../go/pkg/mod/github.com/shirou/gopsutil@v3.21.5+incompatible/disk/disk_openbsd.go:60:51: cannot use stat.F_mntonname[:] (type []byte) as type []int8 in argument to common.IntToString
> Error: ../../../go/pkg/mod/github.com/shirou/gopsutil@v3.21.5+incompatible/disk/disk_openbsd.go:61:52: cannot use stat.F_fstypename[:] (type []byte) as type []int8 in argument to common.IntToString
> Error: ../../../go/pkg/mod/github.com/shirou/gopsutil@v3.21.5+incompatible/disk/disk_openbsd.go:149:45: cannot use stat.F_fstypename[:] (type []byte) as type []int8 in argument to common.IntToString

It is probably prudent to update to the newer struct definitions as a
result.

See also: https://groups.google.com/g/golang-codereviews/c/bPBR9-4hV6E
See also: https://go-review.googlesource.com/c/sys/+/407195/2
See also: golang/sys@bc2c85a

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Updated via:

$ go get -u golang.org/x/sys && go mod tidy

We now require upstream commit bc2c85a on OpenBSD due to type changes.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@schultz-is
Copy link

FWIW, I tested this on an OpenBSD 7.1 machine and it passed.

# arch
OpenBSD.amd64

# go version
go version go1.17.7 openbsd/amd64

# go clean -testcache

# go test ./...
?       github.com/shirou/gopsutil/v3   [no test files]
ok      github.com/shirou/gopsutil/v3/cpu       3.963s
ok      github.com/shirou/gopsutil/v3/disk      0.009s
ok      github.com/shirou/gopsutil/v3/docker    0.008s
ok      github.com/shirou/gopsutil/v3/host      0.009s
ok      github.com/shirou/gopsutil/v3/internal/common   0.062s
ok      github.com/shirou/gopsutil/v3/load      0.011s
ok      github.com/shirou/gopsutil/v3/mem       0.013s
ok      github.com/shirou/gopsutil/v3/net       0.022s
ok      github.com/shirou/gopsutil/v3/process   1.924s

Copy link
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the link to the detailed information. It is very easy to understand. Awesome!

@shirou shirou merged commit ff544cb into shirou:master Jun 7, 2022
@austingebauer
Copy link

Hi, @shirou! Do you happen to have an estimate for when this will land in a release? We're looking to get this updated in Vault to move some other dependencies forward. Thank you!

@shirou
Copy link
Owner

shirou commented Jun 28, 2022

gopsutil has a monthly based release policy. so we will release end of June.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure on OpenBSD with updated x/sys/unix
4 participants