mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 21:25:07 +00:00

This shows some info about the MM. Right now it's just the zone count and the number of free physical pages. Lots more can be added. Also added "exit" to sh so we can nest shells and exit from them. I also noticed that we were leaking all the physical pages, so fixed that.
25 lines
531 B
C++
25 lines
531 B
C++
#include <LibC/stdio.h>
|
|
#include <LibC/unistd.h>
|
|
|
|
int main(int c, char** v)
|
|
{
|
|
int fd = open("/proc/mm");
|
|
if (fd == -1) {
|
|
perror("failed to open /proc/mm");
|
|
return 1;
|
|
}
|
|
for (;;) {
|
|
char buf[128];
|
|
ssize_t nread = read(fd, buf, sizeof(buf));
|
|
if (nread == 0)
|
|
break;
|
|
if (nread < 0) {
|
|
perror("failed to read");
|
|
return 2;
|
|
}
|
|
for (ssize_t i = 0; i < nread; ++i) {
|
|
putchar(buf[i]);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|