Print this page
6623 iostat -exrn has missing comma (field separator) in header
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>

*** 27,36 **** --- 27,37 ---- * rewritten from SunOS 4.1 SID 1.18 89/10/06 */ /* * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 James S. Blachly, MD. All rights reserved. */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h>
*** 1268,1278 **** */ void do_format(void) { ! char header[SMALL_SCRATCH_BUFLEN]; char ch; char iosz; const char *fstr; disk_header[0] = 0; --- 1269,1279 ---- */ void do_format(void) { ! char header[SMALL_SCRATCH_BUFLEN] = {0}; char ch; char iosz; const char *fstr; disk_header[0] = 0;
*** 1281,1292 **** if (do_disk & DISK_ERRORS) { if (do_raw == 0) { (void) sprintf(header, "s/w h/w trn tot "); } else (void) sprintf(header, "s/w,h/w,trn,tot"); ! } else ! *header = NULL; switch (do_disk & DISK_IO_MASK) { case DISK_OLD: if (do_raw == 0) fstr = "%cp%c tp%c serv "; else --- 1282,1292 ---- if (do_disk & DISK_ERRORS) { if (do_raw == 0) { (void) sprintf(header, "s/w h/w trn tot "); } else (void) sprintf(header, "s/w,h/w,trn,tot"); ! } switch (do_disk & DISK_IO_MASK) { case DISK_OLD: if (do_raw == 0) fstr = "%cp%c tp%c serv "; else
*** 1319,1330 **** /* with -r option */ (void) snprintf(disk_header, sizeof (disk_header), "device,r/%c,w/%c,%cr/%c,%cw/%c," "wait,actv,svc_t,%%%%w," ! "%%%%b,%s", ! ch, ch, iosz, ch, iosz, ch, header); } } else { /* with -n option */ if (do_raw == 0) { fstr = " r/%c w/%c %cr/%c " --- 1319,1337 ---- /* with -r option */ (void) snprintf(disk_header, sizeof (disk_header), "device,r/%c,w/%c,%cr/%c,%cw/%c," "wait,actv,svc_t,%%%%w," ! "%%%%b%s%s", ! ch, ch, iosz, ch, iosz, ch, ! *header == '\0' ? "" : ",", ! header); ! /* ! * if no -e flag, header == '\0...' ! * Ternary operator above is to prevent ! * trailing comma in full disk_header ! */ } } else { /* with -n option */ if (do_raw == 0) { fstr = " r/%c w/%c %cr/%c "
*** 1332,1341 **** --- 1339,1360 ---- "%%%%w %%%%b %sdevice"; } else { fstr = "r/%c,w/%c,%cr/%c,%cw/%c," "wait,actv,wsvc_t,asvc_t," "%%%%w,%%%%b,%sdevice"; + /* + * if -rnxe, "tot" (from -e) and + * "device" are run together + * due to lack of trailing comma + * in 'header'. However, adding + * trailing comma to header at + * its definition leads to prob- + * lems elsewhere so it's added + * here in this edge case -rnxe + */ + if (*header != '\0') + (void) strcat(header, ","); } (void) snprintf(disk_header, sizeof (disk_header), fstr, ch, ch, iosz, ch, iosz, ch, header);