aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-02-21 21:26:32 +0000
committerErik Andersen <andersen@codepoet.org>2000-02-21 21:26:32 +0000
commitd07ee46919e3a8e42b3a8735e1152cc050165934 (patch)
tree8884f7679bef0e0baba2f216372577d314113dcd /procps
parentfa4718efcf055d8720ea99be1af237a921232f5a (diff)
downloadbusybox-w32-d07ee46919e3a8e42b3a8735e1152cc050165934.tar.gz
busybox-w32-d07ee46919e3a8e42b3a8735e1152cc050165934.tar.bz2
busybox-w32-d07ee46919e3a8e42b3a8735e1152cc050165934.zip
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 b07135430..78a36fe9a 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -23,15 +23,33 @@
23 23
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26#include <sys/sysinfo.h>
26 27
27 28#define DIVISOR 1024
28#if ! defined BB_FEATURE_USE_PROCFS
29#error Sorry, I depend on the /proc filesystem right now.
30#endif
31
32extern int free_main(int argc, char **argv) 29extern int free_main(int argc, char **argv)
33{ 30{
34 char *cmd[] = { "cat", "/proc/meminfo", "\0" }; 31 struct sysinfo info;
32 sysinfo(&info);
33 info.totalram/=DIVISOR;
34 info.freeram/=DIVISOR;
35 info.totalswap/=DIVISOR;
36 info.freeswap/=DIVISOR;
37 info.sharedram/=DIVISOR;
38 info.bufferram/=DIVISOR;
39
40
41 printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
42 "shared", "buffers");
43
44 printf("%6s%13ld%13ld%13ld%13ld%13ld\n", "Mem:", info.totalram,
45 info.totalram-info.freeram, info.freeram,
46 info.sharedram, info.bufferram);
47
48 printf("%6s%13ld%13ld%13ld\n", "Swap:", info.totalswap,
49 info.totalswap-info.freeswap, info.freeswap);
35 50
36 exit(cat_main(3, cmd)); 51 printf("%6s%13ld%13ld%13ld\n", "Total:", info.totalram+info.totalswap,
52 (info.totalram-info.freeram)+(info.totalswap-info.freeswap),
53 info.freeram+info.freeswap);
54 exit(TRUE);
37} 55}