From 0ca626639329c687075f8fe352d4ffabbf98288d Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Wed, 16 Aug 2023 21:24:20 -0500 Subject: [PATCH] fix IOCounters() SerialNumber enumeration --- disk/disk_linux.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 2a8c50a..f43780f 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -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