Kernel: Make OpenFileDescritorSet::open take rvalue
This gets rid of some implicit allocations from copy constructors
This commit is contained in:
parent
5f66ef34dd
commit
d20752c318
|
@ -22,7 +22,7 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<void> clone_from(const OpenFileDescriptorSet&);
|
BAN::ErrorOr<void> clone_from(const OpenFileDescriptorSet&);
|
||||||
|
|
||||||
BAN::ErrorOr<int> open(VirtualFileSystem::File, int flags);
|
BAN::ErrorOr<int> open(VirtualFileSystem::File&&, int flags);
|
||||||
BAN::ErrorOr<int> open(BAN::StringView absolute_path, int flags);
|
BAN::ErrorOr<int> open(BAN::StringView absolute_path, int flags);
|
||||||
|
|
||||||
BAN::ErrorOr<int> socket(int domain, int type, int protocol);
|
BAN::ErrorOr<int> socket(int domain, int type, int protocol);
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Kernel
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<int> OpenFileDescriptorSet::open(VirtualFileSystem::File file, int flags)
|
BAN::ErrorOr<int> OpenFileDescriptorSet::open(VirtualFileSystem::File&& file, int flags)
|
||||||
{
|
{
|
||||||
ASSERT(file.inode);
|
ASSERT(file.inode);
|
||||||
|
|
||||||
|
|
|
@ -910,13 +910,14 @@ namespace Kernel
|
||||||
file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, flags));
|
file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(file.inode);
|
auto inode = file.inode;
|
||||||
|
ASSERT(inode);
|
||||||
|
|
||||||
int fd = TRY(m_open_file_descriptors.open(file, flags));
|
int fd = TRY(m_open_file_descriptors.open(BAN::move(file), flags));
|
||||||
|
|
||||||
// Open controlling terminal
|
// Open controlling terminal
|
||||||
if (!(flags & O_NOCTTY) && file.inode->is_tty() && is_session_leader() && !m_controlling_terminal)
|
if (!(flags & O_NOCTTY) && inode->is_tty() && is_session_leader() && !m_controlling_terminal)
|
||||||
m_controlling_terminal = static_cast<TTY*>(file.inode.ptr());
|
m_controlling_terminal = static_cast<TTY*>(inode.ptr());
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -1775,7 +1776,7 @@ namespace Kernel
|
||||||
|
|
||||||
LockGuard _(m_process_lock);
|
LockGuard _(m_process_lock);
|
||||||
|
|
||||||
int pts_master_fd = TRY(m_open_file_descriptors.open(file, flags));
|
int pts_master_fd = TRY(m_open_file_descriptors.open(BAN::move(file), flags));
|
||||||
|
|
||||||
if (!(flags & O_NOCTTY) && is_session_leader() && !m_controlling_terminal)
|
if (!(flags & O_NOCTTY) && is_session_leader() && !m_controlling_terminal)
|
||||||
m_controlling_terminal = (TTY*)pts_slave.ptr();
|
m_controlling_terminal = (TTY*)pts_slave.ptr();
|
||||||
|
|
Loading…
Reference in New Issue