mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:07:40 +00: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();
|
auto& process = handle->process();
|
||||||
if (process.number_of_open_file_descriptors() == 0)
|
if (process.number_of_open_file_descriptors() == 0)
|
||||||
return {};
|
return {};
|
||||||
StringBuilder builder;
|
JsonArray array;
|
||||||
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
|
for (int i = 0; i < process.max_open_file_descriptors(); ++i) {
|
||||||
auto* description = process.file_description(i);
|
auto* description = process.file_description(i);
|
||||||
if (!description)
|
if (!description)
|
||||||
continue;
|
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)
|
ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue