Kernel+ProcessManager: Add some more info to /proc/PID/fds

- "seekable": whether the fd is seekable or sequential.
- "class": which kernel C++ class implements this File.
- "offset": the current implicit POSIX API file offset.
This commit is contained in:
Andreas Kling 2019-08-03 08:42:40 +02:00
parent 7f25959fa2
commit f511421aaa
3 changed files with 24 additions and 0 deletions

View file

@ -29,6 +29,12 @@ String ProcessFileDescriptorMapModel::column_name(int column) const
switch (column) { switch (column) {
case Column::FileDescriptor: case Column::FileDescriptor:
return "FD"; return "FD";
case Column::ClassName:
return "Class";
case Column::Offset:
return "Offset";
case Column::Access:
return "Access";
case Column::Path: case Column::Path:
return "Path"; return "Path";
default: default:
@ -41,6 +47,12 @@ GModel::ColumnMetadata ProcessFileDescriptorMapModel::column_metadata(int column
switch (column) { switch (column) {
case Column::FileDescriptor: case Column::FileDescriptor:
return { 32, TextAlignment::CenterRight }; return { 32, TextAlignment::CenterRight };
case Column::ClassName:
return { 80, TextAlignment::CenterLeft };
case Column::Offset:
return { 40, TextAlignment::CenterRight };
case Column::Access:
return { 60, TextAlignment::CenterLeft };
case Column::Path: case Column::Path:
return { 300, TextAlignment::CenterLeft }; return { 300, TextAlignment::CenterLeft };
default: default:
@ -56,6 +68,12 @@ GVariant ProcessFileDescriptorMapModel::data(const GModelIndex& index, Role role
switch (index.column()) { switch (index.column()) {
case Column::FileDescriptor: case Column::FileDescriptor:
return fd_object.get("fd").to_int(); return fd_object.get("fd").to_int();
case Column::ClassName:
return fd_object.get("class").to_string();
case Column::Offset:
return fd_object.get("offset").to_int();
case Column::Access:
return fd_object.get("seekable").to_bool() ? "Seekable" : "Sequential";
case Column::Path: case Column::Path:
return fd_object.get("absolute_path").to_string(); return fd_object.get("absolute_path").to_string();
default: default:

View file

@ -8,6 +8,9 @@ public:
enum Column { enum Column {
FileDescriptor, FileDescriptor,
Path, Path,
Offset,
Access,
ClassName,
__Count __Count
}; };

View file

@ -201,6 +201,9 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
JsonObject description_object; JsonObject description_object;
description_object.set("fd", i); description_object.set("fd", i);
description_object.set("absolute_path", description->absolute_path()); description_object.set("absolute_path", description->absolute_path());
description_object.set("seekable", description->file().is_seekable());
description_object.set("class", description->file().class_name());
description_object.set("offset", description->offset());
array.append(move(description_object)); array.append(move(description_object));
} }
return array.serialized().to_byte_buffer(); return array.serialized().to_byte_buffer();