v3/diss (Linux): fix disk retrieve partition issue while using in container

pull/1133/head
Derek Ray 4 years ago
parent ce5729cbcd
commit 1fa38051cb

@ -221,15 +221,15 @@ var fsTypeMap = map[int64]string{
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
useMounts := false useMounts := false
filename := common.HostProc("self/mountinfo") filename := common.HostProc("1/mountinfo")
lines, err := common.ReadLines(filename) lines, err := common.ReadLines(filename)
if err != nil { if err != nil {
if err != err.(*os.PathError) { if err != err.(*os.PathError) {
return nil, err 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 useMounts = true
filename = common.HostProc("self/mounts") filename = common.HostProc("1/mounts")
lines, err = common.ReadLines(filename) lines, err = common.ReadLines(filename)
if err != nil { if err != nil {
return nil, err return nil, err
@ -261,7 +261,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
} }
} }
} else { } 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 // 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) // (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)

Loading…
Cancel
Save