Kernel: Add OpenFileDescriptorSet::get_max_open_fd

This commit is contained in:
2026-05-21 14:58:33 +03:00
parent 5c94c30e1b
commit 12158d9208
2 changed files with 11 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ namespace Kernel
BAN::ErrorOr<size_t> recvmsg(int socket, msghdr& message, int flags); BAN::ErrorOr<size_t> recvmsg(int socket, msghdr& message, int flags);
BAN::ErrorOr<size_t> sendmsg(int socket, const msghdr& message, int flags); BAN::ErrorOr<size_t> sendmsg(int socket, const msghdr& message, int flags);
int get_max_open_fd() const;
BAN::ErrorOr<VirtualFileSystem::File> file_of(int) const; BAN::ErrorOr<VirtualFileSystem::File> file_of(int) const;
BAN::ErrorOr<BAN::String> path_of(int) const; BAN::ErrorOr<BAN::String> path_of(int) const;
BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int); BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int);

View File

@@ -853,6 +853,15 @@ namespace Kernel
return inode->sendmsg(message, flags | (is_nonblock ? MSG_DONTWAIT : 0)); return inode->sendmsg(message, flags | (is_nonblock ? MSG_DONTWAIT : 0));
} }
int OpenFileDescriptorSet::get_max_open_fd() const
{
LockGuard _(m_mutex);
for (int fd = m_open_files.size() - 1; fd > 0; fd--)
if (m_open_files[fd])
return fd;
return -1;
}
BAN::ErrorOr<VirtualFileSystem::File> OpenFileDescriptorSet::file_of(int fd) const BAN::ErrorOr<VirtualFileSystem::File> OpenFileDescriptorSet::file_of(int fd) const
{ {
LockGuard _(m_mutex); LockGuard _(m_mutex);