diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 4e210660446..1165d7ff25f 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1100,4 +1100,15 @@ RefPtr Process::executable() const return m_executable.with([](auto& executable) { return executable; }); } +ErrorOr> Process::custody_for_dirfd(int dirfd) +{ + if (dirfd == AT_FDCWD) + return current_directory(); + + auto base_description = TRY(open_file_description(dirfd)); + if (!base_description->custody()) + return EINVAL; + return *base_description->custody(); +} + } diff --git a/Kernel/Process.h b/Kernel/Process.h index bf0c1616c2c..3147965db38 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -844,6 +844,8 @@ public: } private: + ErrorOr> custody_for_dirfd(int dirfd); + SpinlockProtected& thread_list() { return m_thread_list; } SpinlockProtected const& thread_list() const { return m_thread_list; }