On Sat, May 17, 2008 at 06:46:23PM +0200, Bastian Bittorf wrote:
> wouldt it be better (for understanding) to do something like:
> 
> while read NUL MEM NUL; do
>       [ "$MEM" != "used:" ] && {
>               MEM=$(( $MEM / 2 ))             # filling var MEM with
>               break                           # the half of the avail mem 
> [bytes]
>       }
> done </proc/meminfo

That's a gross over simplification of what the line actually does, and
it's slightly insulting that the simplfied version still requires
comments.

The awk line in question returns half of the available memory, but with
the condition that it must leave atleast 5M available outside of tmpfs.
This is done so that devices which only have 8M of memory can still be
used in a limited capacity -- devices with only 8M ram tend to have only
2M of flash, which causes other complications.

While the preinit script could be rewritten in various ways, there's
really not much point. Readability is only a concern in scripts which
may need to be modified by the end user; preinit is executed from a
readonly partition on most systems, requiring the firmware to be
recompiled to change it.
_______________________________________________
openwrt-devel mailing list
[email protected]
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to