mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00: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
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue