mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
Kernel: Improve ProcFS behavior in low memory conditions
When ProcFS could no longer allocate KBuffer objects to serve calls to read, it would just return 0, indicating EOF. This then triggered parsing errors because code assumed it read the file. Because read isn't supposed to return ENOMEM, change ProcFS to populate the file data upon file open or seek to the beginning. This also means that calls to open can now return ENOMEM if needed. This allows the caller to either be able to successfully open the file and read it, or fail to open it in the first place.
This commit is contained in:
parent
b36f57e570
commit
f98ca35b83
24 changed files with 398 additions and 243 deletions
|
@ -170,14 +170,6 @@ KResult IPv4Socket::connect(FileDescription& description, Userspace<const sockad
|
|||
return protocol_connect(description, should_block);
|
||||
}
|
||||
|
||||
void IPv4Socket::attach(FileDescription&)
|
||||
{
|
||||
}
|
||||
|
||||
void IPv4Socket::detach(FileDescription&)
|
||||
{
|
||||
}
|
||||
|
||||
bool IPv4Socket::can_read(const FileDescription&, size_t) const
|
||||
{
|
||||
if (m_role == Role::Listener)
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
virtual KResult listen(size_t) override;
|
||||
virtual void get_local_address(sockaddr*, socklen_t*) override;
|
||||
virtual void get_peer_address(sockaddr*, socklen_t*) override;
|
||||
virtual void attach(FileDescription&) override;
|
||||
virtual void detach(FileDescription&) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
virtual KResultOr<size_t> sendto(FileDescription&, const UserOrKernelBuffer&, size_t, int, Userspace<const sockaddr*>, socklen_t) override;
|
||||
|
|
|
@ -224,7 +224,7 @@ KResult LocalSocket::listen(size_t backlog)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
void LocalSocket::attach(FileDescription& description)
|
||||
KResult LocalSocket::attach(FileDescription& description)
|
||||
{
|
||||
ASSERT(!m_accept_side_fd_open);
|
||||
if (m_connect_side_role == Role::None) {
|
||||
|
@ -236,6 +236,7 @@ void LocalSocket::attach(FileDescription& description)
|
|||
}
|
||||
|
||||
evaluate_block_conditions();
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
void LocalSocket::detach(FileDescription& description)
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
virtual KResult listen(size_t) override;
|
||||
virtual void get_local_address(sockaddr*, socklen_t*) override;
|
||||
virtual void get_peer_address(sockaddr*, socklen_t*) override;
|
||||
virtual void attach(FileDescription&) override;
|
||||
virtual KResult attach(FileDescription&) override;
|
||||
virtual void detach(FileDescription&) override;
|
||||
virtual bool can_read(const FileDescription&, size_t) const override;
|
||||
virtual bool can_write(const FileDescription&, size_t) const override;
|
||||
|
|
|
@ -105,8 +105,6 @@ public:
|
|||
virtual void get_peer_address(sockaddr*, socklen_t*) = 0;
|
||||
virtual bool is_local() const { return false; }
|
||||
virtual bool is_ipv4() const { return false; }
|
||||
virtual void attach(FileDescription&) = 0;
|
||||
virtual void detach(FileDescription&) = 0;
|
||||
virtual KResultOr<size_t> sendto(FileDescription&, const UserOrKernelBuffer&, size_t, int flags, Userspace<const sockaddr*>, socklen_t) = 0;
|
||||
virtual KResultOr<size_t> recvfrom(FileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, timeval&) = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue