Update filesystem freebsd

Upstream x/sys/unix changed types.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2020-05-14 20:52:48 +02:00
parent cdb9e7d2b8
commit b532c81da7
No known key found for this signature in database
GPG key ID: C646B23C9E3245F1

View file

@ -16,9 +16,6 @@
package collector
import (
"bytes"
"unsafe"
"github.com/go-kit/kit/log/level"
"golang.org/x/sys/unix"
)
@ -30,15 +27,6 @@ const (
noWait = 0x2 // MNT_NOWAIT
)
func gostring(b []int8) string {
bb := *(*[]byte)(unsafe.Pointer(&b))
idx := bytes.IndexByte(bb, 0)
if idx < 0 {
return ""
}
return string(bb[:idx])
}
// Expose filesystem fullness.
func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
n, err := unix.Getfsstat(nil, noWait)
@ -52,14 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
}
stats := []filesystemStats{}
for _, fs := range buf {
mountpoint := gostring(fs.Mntonname[:])
mountpoint := string(fs.Mntonname[:])
if c.ignoredMountPointsPattern.MatchString(mountpoint) {
level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
continue
}
device := gostring(fs.Mntfromname[:])
fstype := gostring(fs.Fstypename[:])
device := string(fs.Mntfromname[:])
fstype := string(fs.Fstypename[:])
if c.ignoredFSTypesPattern.MatchString(fstype) {
level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
continue