mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 21:45:20 +00:00
ProcFS: JSONify /proc/cpuinfo
To be more in line with other parts of Serenity's procfs, the "key: value" format of /proc/cpuinfo was replaced with JSON, namely an array of objects (one for each core). The available keys remain the same, though "features" has been changed from a space-separated string to an array of strings.
This commit is contained in:
parent
43d955014d
commit
fc0ec60d82
Notes:
sideshowbarker
2024-07-19 04:56:10 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/fc0ec60d82a Pull-request: https://github.com/SerenityOS/serenity/pull/2766
1 changed files with 14 additions and 15 deletions
|
@ -732,27 +732,26 @@ Optional<KBuffer> procfs$df(InodeIdentifier)
|
|||
Optional<KBuffer> procfs$cpuinfo(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
bool first = true;
|
||||
|
||||
JsonArraySerializer array { builder };
|
||||
Processor::for_each(
|
||||
[&](Processor& proc) -> IterationDecision
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
builder.append('\n');
|
||||
|
||||
auto& info = proc.info();
|
||||
builder.appendf("processor: %u\n", proc.id());
|
||||
builder.appendf("cpuid: %s\n", info.cpuid().characters());
|
||||
builder.appendf("family: %u\n", info.display_family());
|
||||
builder.appendf("features: %s\n", info.features().characters());
|
||||
builder.appendf("model: %u\n", info.display_model());
|
||||
builder.appendf("stepping: %u\n", info.stepping());
|
||||
builder.appendf("type: %u\n", info.type());
|
||||
builder.appendf("brandstr: \"%s\"\n", info.brandstr().characters());
|
||||
auto obj = array.add_object();
|
||||
JsonArray features;
|
||||
for (auto& feature : info.features().split(' '))
|
||||
features.append(feature);
|
||||
obj.add("processor", proc.id());
|
||||
obj.add("cpuid", info.cpuid());
|
||||
obj.add("family", info.display_family());
|
||||
obj.add("features", features);
|
||||
obj.add("model", info.display_model());
|
||||
obj.add("stepping", info.stepping());
|
||||
obj.add("type", info.type());
|
||||
obj.add("brandstr", info.brandstr());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
array.finish();
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue