Kernel: OpenFileDesctiptor can now return inode of fd

This commit is contained in:
Bananymous 2023-07-23 18:52:33 +03:00
parent f7bf6d5e62
commit 9eb72f4392
2 changed files with 6 additions and 1 deletions

View File

@ -42,6 +42,7 @@ namespace Kernel
BAN::ErrorOr<void> read_dir_entries(int fd, DirectoryEntryList* list, size_t list_size);
BAN::ErrorOr<BAN::StringView> path_of(int) const;
BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int);
private:
struct OpenFileDescription : public BAN::RefCounted<OpenFileDescription>

View File

@ -216,13 +216,17 @@ namespace Kernel
return {};
}
BAN::ErrorOr<BAN::StringView> OpenFileDescriptorSet::path_of(int fd) const
{
TRY(validate_fd(fd));
return m_open_files[fd]->path.sv();
}
BAN::ErrorOr<BAN::RefPtr<Inode>> OpenFileDescriptorSet::inode_of(int fd)
{
TRY(validate_fd(fd));
return m_open_files[fd]->inode;
}
BAN::ErrorOr<void> OpenFileDescriptorSet::validate_fd(int fd) const
{