From 0ca626639329c687075f8fe352d4ffabbf98288d Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Wed, 16 Aug 2023 21:24:20 -0500 Subject: [PATCH 1/4] 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 2a8c50ae4..f43780fb9 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 From aa4c84c6b384de7445ab3506ddf89825154ca823 Mon Sep 17 00:00:00 2001 From: Greg <2582552+gdvalle@users.noreply.github.com> Date: Thu, 17 Aug 2023 09:37:46 -0500 Subject: [PATCH 2/4] Update disk/disk_linux.go Co-authored-by: shirou --- disk/disk_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index f43780fb9..2632a281f 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -478,7 +478,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC // 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.SerialNumber, _ = SerialNumberWithContext(ctx, common.HostDevWithContext(ctx, name)) d.Label, _ = LabelWithContext(ctx, name) ret[name] = d From b2d1f05f08da2a30f83e00cfdb87495415646d99 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Thu, 17 Aug 2023 09:38:49 -0500 Subject: [PATCH 3/4] update comment --- disk/disk_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 2632a281f..77d7deabd 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -475,7 +475,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC d.Name = 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. + // Since `name`` here is already a basename, re-add the /dev path. // This is not ideal, but we may break the API by changing how SerialNumberWithContext // works. d.SerialNumber, _ = SerialNumberWithContext(ctx, common.HostDevWithContext(ctx, name)) From 0a23dc690f0ae3a2844adfb2afc2a30a9fbff3eb Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Fri, 18 Aug 2023 09:17:37 -0500 Subject: [PATCH 4/4] comment cleanup --- disk/disk_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 77d7deabd..5015c34ae 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -475,7 +475,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC d.Name = name // Names passed in can be full paths (/dev/sda) or just device names (sda). - // Since `name`` here is already a basename, re-add the /dev path. + // Since `name` here is already a basename, re-add the /dev path. // This is not ideal, but we may break the API by changing how SerialNumberWithContext // works. d.SerialNumber, _ = SerialNumberWithContext(ctx, common.HostDevWithContext(ctx, name))