blob: 6ddf7c431b5e0c9201494f3531ac903d1a19278e (
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
29
30
31
32
33
34
35
36
37
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteBuffer.h>
#include <LibCore/File.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
if (pledge("stdio rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/proc/dmesg", "r") < 0) {
perror("unveil");
return 1;
}
unveil(nullptr, nullptr);
auto f = Core::File::construct("/proc/dmesg");
if (!f->open(Core::OpenMode::ReadOnly)) {
fprintf(stderr, "open: failed to open /proc/dmesg: %s\n", f->error_string());
return 1;
}
const auto& b = f->read_all();
for (size_t i = 0; i < b.size(); ++i)
putchar(b[i]);
return 0;
}
|