Merge pull request #1133 from derekhjray/master

v3/diss (Linux): fix disk retrieve partition issue while using in container
This commit is contained in:
shirou 2021-09-30 22:51:49 +09:00 committed by GitHub
commit c2f6682078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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)