summaryrefslogtreecommitdiff
path: root/Userland/mm.cpp
blob: 1e49f9a01134498ac26234ae464cfec8c315ae80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char** argv)
{
    (void) argc;
    (void) argv;
    int fd = open("/proc/mm", O_RDONLY);
    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;
}