From fb9d72e60d10e4d14b5b828c250a91cf7640f7bd Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 6 Feb 2007 20:29:40 +0000 Subject: Make iostat(8) fully work on crash dumps again (broken since 5.0): - Pass the address of the variable we are reading to kvm_read() rather than the index into the nlist array. - Properly report errors from kvm_read() which returns -1 on error, not 0. MFC after: 3 days --- usr.sbin/iostat/iostat.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'usr.sbin/iostat') diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c index 01c8c69..7446780 100644 --- a/usr.sbin/iostat/iostat.c +++ b/usr.sbin/iostat/iostat.c @@ -823,15 +823,16 @@ readvar(kvm_t *kd, const char *name, int nlid, void *ptr, size_t len) if (kd != NULL) { ssize_t nbytes; - nbytes = kvm_read(kd, nlid, ptr, len); + nbytes = kvm_read(kd, namelist[nlid].n_value, ptr, len); - if (nbytes == 0) { - warnx("kvm_read(%s): %s", name, kvm_geterr(kd)); + if (nbytes < 0) { + warnx("kvm_read(%s): %s", namelist[nlid].n_name, + kvm_geterr(kd)); return (1); } if (nbytes != len) { - warnx("kvm_read(%s): expected %lu bytes, got %ld bytes", - name, (unsigned long)len, (long)nbytes); + warnx("kvm_read(%s): expected %zu bytes, got %zd bytes", + namelist[nlid].n_name, len, nbytes); return (1); } } else { -- cgit v1.1