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