From aee8cecfcddaae298eb1bf2b51791e3a134a8454 Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Mon, 6 Jun 2022 14:05:41 -0400 Subject: [PATCH 1/2] Mirror updated x/sys/unix OpenBSD Statfs_t fields 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: https://github.com/golang/sys/commit/bc2c85ada10aa9b6aa9607e9ac9ad0761b95cf1d Signed-off-by: Alexander Scheel --- disk/disk_openbsd.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/disk/disk_openbsd.go b/disk/disk_openbsd.go index e0658650d..81ff23994 100644 --- a/disk/disk_openbsd.go +++ b/disk/disk_openbsd.go @@ -57,9 +57,9 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } d := PartitionStat{ - Device: common.IntToString(stat.F_mntfromname[:]), - Mountpoint: common.IntToString(stat.F_mntonname[:]), - Fstype: common.IntToString(stat.F_fstypename[:]), + Device: common.ByteToString(stat.F_mntfromname[:]), + Mountpoint: common.ByteToString(stat.F_mntonname[:]), + Fstype: common.ByteToString(stat.F_fstypename[:]), Opts: opts, } @@ -147,7 +147,7 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { } func getFsType(stat unix.Statfs_t) string { - return common.IntToString(stat.F_fstypename[:]) + return common.ByteToString(stat.F_fstypename[:]) } func SerialNumberWithContext(ctx context.Context, name string) (string, error) { From 4ad218b552943b6f65f450af660bfd61f4613d60 Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Mon, 6 Jun 2022 14:10:54 -0400 Subject: [PATCH 2/2] Update go.mod to clarify newer sys/unix dependency 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 --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c25d15d28..4867c9456 100644 --- a/go.mod +++ b/go.mod @@ -9,5 +9,5 @@ require ( github.com/stretchr/testify v1.7.1 github.com/tklauser/go-sysconf v0.3.10 github.com/yusufpapurcu/wmi v1.2.2 - golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a ) diff --git a/go.sum b/go.sum index 75f605832..dd28d0af2 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,9 @@ github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPR github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=