diff options
author | Eric Andersen | 2000-06-26 10:45:52 +0000 |
---|---|---|
committer | Eric Andersen | 2000-06-26 10:45:52 +0000 |
commit | 10dc9d4d17e6880bfdfd253716ce72ec1243227f (patch) | |
tree | f3c2aa6ab3dadf1b4bf710c7957e72faddebd75f /init | |
parent | 8a24a6783af7a0d54b1f2ebcda5b07757bd19c99 (diff) | |
download | busybox-10dc9d4d17e6880bfdfd253716ce72ec1243227f.zip busybox-10dc9d4d17e6880bfdfd253716ce72ec1243227f.tar.gz |
Updates to handle Linux 2.4.0 kernels (kludged around the "none" entries in
/proc/mounts, added a hack to make sysinfo work with both old and new kernels).
-Erik
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/init/init.c b/init/init.c index 98a58f2..9289b86 100644 --- a/init/init.c +++ b/init/init.c @@ -42,7 +42,6 @@ #include <linux/version.h> #include <linux/reboot.h> #include <linux/unistd.h> -#include <sys/sysinfo.h> /* For check_free_memory() */ #include <sys/fcntl.h> #include <sys/ioctl.h> #include <sys/mount.h> @@ -270,13 +269,28 @@ static int check_free_memory() { struct sysinfo info; + /* Pre initialize mem_unit in case this kernel is something prior to + * the linux 2.4 kernel (which will actually fill in mem_unit... */ sysinfo(&info); if (sysinfo(&info) != 0) { - message(LOG, "Error checking free memory: %s\n", strerror(errno)); + printf("Error checking free memory: %s\n", strerror(errno)); return -1; } + 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; + } - return((info.totalram+info.totalswap)/1024); + return(info.totalram+info.totalswap); } static void console_init() |