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-06 15:04:03 +01:00
|
|
|
#include <LibCore/File.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);
|
|
|
|
|
2021-05-31 15:43:25 +01:00
|
|
|
auto file = Core::File::construct("/proc/dmesg");
|
|
|
|
if (!file->open(Core::OpenMode::ReadOnly)) {
|
|
|
|
warnln("Failed to open {}: {}", file->name(), file->error_string());
|
2019-01-28 22:40:55 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2021-05-31 15:43:25 +01:00
|
|
|
auto buffer = file->read_all();
|
|
|
|
out("{}", String::copy(buffer));
|
2019-01-28 22:40:55 +01:00
|
|
|
return 0;
|
|
|
|
}
|