ref: 5ed8d825c11f41aadedf4b88eba6364dc955f52f
parent: 8b4726ff2f15028c71b93aafb02b378898edb802
author: mkf <mkf@cloud9p.org>
date: Tue Nov 28 21:30:38 EST 2023
cmd/memory: import
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@
cmd/cal.o\
cmd/ls.o\
cmd/reboot.o\
+ cmd/memory.o\
L = \
libc/strlen.o\
--- /dev/null
+++ b/cmd/memory.c
@@ -1,0 +1,26 @@
+#include <u.h>
+#include <libc.h>
+
+#include <mem.h>
+#include <err.h>
+
+int
+memory_main(int argc, char **argv, char *cwd)
+{
+ int free, taken;
+
+
+ free = 0;
+ taken = 0;
+ for(int i = 0 ; i < sizeof(memap) ; i++)
+ {
+ if(memap[i] == FREE)
+ free++;
+ else
+ taken++;
+ }
+
+ printf("free memory: %dB\t", free * BLOCKSIZE);
+ printf("taken memory: %dB\n", taken * BLOCKSIZE);
+ return OK;
+}
--- a/cmd/rc.h
+++ b/cmd/rc.h
@@ -7,6 +7,7 @@
int cal_main(int, char**, char *cwd);
int ls_main(int, char**, char *cwd);
int reboot_main(int, char**, char *cwd);
+int memory_main(int, char**, char *cwd);
static prog_t cmdtab[] =
{
@@ -15,5 +16,6 @@
{"check", check_main},
{"cal", cal_main},
{"ls", ls_main},
- {"reboot", reboot_main}
+ {"reboot", reboot_main},
+ {"memory", memory_main},
};