2018-10-23 12:57:38 +03:00
|
|
|
#include <LibC/stdio.h>
|
|
|
|
#include <LibC/unistd.h>
|
|
|
|
|
|
|
|
int main(int c, char** v)
|
|
|
|
{
|
2018-10-28 16:11:51 +03:00
|
|
|
int fd = open("/proc/summary", O_RDONLY);
|
2018-10-23 12:57:38 +03:00
|
|
|
if (fd == -1) {
|
2018-10-28 12:26:07 +03:00
|
|
|
perror("failed to open /proc/summary");
|
2018-10-23 12:57:38 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
for (;;) {
|
2018-10-23 14:57:17 +03:00
|
|
|
char buf[128];
|
2018-10-23 12:57:38 +03:00
|
|
|
ssize_t nread = read(fd, buf, sizeof(buf));
|
|
|
|
if (nread == 0)
|
|
|
|
break;
|
|
|
|
if (nread < 0) {
|
2018-10-28 12:26:07 +03:00
|
|
|
perror("failed to read");
|
2018-10-23 12:57:38 +03:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
for (ssize_t i = 0; i < nread; ++i) {
|
|
|
|
putchar(buf[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|