diff --git a/kernel/include/kernel/OpenFileDescriptorSet.h b/kernel/include/kernel/OpenFileDescriptorSet.h index 2060d257a0..7fb6b59958 100644 --- a/kernel/include/kernel/OpenFileDescriptorSet.h +++ b/kernel/include/kernel/OpenFileDescriptorSet.h @@ -22,7 +22,7 @@ namespace Kernel BAN::ErrorOr clone_from(const OpenFileDescriptorSet&); - BAN::ErrorOr open(VirtualFileSystem::File, int flags); + BAN::ErrorOr open(VirtualFileSystem::File&&, int flags); BAN::ErrorOr open(BAN::StringView absolute_path, int flags); BAN::ErrorOr socket(int domain, int type, int protocol); diff --git a/kernel/kernel/OpenFileDescriptorSet.cpp b/kernel/kernel/OpenFileDescriptorSet.cpp index 521b16371f..403ed18472 100644 --- a/kernel/kernel/OpenFileDescriptorSet.cpp +++ b/kernel/kernel/OpenFileDescriptorSet.cpp @@ -58,7 +58,7 @@ namespace Kernel return {}; } - BAN::ErrorOr OpenFileDescriptorSet::open(VirtualFileSystem::File file, int flags) + BAN::ErrorOr OpenFileDescriptorSet::open(VirtualFileSystem::File&& file, int flags) { ASSERT(file.inode); diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 547aba7347..0a9679b679 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -910,13 +910,14 @@ namespace Kernel 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 - if (!(flags & O_NOCTTY) && file.inode->is_tty() && is_session_leader() && !m_controlling_terminal) - m_controlling_terminal = static_cast(file.inode.ptr()); + if (!(flags & O_NOCTTY) && inode->is_tty() && is_session_leader() && !m_controlling_terminal) + m_controlling_terminal = static_cast(inode.ptr()); return fd; } @@ -1775,7 +1776,7 @@ namespace Kernel 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) m_controlling_terminal = (TTY*)pts_slave.ptr();