Skip to content

Commit f6dc96c

Browse files
committed
follow the psutil principles, do nothing if can not find root device
1 parent d52b97c commit f6dc96c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

disk/disk_linux.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,11 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
349349

350350
// /dev/root is not the real device name
351351
// so we get the real device name from its major/minor number
352-
if d.Device == "/dev/root" && d.Fstype != "nfs" {
352+
if d.Device == "/dev/root" {
353353
devpath, err := os.Readlink(common.HostSys("/dev/block/" + blockDeviceID))
354-
if err != nil {
355-
return nil, err
354+
if err == nil {
355+
d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1)
356356
}
357-
d.Device = strings.Replace(d.Device, "root", filepath.Base(devpath), 1)
358357
}
359358
}
360359
ret = append(ret, d)

0 commit comments

Comments
 (0)