svn commit: r248680 - head/sbin/fsck_ffs

Bruce Evans brde at optusnet.com.au
Sun Mar 24 13:57:26 UTC 2013


On Sun, 24 Mar 2013, Bruce Evans wrote:

> ...
>> -		printf("%21s:%8ld %2ld.%ld%% %4ld.%03ld sec %2lld.%lld%%\n",
>> +		printf("%21s:%8ld %2ld.%ld%% %4jd.%03ld sec %2lld.%lld%%\n",
>> 		    buftype[i], readcnt[i], readcnt[i] * 100 / diskreads,
>> 		    (readcnt[i] * 1000 / diskreads) % 10,
>> -		    readtime[i].tv_sec, readtime[i].tv_nsec / 1000000,
>> +		    (intmax_t)readtime[i].tv_sec, readtime[i].tv_nsec / 
>> 1000000,
>> 		    msec * 100 / totalmsec, (msec * 1000 / totalmsec) % 10);
> ...
> I don't like the poor man's floating point calculations.  Everything is
> easier using floating point.

Don't say that this would use too many resources on embedded systems
:-).  In FreeBSD-2, fsck_ffs has always used floating point for printing
the percentages in its primary statistics (the % fragmentation lines
that are printed for every file system checked by fsck_ffs).  This
wasn't in 4.4BSD (poor man's floating point calculations are used there
too), but it was one of the first things changed in FreeBSD-2 in 1994.
The FreeBSD version used a remnant of the poor man's floating point
calculations at first (a decimal multiplication by 100) at first, but
I changed it in 1997 to do a floating point multiplication.  The decimal
multiplication could have overflowed with today's sized disk on ffs1
(this takes 21+ million frags).

Bruce


More information about the svn-src-all mailing list