aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-09-10 16:10:41 +0000
committerEric Andersen <andersen@codepoet.org>2000-09-10 16:10:41 +0000
commit73de6561cae5e8707f66ba08203c082cd86e9850 (patch)
tree33945d4d5824736ea2f36d742bb145a24d0d3386
parent729216cb11f263d16bc7322788842234642ab6ab (diff)
downloadbusybox-w32-73de6561cae5e8707f66ba08203c082cd86e9850.tar.gz
busybox-w32-73de6561cae5e8707f66ba08203c082cd86e9850.tar.bz2
busybox-w32-73de6561cae5e8707f66ba08203c082cd86e9850.zip
Update free for current 2.4.x behavior...
-Erik
-rw-r--r--free.c34
-rw-r--r--procps/free.c34
2 files changed, 26 insertions, 42 deletions
diff --git a/free.c b/free.c
index 78298cfb6..d8c3f0b91 100644
--- a/free.c
+++ b/free.c
@@ -29,29 +29,21 @@ extern int free_main(int argc, char **argv)
29{ 29{
30 struct sysinfo info; 30 struct sysinfo info;
31 sysinfo(&info); 31 sysinfo(&info);
32 /* Kernels prior to 2.4.x will return info.mem_unit==0. Kernels after 32
33 * 2.4.x actually fill this value in */ 33 /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */
34 if (info.mem_unit==0) { 34 if (info.mem_unit==0) {
35 /* Looks like we have a kernel prior to Linux 2.4.x */ 35 info.mem_unit=1;
36 info.mem_unit=1024;
37 info.totalram/=info.mem_unit;
38 info.freeram/=info.mem_unit;
39 info.totalswap/=info.mem_unit;
40 info.freeswap/=info.mem_unit;
41 info.sharedram/=info.mem_unit;
42 info.bufferram/=info.mem_unit;
43 } else {
44 /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory
45 overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap
46 on an embedded system? */
47 info.mem_unit/=1024;
48 info.totalram*=info.mem_unit;
49 info.freeram*=info.mem_unit;
50 info.totalswap*=info.mem_unit;
51 info.freeswap*=info.mem_unit;
52 info.sharedram*=info.mem_unit;
53 info.bufferram*=info.mem_unit;
54 } 36 }
37 info.mem_unit*=1024;
38
39 /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
40 info.totalram/=info.mem_unit;
41 info.freeram/=info.mem_unit;
42 info.totalswap/=info.mem_unit;
43 info.freeswap/=info.mem_unit;
44 info.sharedram/=info.mem_unit;
45 info.bufferram/=info.mem_unit;
46
55 if (argc > 1 && **(argv + 1) == '-') 47 if (argc > 1 && **(argv + 1) == '-')
56 usage(free_usage); 48 usage(free_usage);
57 49
diff --git a/procps/free.c b/procps/free.c
index 78298cfb6..d8c3f0b91 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -29,29 +29,21 @@ extern int free_main(int argc, char **argv)
29{ 29{
30 struct sysinfo info; 30 struct sysinfo info;
31 sysinfo(&info); 31 sysinfo(&info);
32 /* Kernels prior to 2.4.x will return info.mem_unit==0. Kernels after 32
33 * 2.4.x actually fill this value in */ 33 /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */
34 if (info.mem_unit==0) { 34 if (info.mem_unit==0) {
35 /* Looks like we have a kernel prior to Linux 2.4.x */ 35 info.mem_unit=1;
36 info.mem_unit=1024;
37 info.totalram/=info.mem_unit;
38 info.freeram/=info.mem_unit;
39 info.totalswap/=info.mem_unit;
40 info.freeswap/=info.mem_unit;
41 info.sharedram/=info.mem_unit;
42 info.bufferram/=info.mem_unit;
43 } else {
44 /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory
45 overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap
46 on an embedded system? */
47 info.mem_unit/=1024;
48 info.totalram*=info.mem_unit;
49 info.freeram*=info.mem_unit;
50 info.totalswap*=info.mem_unit;
51 info.freeswap*=info.mem_unit;
52 info.sharedram*=info.mem_unit;
53 info.bufferram*=info.mem_unit;
54 } 36 }
37 info.mem_unit*=1024;
38
39 /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
40 info.totalram/=info.mem_unit;
41 info.freeram/=info.mem_unit;
42 info.totalswap/=info.mem_unit;
43 info.freeswap/=info.mem_unit;
44 info.sharedram/=info.mem_unit;
45 info.bufferram/=info.mem_unit;
46
55 if (argc > 1 && **(argv + 1) == '-') 47 if (argc > 1 && **(argv + 1) == '-')
56 usage(free_usage); 48 usage(free_usage);
57 49