diff options
author | adrian <adrian@FreeBSD.org> | 2008-09-11 09:55:54 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2008-09-11 09:55:54 +0000 |
commit | 0d6a982e10174323c8b14954cf327f73604b8453 (patch) | |
tree | 2ddc20017c05216e63ff4bf6e1c6efe48f9e6142 /usr.sbin/iostat/iostat.c | |
parent | 1c6ab85afc0de1e8b733b1378cf1336024da62a1 (diff) | |
download | FreeBSD-src-0d6a982e10174323c8b14954cf327f73604b8453.zip FreeBSD-src-0d6a982e10174323c8b14954cf327f73604b8453.tar.gz |
Fix the device name spacing.
The old logic padded the device name out but assumed the unit number was one digit
long; this fails for things like SATA devices which (for me) begin at ad10.
Assemble the full device name in a temporary buffer and then calcluate padding
based on that string.
Diffstat (limited to 'usr.sbin/iostat/iostat.c')
-rw-r--r-- | usr.sbin/iostat/iostat.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c index d8e0bf4..40d78ab 100644 --- a/usr.sbin/iostat/iostat.c +++ b/usr.sbin/iostat/iostat.c @@ -667,6 +667,7 @@ static void phdr(void) { int i, printed; + char devbuf[256]; /* * If xflag is set, we need a per-loop header, not a page header, so @@ -682,14 +683,13 @@ phdr(void) if ((dev_select[i].selected != 0) && (dev_select[i].selected <= maxshowdevs)) { di = dev_select[i].position; - if (oflag > 0) - (void)printf("%12.6s%d ", + snprintf(devbuf, sizeof(devbuf), "%s%d", cur.dinfo->devices[di].device_name, cur.dinfo->devices[di].unit_number); + if (oflag > 0) + (void)printf("%13.6s ", devbuf); else - printf("%15.6s%d ", - cur.dinfo->devices[di].device_name, - cur.dinfo->devices[di].unit_number); + printf("%16.6s ", devbuf); printed++; } } |