mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
dmesg: Port to LibMain :^)
This commit is contained in:
parent
e6579e7029
commit
6386b54746
Notes:
sideshowbarker
2024-07-18 00:47:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6386b54746a
2 changed files with 10 additions and 21 deletions
|
@ -61,6 +61,7 @@ target_link_libraries(config LibConfig)
|
|||
target_link_libraries(copy LibGUI)
|
||||
target_link_libraries(diff LibDiff)
|
||||
target_link_libraries(disasm LibX86)
|
||||
target_link_libraries(dmesg LibMain)
|
||||
target_link_libraries(expr LibRegex)
|
||||
target_link_libraries(fdtdump LibDeviceTree)
|
||||
target_link_libraries(file LibGfx LibIPC LibCompress)
|
||||
|
|
|
@ -1,33 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/File.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath", nullptr));
|
||||
TRY(Core::System::unveil("/proc/dmesg", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
if (unveil("/proc/dmesg", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
auto file = Core::File::construct("/proc/dmesg");
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
warnln("Failed to open {}: {}", file->name(), file->error_string());
|
||||
return 1;
|
||||
}
|
||||
auto file = TRY(Core::File::open("/proc/dmesg", Core::OpenMode::ReadOnly));
|
||||
auto buffer = file->read_all();
|
||||
out("{}", String::copy(buffer));
|
||||
out("{}", StringView { buffer });
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue