Skip to content

Commit

Permalink
Fix IOCountersForNames on darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson committed Apr 7, 2017
1 parent 3f35f00 commit ab6db76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 0 additions & 4 deletions disk/disk_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ func Partitions(all bool) ([]PartitionStat, error) {
return ret, nil
}

func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}

func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer
var bufsize uintptr
Expand Down
8 changes: 7 additions & 1 deletion disk/disk_darwin_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import (
"errors"
"strings"
"unsafe"

"github.com/shirou/gopsutil/internal/common"
)

func IOCounters() (map[string]IOCountersStat, error) {
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
if C.StartIOCounterFetch() == 0 {
return nil, errors.New("Unable to fetch disk list")
}
Expand Down Expand Up @@ -78,6 +80,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
Name: strings.TrimFunc(C.GoStringN(&di.DiskName[0], C.MAX_DISK_NAME), isRuneNull),
}

if len(names) > 0 && !common.StringsHas(names, d.Name) {
continue
}

ret[d.Name] = d
}

Expand Down
2 changes: 1 addition & 1 deletion disk/disk_darwin_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package disk

import "github.com/shirou/gopsutil/internal/common"

func IOCounters() (map[string]IOCountersStat, error) {
func IOCountersForNames(names []string) (map[string]IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}

0 comments on commit ab6db76

Please sign in to comment.