summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorEric Andersen2003-01-11 20:40:49 +0000
committerEric Andersen2003-01-11 20:40:49 +0000
commit1dcf218e60849b58b1efa7ce43cf0c4e14f95617 (patch)
treedb0f8169a80bae8a1af4a2a9eed91fbfc7fd23e6 /procps
parent575c78274a7458cc9459c6e07c5ff33a103c3f3c (diff)
downloadbusybox-1dcf218e60849b58b1efa7ce43cf0c4e14f95617.zip
busybox-1dcf218e60849b58b1efa7ce43cf0c4e14f95617.tar.gz
Patch from Daniel J Walsh at redhat to make free work for systems
with more than 1 GB of memory...
Diffstat (limited to 'procps')
-rw-r--r--procps/free.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/procps/free.c b/procps/free.c
index cdc0d35..4a5469b 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -37,15 +37,30 @@ extern int free_main(int argc, char **argv)
if (info.mem_unit==0) {
info.mem_unit=1;
}
- info.mem_unit*=1024;
-
- /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
- info.totalram/=info.mem_unit;
- info.freeram/=info.mem_unit;
- info.totalswap/=info.mem_unit;
- info.freeswap/=info.mem_unit;
- info.sharedram/=info.mem_unit;
- info.bufferram/=info.mem_unit;
+ if ( info.mem_unit == 1 ) {
+ info.mem_unit=1024;
+
+ /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
+ info.totalram/=info.mem_unit;
+ info.freeram/=info.mem_unit;
+#ifndef __uClinux__
+ info.totalswap/=info.mem_unit;
+ info.freeswap/=info.mem_unit;
+#endif
+ info.sharedram/=info.mem_unit;
+ info.bufferram/=info.mem_unit;
+ } else {
+ info.mem_unit/=1024;
+ /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
+ info.totalram*=info.mem_unit;
+ info.freeram*=info.mem_unit;
+#ifndef __uClinux__
+ info.totalswap*=info.mem_unit;
+ info.freeswap*=info.mem_unit;
+#endif
+ info.sharedram*=info.mem_unit;
+ info.bufferram*=info.mem_unit;
+ }
if (argc > 1 && **(argv + 1) == '-')
show_usage();
@@ -57,13 +72,14 @@ extern int free_main(int argc, char **argv)
info.totalram-info.freeram, info.freeram,
info.sharedram, info.bufferram);
+#ifndef __uClinux__
printf("%6s%13ld%13ld%13ld\n", "Swap:", info.totalswap,
info.totalswap-info.freeswap, info.freeswap);
printf("%6s%13ld%13ld%13ld\n", "Total:", info.totalram+info.totalswap,
(info.totalram-info.freeram)+(info.totalswap-info.freeswap),
info.freeram+info.freeswap);
+#endif
return EXIT_SUCCESS;
}
-