Add megabytes display format to free
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Tue Nov 18 21:47:34 UTC 2008
On Tue, Nov 18, 2008 at 10:06:47PM +0100, Tito wrote:
>On Tuesday 18 November 2008 20:01:59 Matthew Hiles wrote:
>> Hello Busybox mailing list:
>>
>> I just joined the mailing list because I'm interested in helping out
>> with busybox.
>>
>> I've been reading TODOs and the bug tracker to find out what I can do.
we have a TODO in the toplevel directory. Worth a read :)
>> I'm not sure how opposed everyone is to feature creep, as I'm sure
>> it's an issue, but one thing that always bothered me when using a
>> busybox system was the lack of the -m option for free.
>>
>> I also checked out the TODO in free about fixing the integer overflow
>> on systems with >4gb of RAM. I tried busybox's free command on a 6 GB
>> system and it did not overflow--it showed exactly the same output as
>> the in-distro free command. Does anyone know what's up with that?
>>
>> The following patch allows free to display in megabytes.
>>
>>
>> --- procps/free.c 2008-11-18 09:08:29.000000000 -0500
>> +++ procps/free.c 2008-11-18 08:06:16.000000000 -0500
>> @@ -46,8 +46,21 @@
>> info.bufferram*=info.mem_unit;
>> }
>>
>> - if (argc > 1 && *argv[1] == '-')
>> - bb_show_usage();
>> + if ( argc > 1 )
>> + {
>> + if ( argv[1][1] == 'm' ) /* I see no point invoking getopt */
>> + { /* or even strcmp for one option */
>> + /* give output in megabytes */
>> + info.totalram /= 1024;
>> + info.freeram /= 1024;
>> + info.sharedram /= 1024;
>> + info.bufferram /= 1024;
>> +#ifndef __uClinux__
>> + info.totalswap /= 1024;
>> + info.freeswap /= 1024;
>> +#endif
>> + } else bb_show_usage();
>> + }
>>
>> printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
>> "shared", "buffers");
>
>Hi,
>you should add -m also to the help text in busybox/include/usage.h
and also post the size(1) output from before and after your patch or
./scripts/bloat-o-meter.
Let me note that we have make_human_readable_str()
cheers,
Bernhard
More information about the busybox
mailing list