Kernel: Add OpenFileDescriptorSet::get_max_open_fd
This commit is contained in:
@@ -58,6 +58,8 @@ namespace Kernel
|
||||
BAN::ErrorOr<size_t> recvmsg(int socket, 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<BAN::String> path_of(int) const;
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int);
|
||||
|
||||
@@ -853,6 +853,15 @@ namespace Kernel
|
||||
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
|
||||
{
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
Reference in New Issue
Block a user