ladybird/Userland/Utilities/dmesg.cpp

22 lines
600 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
*/
2022-09-14 13:57:31 +03:00
#include <LibCore/Stream.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
2022-09-14 13:57:31 +03:00
auto file = TRY(Core::Stream::File::open("/sys/kernel/dmesg"sv, Core::Stream::OpenMode::Read));
auto buffer = TRY(file->read_until_eof());
2021-11-23 17:44:17 +03:00
out("{}", StringView { buffer });
return 0;
}