Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 2020 20:46:52 -0700
From:      csjp@ion.sqrt.ca
To:        "Piotr P. Stefaniak" <pstef@freebsd.org>
Cc:        "Christian S.J. Peron" <csjp@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r358181 - head/usr.sbin/pstat
Message-ID:  <20200701034652.GA1094@ion.sqrt.ca>
In-Reply-To: <20200622215315.GC28243@freefall.freebsd.org>
References:  <202002202112.01KLCAKx000852@repo.freebsd.org> <20200622215315.GC28243@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Piotr,

Thanks for the heads up. I will fix this shortly.

On Mon, Jun 22, 2020 at 11:53:15PM +0200, Piotr P. Stefaniak wrote:
> On 2020-02-20 21:12:10, Christian S.J. Peron wrote:
> >Author: csjp
> >Date: Thu Feb 20 21:12:10 2020
> >New Revision: 358181
> >URL: https://svnweb.freebsd.org/changeset/base/358181
> >
> >Log:
> > - Implement -h (human readable) for the size of the underlying block disk.
> >   Currently, the size of the swap device is unconditionally reported using
> >   blocks, even if -h has been used.
> > - While here, switch to CONVERT_BLOCKS() instead of CONVERT() which will
> >   avoid overflowing size counters (in human readable form see: r196244)
> > - Update the column headers to reflect that a size is being reported instead
> >   of the block size units being used
> >
> > Before:
> >
> > $ swapinfo
> > Device          1K-blocks     Used    Avail Capacity
> > /dev/gpt/swapfs   1048576        0  1048576     0%
> 
> In the above, the "1K-blocks" and "1048576" line up because both the
> header and the value have field width of hlen which is always set by
> getbsize(&hlen, &blocksize). In other words, the header name sets the
> width for the column. It is especially apparent when you compare output
> with BLOCKSIZE=1000000000 and BLOCKSIZE=1K.
> 
> > After:
> >
> > $ swapinfo -h
> > Device           Size     Used    Avail Capacity
> > /dev/gpt/swapfs    1.0G       0B     1.0G     0%
> 
> Here the width for the header is sizeof "Size" and the width for values
> of the size is 8, so the header and the values don't make up a column.
> 
> Since field width for all values of Size, Used, and Avail are hardcoded
> to 8 as well as the column headers, I think the best suggestion I can
> give is to change it like this:
> 
> @@ -475,7 +475,7 @@ print_swap_header(void)
>         if (humanflag) {
>                 header = SIZEHDR;
> -               hlen = sizeof(SIZEHDR);
> +               hlen = 8; /* as the hardcoded field width of values */
>         } else {
>                 header = getbsize(&hlen, &blocksize);
>         }
> 
> Although 8 seems to me a bit high. And too bad that humanize_number() is
> locale-agnostic.
> 
> > Differential Revision:	https://reviews.freebsd.org/D23758
> > Reviewed by:	kevans
> > MFC after:	3 weeks
> >
> >Modified:
> > head/usr.sbin/pstat/pstat.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200701034652.GA1094>