1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-12 14:29:28 +00:00

Fixed segfault when more then four devices are specified (improper free),

fixed variable so all manually-specified devices are shown rather then
    cutting the display off at 3, fixed formatting for msps when msps is
    larger then 100 (it was blowing the columner display output before),
    added -K option to make blk count (-oIK) force a 1K block size (to conform
    more closely to systat, vmstat definition of blocksize).
This commit is contained in:
Matthew Dillon 1998-09-16 18:03:44 +00:00
parent 51a6f39df6
commit 2fa4aaa07a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39371
2 changed files with 26 additions and 13 deletions

View File

@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id$
.\" $Id: iostat.8,v 1.5 1998/09/15 08:16:45 gibbs Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -70,7 +70,7 @@
statistics
.Sh SYNOPSIS
.Nm iostat
.Op Fl CdhIoT?
.Op Fl CdhKIoT?
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl n Ar devs
@ -109,6 +109,9 @@ Put iostat in
.Sq top
mode. In this mode, iostat will show devices in order from highest to
lowest bytes per measurement cycle.
.It Fl K
In the blocks transfered display (-o), display block count in kilobytes rather
then the device native block size.
.It Fl I
Display total statstics for a given time period, rather than average
statistics for each second during that time period.

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: iostat.c,v 1.9 1998/09/15 08:16:45 gibbs Exp $
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@ -135,7 +135,7 @@ struct statinfo cur, last;
int num_devices;
struct device_selection *dev_select;
int maxshowdevs;
int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0;
int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
#define nlread(x, v) \
kvm_read(kd, namelist[x].n_value, &(v), sizeof(v))
@ -184,7 +184,7 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
while ((c = getopt(argc, argv, "c:CdhIM:n:N:ot:Tw:?")) != -1) {
while ((c = getopt(argc, argv, "c:CdhKIM:n:N:ot:Tw:?")) != -1) {
switch(c) {
case 'c':
cflag++;
@ -201,6 +201,9 @@ main(int argc, char **argv)
case 'h':
hflag++;
break;
case 'K':
Kflag++;
break;
case 'I':
Iflag++;
break;
@ -314,6 +317,8 @@ main(int argc, char **argv)
specified_devices[num_devices_specified - 1] = *argv;
}
if (nflag == 0 && maxshowdevs < num_devices_specified)
maxshowdevs = num_devices_specified;
dev_select = NULL;
@ -335,8 +340,6 @@ main(int argc, char **argv)
select_mode, maxshowdevs, hflag) == -1)
errx(1, "%s", devstat_errbuf);
free(specified_devices);
/*
* Look for the traditional wait time and count arguments.
*/
@ -554,17 +557,17 @@ phdr(int signo)
for (i=0, printed = 0;(i < num_devices) && (printed < maxshowdevs);i++){
if ((dev_select[i].selected != 0)
&& (dev_select[i].selected <= maxshowdevs)) {
if (oflag > 0)
if (oflag > 0) {
if (Iflag == 0)
(void)printf(" sps tps msps ");
else
(void)printf(" blk xfr msps ");
else
} else {
if (Iflag == 0)
printf(" KB/t tps MB/s ");
else
printf(" KB/t xfrs MB ");
}
printed++;
}
}
@ -616,20 +619,27 @@ devstats(int perf_select)
continue;
}
if (Kflag) {
int block_size = cur.dinfo->devices[di].block_size;
total_blocks = total_blocks * (block_size ? block_size : 512) / 1024;
}
if (oflag > 0) {
int msdig = (ms_per_transaction < 100.0) ? 1 : 0;
if (Iflag == 0)
printf("%4.0Lf%4.0Lf%5.1Lf ",
printf("%4.0Lf%4.0Lf%5.*Lf ",
blocks_per_second,
transfers_per_second,
msdig,
ms_per_transaction);
else
printf("%4.1qu%4.1qu%5.1Lf ",
printf("%4.1qu%4.1qu%5.*Lf ",
total_blocks,
total_transfers,
msdig,
ms_per_transaction);
} else {
if (Iflag == 0)
printf(" %5.2Lf %3.0Lf %5.2Lf ",
kb_per_transfer,