summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorErik Andersen2000-02-21 21:26:32 +0000
committerErik Andersen2000-02-21 21:26:32 +0000
commitd07ee46919e3a8e42b3a8735e1152cc050165934 (patch)
tree8884f7679bef0e0baba2f216372577d314113dcd /procps
parentfa4718efcf055d8720ea99be1af237a921232f5a (diff)
downloadbusybox-d07ee46919e3a8e42b3a8735e1152cc050165934.zip
busybox-d07ee46919e3a8e42b3a8735e1152cc050165934.tar.gz
Removed proc dependancies for init and free (which maintaining exactly
the same functionality). /proc takes up 90k of kernel space, so it is nice to avoid using it at all costs. The only places where it is depended on is for cetain optional mount/umount features, and for ps and lsmod. -Erik
Diffstat (limited to 'procps')
-rw-r--r--procps/free.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/procps/free.c b/procps/free.c
index b071354..78a36fe 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -23,15 +23,33 @@
#include "internal.h"
#include <stdio.h>
+#include <sys/sysinfo.h>
-
-#if ! defined BB_FEATURE_USE_PROCFS
-#error Sorry, I depend on the /proc filesystem right now.
-#endif
-
+#define DIVISOR 1024
extern int free_main(int argc, char **argv)
{
- char *cmd[] = { "cat", "/proc/meminfo", "\0" };
+ struct sysinfo info;
+ sysinfo(&info);
+ info.totalram/=DIVISOR;
+ info.freeram/=DIVISOR;
+ info.totalswap/=DIVISOR;
+ info.freeswap/=DIVISOR;
+ info.sharedram/=DIVISOR;
+ info.bufferram/=DIVISOR;
+
+
+ printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
+ "shared", "buffers");
+
+ printf("%6s%13ld%13ld%13ld%13ld%13ld\n", "Mem:", info.totalram,
+ info.totalram-info.freeram, info.freeram,
+ info.sharedram, info.bufferram);
+
+ printf("%6s%13ld%13ld%13ld\n", "Swap:", info.totalswap,
+ info.totalswap-info.freeswap, info.freeswap);
- exit(cat_main(3, cmd));
+ printf("%6s%13ld%13ld%13ld\n", "Total:", info.totalram+info.totalswap,
+ (info.totalram-info.freeram)+(info.totalswap-info.freeswap),
+ info.freeram+info.freeswap);
+ exit(TRUE);
}