[Toybox] New toy: vmstat

Rob Landley rob at landley.net
Mon Apr 9 22:56:13 PDT 2012


On 04/09/2012 06:39 AM, Elie De Brauwer wrote:
> Hello all,
> 
> In attachment you can find a no-nonsense vmstat implementation. Meaning
> most of the special things (which I personally never bothered to use)
> are dropped. (vmstat -d however is still under consideration, please
> shout if you're waiting for a vmstat -d or any other options).

Yay!  Applied.

You're reading multiple things into toybuf and apparently relying on the
existing prezeroed nature of toybuf to provide your null terminator, but
if the second thing you read in is shorter than your first and the file
you're reading in doesn't end with a null you'll have extra leftover
garbage from the previous file.

I'm not sure the fdlength() check and error_exit() buy you anything more
than just read(sizeof(toybuf)-1) would?  If you miss some data at the
end, most likely it'll still work and the current sizes on my box are
all ~1.5k vs 4k buffer size. (It is theorentically possible a number
could get truncated at EOF and thus be viewed as the wrong value, but
even on systems with terabytes of memory I don't see the numbers growing
enough to bring us to 3k, and I believe new fields get added at the
_end_ of the file for backwards compatability reasons...)

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.

 1334037373.0


More information about the Toybox mailing list