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