2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-02-14 22:29:06 +01:00
|
|
|
#include <AK/ByteBuffer.h>
|
2020-02-06 15:04:03 +01:00
|
|
|
#include <LibCore/File.h>
|
2019-06-07 11:49:31 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <fcntl.h>
|
2019-01-28 22:40:55 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2020-12-20 16:09:48 -07:00
|
|
|
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
|
2019-01-28 22:40:55 +01:00
|
|
|
{
|
2020-01-22 02:34:20 -08:00
|
|
|
if (pledge("stdio rpath", nullptr) < 0) {
|
|
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unveil("/proc/dmesg", "r") < 0) {
|
|
|
|
|
perror("unveil");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unveil(nullptr, nullptr);
|
|
|
|
|
|
2020-02-02 12:34:39 +01:00
|
|
|
auto f = Core::File::construct("/proc/dmesg");
|
2021-05-12 13:56:43 +04:30
|
|
|
if (!f->open(Core::OpenMode::ReadOnly)) {
|
2019-12-31 01:32:57 +01:00
|
|
|
fprintf(stderr, "open: failed to open /proc/dmesg: %s\n", f->error_string());
|
2019-01-28 22:40:55 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
2019-09-21 20:50:06 +02:00
|
|
|
const auto& b = f->read_all();
|
2020-02-20 12:54:15 +01:00
|
|
|
for (size_t i = 0; i < b.size(); ++i)
|
2019-06-02 12:13:06 +02:00
|
|
|
putchar(b[i]);
|
2019-01-28 22:40:55 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|