Fix IOCountersForNames on darwin

This commit is contained in:
Daniel Nelson 2017-04-07 11:40:49 -07:00
parent 3f35f001da
commit ab6db76df1
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
3 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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")
}
@ -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
}

View File

@ -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
}