[disk] Partition returns all list even if argument is False.

According to https://github.com/giampaolo/psutil/issues/906,
all BSD system returns same information `df` and `df -a`.
This commit is contained in:
shirou 2020-10-20 18:11:00 +09:00
parent 3202231bcd
commit fb1c75054a
3 changed files with 6 additions and 18 deletions

View File

@ -4,7 +4,6 @@ package disk
import (
"context"
"path"
"github.com/shirou/gopsutil/internal/common"
"golang.org/x/sys/unix"
@ -14,6 +13,8 @@ func Partitions(all bool) ([]PartitionStat, error) {
return PartitionsWithContext(context.Background(), all)
}
// PartitionsWithContext returns disk partition.
// 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
var ret []PartitionStat
@ -69,11 +70,6 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
Fstype: common.ByteToString(stat.Fstypename[:]),
Opts: opts,
}
if all == false {
if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
continue
}
}
ret = append(ret, d)
}

View File

@ -6,7 +6,6 @@ import (
"bytes"
"context"
"encoding/binary"
"path"
"strconv"
"golang.org/x/sys/unix"
@ -18,6 +17,8 @@ func Partitions(all bool) ([]PartitionStat, error) {
return PartitionsWithContext(context.Background(), all)
}
// PartitionsWithContext returns disk partition.
// 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
var ret []PartitionStat
@ -89,11 +90,6 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
Fstype: common.ByteToString(stat.Fstypename[:]),
Opts: opts,
}
if all == false {
if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
continue
}
}
ret = append(ret, d)
}

View File

@ -6,7 +6,6 @@ import (
"bytes"
"context"
"encoding/binary"
"path"
"github.com/shirou/gopsutil/internal/common"
"golang.org/x/sys/unix"
@ -16,6 +15,8 @@ func Partitions(all bool) ([]PartitionStat, error) {
return PartitionsWithContext(context.Background(), all)
}
// PartitionsWithContext returns disk partition.
// 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
var ret []PartitionStat
@ -66,11 +67,6 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
Fstype: common.IntToString(stat.F_fstypename[:]),
Opts: opts,
}
if all == false {
if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
continue
}
}
ret = append(ret, d)
}