summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Burchell <robin+git@viroteck.net>2019-06-02 12:08:47 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-02 12:55:51 +0200
commit7de861bdd93dff92dd2ffa8b7b98ebc625cec003 (patch)
tree05fb72a82e406b38b2be5714482cd0c6bdb40c1d
parent9a4ec2e92a9ed07d776851cb84404cd3260b2f9d (diff)
downloadserenity-7de861bdd93dff92dd2ffa8b7b98ebc625cec003.zip
Userland: Use CFile in mm
-rw-r--r--Userland/mm.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/Userland/mm.cpp b/Userland/mm.cpp
index 1e49f9a011..2a79a55535 100644
--- a/Userland/mm.cpp
+++ b/Userland/mm.cpp
@@ -1,28 +1,20 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
+#include <LibCore/CFile.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");
+
+ CFile f("/proc/mm");
+ if (!f.open(CIODevice::ReadOnly)) {
+ fprintf(stderr, "open: failed to open /proc/mm: %s", f.error_string());
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]);
- }
- }
+ const auto& b = f.read_all();
+ for (auto i = 0; i < b.size(); ++i)
+ putchar(b[i]);
return 0;
}