From a08b926ce632e7bffd46d6a2e950ef7ab45dcfc0 Mon Sep 17 00:00:00 2001 From: JHE Date: Sun, 10 Feb 2019 00:01:25 +0800 Subject: [PATCH] It could be another error than the "self/mountinfo" missing --- disk/disk_linux.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 0069af0..0546491 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -229,12 +229,12 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro filename := common.HostProc("self/mountinfo") lines, err := common.ReadLines(filename) if err != nil { + if err != err.(*os.PathError) { + return nil, err + } + //if kernel not support self/mountinfo useMounts = true - } - - //if kernel not support self/mountinfo - if useMounts { - filename := common.HostProc("self/mounts") + filename = common.HostProc("self/mounts") lines, err = common.ReadLines(filename) if err != nil { return nil, err @@ -248,9 +248,8 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro ret := make([]PartitionStat, 0, len(lines)) - var d PartitionStat - for _, line := range lines { + var d PartitionStat // a line of self/mountinfo has the following structure: // 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue // (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)