aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-02-21 21:26:32 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-02-21 21:26:32 +0000
commit6a5b6979c0bb33da004269c8caa64df1876b994a (patch)
tree8884f7679bef0e0baba2f216372577d314113dcd /procps
parent1d3c91f83f285db6df2ea157c654d0d7cf2ae61d (diff)
downloadbusybox-w32-6a5b6979c0bb33da004269c8caa64df1876b994a.tar.gz
busybox-w32-6a5b6979c0bb33da004269c8caa64df1876b994a.tar.bz2
busybox-w32-6a5b6979c0bb33da004269c8caa64df1876b994a.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 git-svn-id: svn://busybox.net/trunk/busybox@377 69ca8d6d-28ef-0310-b511-8ec308f3f277
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}