follow the psutil principles, do nothing if can not find root device
This commit is contained in:
parent
d52b97cd25
commit
f6dc96c30e
|
@ -349,12 +349,11 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
|
|||
|
||||
// /dev/root is not the real device name
|
||||
// so we get the real device name from its major/minor number
|
||||
if d.Device == "/dev/root" && d.Fstype != "nfs" {
|
||||
if d.Device == "/dev/root" {
|
||||
devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err == nil {
|
||||
d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1)
|
||||
}
|
||||
d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1)
|
||||
}
|
||||
}
|
||||
ret = append(ret, d)
|
||||
|
|
Loading…
Reference in New Issue