Kernel/VFS: Remove the find_mount_for_guest method

We don't really need this method anymore, because we could just try to
find the mount entry based on the given mount point host custody.

This also allows us to remove the is_vfs_root and root_inode_id methods
from the VirtualFileSystem class.
This commit is contained in:
Liav A 2023-08-04 22:34:58 +03:00 committed by Jelle Raaijmakers
parent e5c7662638
commit d216f780a4
2 changed files with 2 additions and 29 deletions

View file

@ -94,12 +94,6 @@ UNMAP_AFTER_INIT VirtualFileSystem::VirtualFileSystem()
UNMAP_AFTER_INIT VirtualFileSystem::~VirtualFileSystem() = default;
InodeIdentifier VirtualFileSystem::root_inode_id() const
{
VERIFY(m_root_inode);
return m_root_inode->identifier();
}
bool VirtualFileSystem::check_matching_absolute_path_hierarchy(Custody const& first_custody, Custody const& second_custody)
{
// Are both custodies the root mount?
@ -251,7 +245,7 @@ ErrorOr<void> VirtualFileSystem::remount(Custody& mount_point, int new_flags)
{
dbgln("VirtualFileSystem: Remounting inode {}", mount_point.inode().identifier());
auto* mount = find_mount_for_guest(mount_point.inode().identifier());
auto* mount = find_mount_for_host_custody(mount_point);
if (!mount)
return ENODEV;
@ -400,22 +394,6 @@ auto VirtualFileSystem::find_mount_for_host_custody(Custody const& current_custo
});
}
auto VirtualFileSystem::find_mount_for_guest(InodeIdentifier id) -> Mount*
{
return m_mounts.with([&](auto& mounts) -> Mount* {
for (auto& mount : mounts) {
if (mount.guest().identifier() == id)
return &mount;
}
return nullptr;
});
}
bool VirtualFileSystem::is_vfs_root(InodeIdentifier inode) const
{
return inode == root_inode_id();
}
ErrorOr<void> VirtualFileSystem::traverse_directory_inode(Inode& dir_inode, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback)
{
return dir_inode.traverse_as_directory([&](auto& entry) -> ErrorOr<void> {

View file

@ -88,8 +88,6 @@ public:
ErrorOr<void> for_each_mount(Function<ErrorOr<void>(Mount const&)>) const;
InodeIdentifier root_inode_id() const;
void sync_filesystems();
void lock_all_filesystems();
@ -111,16 +109,13 @@ private:
ErrorOr<void> add_file_system_to_mount_table(FileSystem& file_system, Custody& mount_point, int flags);
bool is_vfs_root(InodeIdentifier) const;
ErrorOr<void> traverse_directory_inode(Inode&, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>);
static bool check_matching_absolute_path_hierarchy(Custody const& first_custody, Custody const& second_custody);
bool mount_point_exists_at_custody(Custody& mount_point);
// FIXME: These functions are totally unsafe as someone could unmount the returned Mount underneath us.
// FIXME: This function is totally unsafe as someone could unmount the returned Mount underneath us.
Mount* find_mount_for_host_custody(Custody const& current_custody);
Mount* find_mount_for_guest(InodeIdentifier);
RefPtr<Inode> m_root_inode;