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

Merge pull request #1508 from gdvalle/gtd.disk.serial-num-fix

fix IOCounters() SerialNumber enumeration
This commit is contained in:
shirou 2023-08-20 22:25:10 +09:00 committed by GitHub
commit 6084c1e2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 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))
d.Label, _ = LabelWithContext(ctx, name)
ret[name] = d