Subject: Re: ls -lsh
To: None <tech-userlevel@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-userlevel
Date: 08/06/2004 10:14:00
--E39vaYmALEf/7YXx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Aug 06, 2004 at 10:00:04AM -0400, Jan Schaumann wrote:
> Jan Schaumann <jschauma@netmeister.org> wrote:
>=20
> > + if (f_size)=20
> > + total =3D 1024 * howmany(dp->btotal, blocksize);
>=20
> Actually, I think this should be
> =09
> total =3D 512 * dp->btotal;
btotal comes from struct stat, yes, you should multiply it by 512 to get=20
the number of bytes.
> > + 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;
As above, that's what you need to get the number of bytes consumed on=20
disk.
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.
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.
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. ??
Take care,
Bill
--E39vaYmALEf/7YXx
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFBE7xYWz+3JHUci9cRAidCAJ4763sNFg493wFEKo0E6RUBQyVADQCfVon8
MiamlGsbbjkpmSMsUscnhqU=
=ekdH
-----END PGP SIGNATURE-----
--E39vaYmALEf/7YXx--