2021-04-03 14:12:49 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Peter Elliott <pelliott@ualberta.ca>
|
|
|
|
*
|
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>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
if (pledge("stdio rpath", nullptr) < 0) {
|
|
|
|
perror("pledge");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto file = Core::File::construct("/proc/cpuinfo");
|
2021-05-12 13:56:43 +04:30
|
|
|
if (!file->open(Core::OpenMode::ReadOnly)) {
|
2021-04-03 14:12:49 -06:00
|
|
|
perror("Core::File::open()");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto json = JsonValue::from_string({ file->read_all() });
|
|
|
|
auto cpuinfo_array = json.value().as_array();
|
|
|
|
outln("{}", cpuinfo_array.size());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|