Fix IOCountersForNames on darwin

pull/347/head
Daniel Nelson 8 years ago
parent 3f35f001da
commit ab6db76df1
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155

@ -87,10 +87,6 @@ func Partitions(all bool) ([]PartitionStat, error) {
return ret, nil 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) { func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
var bufsize uintptr var bufsize uintptr

@ -30,9 +30,11 @@ import (
"errors" "errors"
"strings" "strings"
"unsafe" "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 { if C.StartIOCounterFetch() == 0 {
return nil, errors.New("Unable to fetch disk list") 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), 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 ret[d.Name] = d
} }

@ -5,6 +5,6 @@ package disk
import "github.com/shirou/gopsutil/internal/common" 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 return nil, common.ErrNotImplementedError
} }

Loading…
Cancel
Save