2021-04-03 20:12:49 +00:00
|
|
|
/*
|
2021-09-01 02:32:46 +00:00
|
|
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
2021-04-03 20:12:49 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-03 20:12:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/JsonObject.h>
|
2023-02-09 02:02:46 +00:00
|
|
|
#include <LibCore/File.h>
|
2021-11-23 09:59:50 +00:00
|
|
|
#include <LibCore/System.h>
|
2021-11-22 18:43:26 +00:00
|
|
|
#include <LibMain/Main.h>
|
2021-04-03 20:12:49 +00:00
|
|
|
|
2021-11-22 18:43:26 +00:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments)
|
2021-04-03 20:12:49 +00:00
|
|
|
{
|
2021-11-27 22:26:34 +00:00
|
|
|
TRY(Core::System::pledge("stdio rpath"));
|
2023-02-09 02:02:46 +00:00
|
|
|
auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
|
2021-04-03 20:12:49 +00:00
|
|
|
|
2022-12-11 16:49:00 +00:00
|
|
|
auto buffer = TRY(file->read_until_eof());
|
2022-09-14 16:00:12 +00:00
|
|
|
auto json = TRY(JsonValue::from_string(buffer));
|
2021-11-22 18:43:26 +00:00
|
|
|
auto const& cpuinfo_array = json.as_array();
|
2021-04-03 20:12:49 +00:00
|
|
|
outln("{}", cpuinfo_array.size());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|