mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Kernel: Port /proc/PID/fds to JSON
This commit is contained in:
parent
f10e850644
commit
246c011497
1 changed files with 6 additions and 3 deletions
|
@ -193,14 +193,17 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
|
|||
auto& process = handle->process();
|
||||
if (process.number_of_open_file_descriptors() == 0)
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
JsonArray array;
|
||||
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
|
||||
auto* description = process.file_description(i);
|
||||
if (!description)
|
||||
continue;
|
||||
builder.appendf("%-3u %s\n", i, description->absolute_path().characters());
|
||||
JsonObject description_object;
|
||||
description_object.set("fd", i);
|
||||
description_object.set("absolute_path", description->absolute_path());
|
||||
array.append(move(description_object));
|
||||
}
|
||||
return builder.to_byte_buffer();
|
||||
return array.serialized().to_byte_buffer();
|
||||
}
|
||||
|
||||
ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier)
|
||||
|
|
Loading…
Add table
Reference in a new issue