tubular icon indicating copy to clipboard operation
tubular copied to clipboard

fix compilation on ARM32

Open chbmuc opened this issue 3 years ago • 1 comments

BPF_FS_MAGIC is too big for statfs.Type on 32bit architectures. Converting to uint64 seems to fix this.

chbmuc avatar Feb 20 '22 16:02 chbmuc

Hello!

This is BPF_FS_MAGIC on arm:

$ GOARCH=arm go doc golang.org/x/sys/unix.BPF_FS_MAGIC | grep BPF_FS
	BPF_FS_MAGIC                                = 0xcafe4a11

Statfs_t.Type is int32 it seems:

$ GOARCH=arm go doc golang.org/x/sys/unix.Statfs_t
package unix // import "golang.org/x/sys/unix"

type Statfs_t struct {
	Type    int32
	Bsize   int32
	Blocks  uint64
	Bfree   uint64
	Bavail  uint64
	Files   uint64
	Ffree   uint64
	Fsid    Fsid
	Namelen int32
	Frsize  int32
	Flags   int32
	Spare   [4]int32
	// Has unexported fields.
}

The problem is that the constant exceeds int32. In this instance I would probably convert to int64 instead of uint64 since that makes conversion a no op on 64 bit arches.

lmb avatar Feb 22 '22 09:02 lmb