mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
Kernel: Implement Process::custody_for_dirfd
This allows deduplicating a bunch of code that has to work with POSIX' *at syscall semantics.
This commit is contained in:
parent
5b335e7fba
commit
5c1d5ed51d
Notes:
sideshowbarker
2024-07-17 03:24:13 +09:00
Author: https://github.com/sin-ack
Commit: 5c1d5ed51d
Pull-request: https://github.com/SerenityOS/serenity/pull/15428
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/BertalanD
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/timschumi
2 changed files with 13 additions and 0 deletions
|
@ -1100,4 +1100,15 @@ RefPtr<Custody const> Process::executable() const
|
|||
return m_executable.with([](auto& executable) { return executable; });
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -844,6 +844,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ErrorOr<NonnullRefPtr<Custody>> custody_for_dirfd(int dirfd);
|
||||
|
||||
SpinlockProtected<Thread::ListInProcess>& thread_list() { return m_thread_list; }
|
||||
SpinlockProtected<Thread::ListInProcess> const& thread_list() const { return m_thread_list; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue