ladybird/Userland/Utilities/dmesg.cpp

22 lines
588 B
C++
Raw Normal View History

/*
2021-11-23 17:44:17 +03:00
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/File.h>
2021-11-23 17:44:17 +03:00
#include <LibCore/System.h>
#include <LibMain/Main.h>
2021-11-23 17:44:17 +03:00
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"));
TRY(Core::System::unveil("/sys/kernel/dmesg", "r"));
2021-11-23 17:44:17 +03:00
TRY(Core::System::unveil(nullptr, nullptr));
2020-01-22 13:34:20 +03:00
auto file = TRY(Core::File::open("/sys/kernel/dmesg"sv, Core::File::OpenMode::Read));
auto buffer = TRY(file->read_until_eof());
2021-11-23 17:44:17 +03:00
out("{}", StringView { buffer });
return 0;
}