Update filesystem freebsd
Upstream x/sys/unix changed types.
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
