[BusyBox] init: sysinfo [PATCH]

Jason Schoon floydpink at gmail.com
Tue Jul 5 13:09:21 UTC 2005


I would agree with addition of a config option, rather than a unconditional 
call to check_memory(). None of my embedded systems use swap, so attempting 
to swapon will be of no use.

Granted, I really don't want to be starting the system with less than a meg 
of RAM, but swapon() wouldn't fix the problem either.


On 7/4/05, Shaun Jackman <sjackman at gmail.com> wrote:
> 
> init uses sysinfo to check if the amount of memory is less than one
> megabyte, and if so attempts to swapon.
> 
> According to the sysinfo(2) man page...
> This function is Linux-specific, and should not be used in pro-
> grams intended to be portable.
> 
> So I suggest armouring its use in an ifdef. I used ifdef
> _LINUX_TYPES_H, but I'd like to hear any suggestions of a better test.
> 
> I find altering the behaviour of init based on the amount of installed
> memory a bit of a hack though. I'd rather see check_memory removed
> altogether. If the swapon functionality of init is useful to people,
> perhaps a swapon switch to init would be called for.
> 
> Cheers,
> Shaun
> 
> --- init/init.c
> +++ init/init.c
> @@ -312,6 +312,7 @@
> Units are kBytes to avoid overflow on 4GB machines */
> static unsigned int check_free_memory(void)
> {
> +#ifdef _LINUX_TYPES_H
> struct sysinfo info;
> unsigned int result, u, s = 10;
> 
> @@ -335,6 +336,11 @@
> } else {
> return(result * u);
> }
> +#else
> + // check_memory attempts to swapon if there's less than a megabyte
> + // of free memory, so tell it we have more than that.
> + return 1001;
> +#endif /* _LINUX_TYPES_H */
> }
> 
> static void console_init(void)
> _______________________________________________
> busybox mailing list
> busybox at mail.busybox.net
> http://busybox.net/mailman/listinfo/busybox
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20050705/221364e6/attachment-0002.htm 


More information about the busybox mailing list