Kernel+SystemMonitor: Publish can_read/write state for open files

The can_read() and can_write() states for file descriptions are now
published in /proc, allowing SystemMonitor to display it.
This commit is contained in:
Andreas Kling 2019-11-09 22:15:35 +01:00
parent 660db0f79a
commit 06a80bcf69
Notes: sideshowbarker 2024-07-19 11:18:00 +09:00
3 changed files with 10 additions and 2 deletions

View file

@ -25,6 +25,12 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent)
pid_fds_fields.empend("On exec", TextAlignment::CenterLeft, [](auto& object) {
return object.get("cloexec").to_bool() ? "Close" : "Keep";
});
pid_fds_fields.empend("Can read", TextAlignment::CenterLeft, [](auto& object) {
return object.get("can_read").to_bool() ? "Yes" : "No";
});
pid_fds_fields.empend("Can write", TextAlignment::CenterLeft, [](auto& object) {
return object.get("can_write").to_bool() ? "Yes" : "No";
});
m_table_view->set_model(GJsonArrayModel::create({}, move(pid_fds_fields)));
}

View file

@ -226,6 +226,8 @@ Optional<KBuffer> procfs$pid_fds(InodeIdentifier identifier)
description_object.add("offset", description->offset());
description_object.add("cloexec", cloexec);
description_object.add("blocking", description->is_blocking());
description_object.add("can_read", description->can_read());
description_object.add("can_write", description->can_write());
}
array.finish();
return builder.build();

View file

@ -195,7 +195,7 @@ bool LocalSocket::can_read(const FileDescription& description) const
return !has_attached_peer(description) || !m_for_server.is_empty();
if (role == Role::Connected)
return !has_attached_peer(description) || !m_for_client.is_empty();
ASSERT_NOT_REACHED();
return false;
}
bool LocalSocket::has_attached_peer(const FileDescription& description) const
@ -215,7 +215,7 @@ bool LocalSocket::can_write(const FileDescription& description) const
return !has_attached_peer(description) || m_for_client.bytes_in_write_buffer() < 16384;
if (role == Role::Connected)
return !has_attached_peer(description) || m_for_server.bytes_in_write_buffer() < 16384;
ASSERT_NOT_REACHED();
return false;
}
ssize_t LocalSocket::sendto(FileDescription& description, const void* data, size_t data_size, int, const sockaddr*, socklen_t)