Serenity Operating System
1/*
2 * Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <AK/JsonObject.h>
8#include <LibCore/File.h>
9#include <LibCore/System.h>
10#include <LibMain/Main.h>
11
12ErrorOr<int> serenity_main(Main::Arguments)
13{
14 TRY(Core::System::pledge("stdio rpath"));
15 auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
16
17 auto buffer = TRY(file->read_until_eof());
18 auto json = TRY(JsonValue::from_string(buffer));
19 auto const& cpuinfo_array = json.as_array();
20 outln("{}", cpuinfo_array.size());
21
22 return 0;
23}