follow the psutil principles, do nothing if can not find root device

pull/1291/head
arstercz 3 years ago
parent d52b97cd25
commit f6dc96c30e

@ -349,14 +349,13 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
// /dev/root is not the real device name // /dev/root is not the real device name
// so we get the real device name from its major/minor number // 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)) devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID))
if err != nil { if err == nil {
return nil, err
}
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) ret = append(ret, d)
} }

Loading…
Cancel
Save