1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-24 13:48:56 +08:00

fix IOCounters() SerialNumber enumeration

This commit is contained in:
Greg Dallavalle 2023-08-16 21:24:20 -05:00
parent d428168624
commit 0ca6266393

View File

@ -474,7 +474,11 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
}
d.Name = name
d.SerialNumber, _ = SerialNumberWithContext(ctx, name)
// Names passed in can be full paths (/dev/sda) or just device names (sda).
// Since `name`` here is already a basename, re-add a hardcoded /dev path.
// This is not ideal, but we may break the API by changing how SerialNumberWithContext
// works.
d.SerialNumber, _ = SerialNumberWithContext(ctx, "/dev/"+name)
d.Label, _ = LabelWithContext(ctx, name)
ret[name] = d