From f2ebb91cf0a6ef3714214c407689791d1d271d2d Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Sat, 16 Apr 2016 22:43:55 +0900 Subject: [PATCH] [disk]darwin,freebsd: implements 'all' argument. --- disk/disk_darwin.go | 7 +++++++ disk/disk_freebsd.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 83a733b..1ccb330 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -3,6 +3,7 @@ package disk import ( + "path" "syscall" "unsafe" @@ -74,6 +75,12 @@ func Partitions(all bool) ([]PartitionStat, error) { Fstype: common.IntToString(stat.Fstypename[:]), Opts: opts, } + if all == false { + if !path.IsAbs(d.Device) || !common.PathExists(d.Device) { + continue + } + } + ret = append(ret, d) } diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 4ec2d6e..4024bcb 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -5,6 +5,7 @@ package disk import ( "bytes" "encoding/binary" + "path" "strconv" "syscall" "unsafe" @@ -81,6 +82,12 @@ func Partitions(all bool) ([]PartitionStat, error) { Fstype: common.IntToString(stat.Fstypename[:]), Opts: opts, } + if all == false { + if !path.IsAbs(d.Device) || !common.PathExists(d.Device) { + continue + } + } + ret = append(ret, d) }