diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-06-26 10:45:52 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-06-26 10:45:52 +0000 |
commit | 10dc9d4d17e6880bfdfd253716ce72ec1243227f (patch) | |
tree | f3c2aa6ab3dadf1b4bf710c7957e72faddebd75f /init | |
parent | 8a24a6783af7a0d54b1f2ebcda5b07757bd19c99 (diff) | |
download | busybox-w32-10dc9d4d17e6880bfdfd253716ce72ec1243227f.tar.gz busybox-w32-10dc9d4d17e6880bfdfd253716ce72ec1243227f.tar.bz2 busybox-w32-10dc9d4d17e6880bfdfd253716ce72ec1243227f.zip |
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 98a58f275..9289b86a6 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/version.h> | 42 | #include <linux/version.h> |
43 | #include <linux/reboot.h> | 43 | #include <linux/reboot.h> |
44 | #include <linux/unistd.h> | 44 | #include <linux/unistd.h> |
45 | #include <sys/sysinfo.h> /* For check_free_memory() */ | ||
46 | #include <sys/fcntl.h> | 45 | #include <sys/fcntl.h> |
47 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
48 | #include <sys/mount.h> | 47 | #include <sys/mount.h> |
@@ -270,13 +269,28 @@ static int check_free_memory() | |||
270 | { | 269 | { |
271 | struct sysinfo info; | 270 | struct sysinfo info; |
272 | 271 | ||
272 | /* Pre initialize mem_unit in case this kernel is something prior to | ||
273 | * the linux 2.4 kernel (which will actually fill in mem_unit... */ | ||
273 | sysinfo(&info); | 274 | sysinfo(&info); |
274 | if (sysinfo(&info) != 0) { | 275 | if (sysinfo(&info) != 0) { |
275 | message(LOG, "Error checking free memory: %s\n", strerror(errno)); | 276 | printf("Error checking free memory: %s\n", strerror(errno)); |
276 | return -1; | 277 | return -1; |
277 | } | 278 | } |
279 | if (info.mem_unit==0) { | ||
280 | /* Looks like we have a kernel prior to Linux 2.4.x */ | ||
281 | info.mem_unit=1024; | ||
282 | info.totalram/=info.mem_unit; | ||
283 | info.totalswap/=info.mem_unit; | ||
284 | } else { | ||
285 | /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory | ||
286 | overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap | ||
287 | on an embedded system? */ | ||
288 | info.mem_unit/=1024; | ||
289 | info.totalram*=info.mem_unit; | ||
290 | info.totalswap*=info.mem_unit; | ||
291 | } | ||
278 | 292 | ||
279 | return((info.totalram+info.totalswap)/1024); | 293 | return(info.totalram+info.totalswap); |
280 | } | 294 | } |
281 | 295 | ||
282 | static void console_init() | 296 | static void console_init() |