mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
lsirq: Port to LibMain
This commit is contained in:
parent
4a69072c3a
commit
6a7ffcddba
2 changed files with 10 additions and 31 deletions
|
@ -122,6 +122,7 @@ target_link_libraries(less LibMain)
|
||||||
target_link_libraries(ln LibMain)
|
target_link_libraries(ln LibMain)
|
||||||
target_link_libraries(logout LibMain)
|
target_link_libraries(logout LibMain)
|
||||||
target_link_libraries(ls LibMain)
|
target_link_libraries(ls LibMain)
|
||||||
|
target_link_libraries(lsirq LibMain)
|
||||||
target_link_libraries(lspci LibPCIDB LibMain)
|
target_link_libraries(lspci LibPCIDB LibMain)
|
||||||
target_link_libraries(lsusb LibUSBDB LibMain)
|
target_link_libraries(lsusb LibUSBDB LibMain)
|
||||||
target_link_libraries(man LibMarkdown LibMain)
|
target_link_libraries(man LibMarkdown LibMain)
|
||||||
|
|
|
@ -4,47 +4,25 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Assertions.h>
|
|
||||||
#include <AK/ByteBuffer.h>
|
|
||||||
#include <AK/JsonArray.h>
|
#include <AK/JsonArray.h>
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <stdio.h>
|
#include <LibCore/System.h>
|
||||||
#include <unistd.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) {
|
TRY(Core::System::pledge("stdio rpath"));
|
||||||
perror("pledge");
|
TRY(Core::System::unveil("/proc/interrupts", "r"));
|
||||||
return 1;
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil("/proc/interrupts", "r") < 0) {
|
auto proc_interrupts = TRY(Core::File::open("/proc/interrupts", Core::OpenMode::ReadOnly));
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unveil(nullptr, nullptr);
|
TRY(Core::System::pledge("stdio"));
|
||||||
|
|
||||||
auto proc_interrupts = Core::File::construct("/proc/interrupts");
|
|
||||||
if (!proc_interrupts->open(Core::OpenMode::ReadOnly)) {
|
|
||||||
warnln("Error: {}", proc_interrupts->error_string());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
outln(" CPU0");
|
outln(" CPU0");
|
||||||
auto file_contents = proc_interrupts->read_all();
|
auto file_contents = proc_interrupts->read_all();
|
||||||
auto json_or_error = JsonValue::from_string(file_contents);
|
auto json = TRY(JsonValue::from_string(file_contents));
|
||||||
if (json_or_error.is_error()) {
|
|
||||||
warnln("Error: {}", json_or_error.error());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
auto json = json_or_error.release_value();
|
|
||||||
json.as_array().for_each([](auto& value) {
|
json.as_array().for_each([](auto& value) {
|
||||||
auto& handler = value.as_object();
|
auto& handler = value.as_object();
|
||||||
auto purpose = handler.get("purpose").to_string();
|
auto purpose = handler.get("purpose").to_string();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue