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>
|
|
|
|
#include <LibCore/File.h>
|
2021-11-22 19:43:26 +01:00
|
|
|
#include <LibMain/Main.h>
|
|
|
|
#include <LibSystem/Wrappers.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-22 19:43:26 +01:00
|
|
|
TRY(System::pledge("stdio rpath", nullptr));
|
|
|
|
auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly));
|
2021-04-03 14:12:49 -06:00
|
|
|
|
2021-09-10 23:43:25 +02:00
|
|
|
auto buffer = file->read_all();
|
2021-11-22 19:43:26 +01:00
|
|
|
auto json = TRY(JsonValue::from_string({ buffer }));
|
|
|
|
auto const& cpuinfo_array = json.as_array();
|
2021-04-03 14:12:49 -06:00
|
|
|
outln("{}", cpuinfo_array.size());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|