Subject: Re: ls -lsh
To: None <tech-userlevel@netbsd.org>
From: Jan Schaumann <jschauma@netmeister.org>
List: tech-userlevel
Date: 08/06/2004 14:38:35
--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Bill Studenmund <wrstuden@netbsd.org> wrote:
=20
> > > +		if (f_size) {
> > > +			if (f_humanize) {
> > > +				if ((humanize_number(szbuf, sizeof(szbuf),
> > > +					 1024 * howmany(sp->st_blocks, blocksize),
> >=20
> > As should this
> > 		512 * sp->st_blocks;
>=20
> As above, that's what you need to get the number of bytes consumed on=20
> disk.
>=20
> I think it's wrong to use howmany as above as you will end up computing=
=20
> how many thousands of blocks you are using.
>=20
> I think the right thing might actually be to use howmany(), but=20
> howmany(foo, blocksize >> 9). Then you'll get at the number of "blocksize=
"=20
> blocks you consume on disk.

I don't think you can right-shift the blocksize.  blocksize is a rather
small number, such as '1' or '2'.

What I ment was to use either

	if ((humanize_number(szbuf, sizeof(szbuf),
		512 * st_blocks,

or

	if ((humanize_number(szbuf, sizeof(szbuf),
		howmany(512 * st_blocks, blocksize),


In the first case, we'd always use the actual number of bytes consumed
on disk, regardless of the BLOCKSIZE variable.

The second case takes into account the BLOCKSIZE variable.

> As I look at the code above, I am confused as to what the code is trying=
=20
> to calculate. I don't see why the 1024 * is in there. ??

I was confused.  In fact, I may still be, but I think it's getting
better. ;-)

-Jan

--=20
I seem to be having this tremendous difficulty with my lifestyle.

--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFBE9AqfFtkr68iakwRAiRtAJ9fnDrgC7l0nSu3ctAQkL6KU3sbTACfZgpu
E7KAXkSYhx8LV7AXQZFeUrU=
=Csji
-----END PGP SIGNATURE-----

--huq684BweRXVnRxX--