1616package collector
1717
1818import (
19- "bytes"
20- "unsafe"
21-
2219 "github.com/go-kit/kit/log/level"
2320 "golang.org/x/sys/unix"
2421)
@@ -30,15 +27,6 @@ const (
3027 noWait = 0x2 // MNT_NOWAIT
3128)
3229
33- func gostring (b []int8 ) string {
34- bb := * (* []byte )(unsafe .Pointer (& b ))
35- idx := bytes .IndexByte (bb , 0 )
36- if idx < 0 {
37- return ""
38- }
39- return string (bb [:idx ])
40- }
41-
4230// Expose filesystem fullness.
4331func (c * filesystemCollector ) GetStats () ([]filesystemStats , error ) {
4432 n , err := unix .Getfsstat (nil , noWait )
@@ -52,14 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
5240 }
5341 stats := []filesystemStats {}
5442 for _ , fs := range buf {
55- mountpoint := gostring (fs .Mntonname [:])
43+ mountpoint := string (fs .Mntonname [:])
5644 if c .ignoredMountPointsPattern .MatchString (mountpoint ) {
5745 level .Debug (c .logger ).Log ("msg" , "Ignoring mount point" , "mountpoint" , mountpoint )
5846 continue
5947 }
6048
61- device := gostring (fs .Mntfromname [:])
62- fstype := gostring (fs .Fstypename [:])
49+ device := string (fs .Mntfromname [:])
50+ fstype := string (fs .Fstypename [:])
6351 if c .ignoredFSTypesPattern .MatchString (fstype ) {
6452 level .Debug (c .logger ).Log ("msg" , "Ignoring fs type" , "type" , fstype )
6553 continue
0 commit comments