From 1fa38051cb8ab235f18589a23a0eac0722ebe5ce Mon Sep 17 00:00:00 2001 From: Derek Ray Date: Sat, 18 Sep 2021 17:17:59 +0800 Subject: [PATCH 1/2] v3/diss (Linux): fix disk retrieve partition issue while using in container --- v3/disk/disk_linux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v3/disk/disk_linux.go b/v3/disk/disk_linux.go index 459da5e..85146e7 100644 --- a/v3/disk/disk_linux.go +++ b/v3/disk/disk_linux.go @@ -221,15 +221,15 @@ var fsTypeMap = map[int64]string{ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { useMounts := false - filename := common.HostProc("self/mountinfo") + filename := common.HostProc("1/mountinfo") lines, err := common.ReadLines(filename) if err != nil { if err != err.(*os.PathError) { return nil, err } - // if kernel does not support self/mountinfo, fallback to self/mounts (<2.6.26) + // if kernel does not support 1/mountinfo, fallback to 1/mounts (<2.6.26) useMounts = true - filename = common.HostProc("self/mounts") + filename = common.HostProc("1/mounts") lines, err = common.ReadLines(filename) if err != nil { return nil, err @@ -261,7 +261,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } } } else { - // a line of self/mountinfo has the following structure: + // a line of 1/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) From b39f8bb90e5a83b4837cc62b001309562e63cd28 Mon Sep 17 00:00:00 2001 From: shirou Date: Thu, 30 Sep 2021 21:42:30 +0900 Subject: [PATCH 2/2] [v2][disk][linux] apply DiskPartiton change to v2 --- disk/disk_linux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 887c79a..7fc0bb4 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -221,15 +221,15 @@ var fsTypeMap = map[int64]string{ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { useMounts := false - filename := common.HostProc("self/mountinfo") + filename := common.HostProc("1/mountinfo") lines, err := common.ReadLines(filename) if err != nil { if err != err.(*os.PathError) { return nil, err } - // if kernel does not support self/mountinfo, fallback to self/mounts (<2.6.26) + // if kernel does not support 1/mountinfo, fallback to 1/mounts (<2.6.26) useMounts = true - filename = common.HostProc("self/mounts") + filename = common.HostProc("1/mounts") lines, err = common.ReadLines(filename) if err != nil { return nil, err @@ -261,7 +261,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } } } else { - // a line of self/mountinfo has the following structure: + // a line of 1/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)