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