diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-09-10 16:13:41 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-09-10 16:13:41 +0000 |
commit | cbb61c78ae97e5e205cb4403f4f458a36ffec582 (patch) | |
tree | 291171dd2b4184f214acb798c0fa6ffce2b938e3 | |
parent | 73de6561cae5e8707f66ba08203c082cd86e9850 (diff) | |
download | busybox-cbb61c78ae97e5e205cb4403f4f458a36ffec582.tar.gz |
Make init handle current 2.4.x sysinfo behavior
-Erik
-rw-r--r-- | init.c | 21 | ||||
-rw-r--r-- | init/init.c | 21 |
2 files changed, 18 insertions, 24 deletions
@@ -296,20 +296,17 @@ static int check_free_memory() printf("Error checking free memory: %s\n", strerror(errno)); return -1; } + /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */ if (info.mem_unit==0) { - /* Looks like we have a kernel prior to Linux 2.4.x */ - info.mem_unit=1024; - info.totalram/=info.mem_unit; - info.totalswap/=info.mem_unit; - } else { - /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory - overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap - on an embedded system? */ - info.mem_unit/=1024; - info.totalram*=info.mem_unit; - info.totalswap*=info.mem_unit; + info.mem_unit=1; } - + info.mem_unit*=1024; + + /* Note: These values can in theory overflow a 32 bit unsigned long (i.e. + * mem >= Gib), but who puts more then 4GiB ram+swap on an embedded + * system? */ + info.totalram/=info.mem_unit; + info.totalswap/=info.mem_unit; return(info.totalram+info.totalswap); } diff --git a/init/init.c b/init/init.c index 91a72550b..b532ea88f 100644 --- a/init/init.c +++ b/init/init.c @@ -296,20 +296,17 @@ static int check_free_memory() printf("Error checking free memory: %s\n", strerror(errno)); return -1; } + /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */ if (info.mem_unit==0) { - /* Looks like we have a kernel prior to Linux 2.4.x */ - info.mem_unit=1024; - info.totalram/=info.mem_unit; - info.totalswap/=info.mem_unit; - } else { - /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory - overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap - on an embedded system? */ - info.mem_unit/=1024; - info.totalram*=info.mem_unit; - info.totalswap*=info.mem_unit; + info.mem_unit=1; } - + info.mem_unit*=1024; + + /* Note: These values can in theory overflow a 32 bit unsigned long (i.e. + * mem >= Gib), but who puts more then 4GiB ram+swap on an embedded + * system? */ + info.totalram/=info.mem_unit; + info.totalswap/=info.mem_unit; return(info.totalram+info.totalswap); } |