From 8e83aac8a310da1e8d21dd09087658768d9faf56 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 30 May 2019 21:01:16 +0200 Subject: [PATCH] FileSystem: Get rid of VFS::resolve_path_to_inode() and old_resolve_path(). --- Kernel/FileSystem/VirtualFileSystem.cpp | 34 +++---------------------- Kernel/FileSystem/VirtualFileSystem.h | 2 -- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index d9dba7bdfe..adde353404 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -39,16 +39,15 @@ InodeIdentifier VFS::root_inode_id() const bool VFS::mount(RetainPtr&& file_system, StringView path) { ASSERT(file_system); - int error; - auto inode = old_resolve_path(path, root_inode_id(), error); - if (!inode.is_valid()) { + auto result = resolve_path_to_custody(path, root_custody()); + if (result.is_error()) { kprintf("VFS: mount can't resolve mount point '%s'\n", path.characters()); return false; } - + auto& inode = result.value()->inode(); kprintf("VFS: mounting %s{%p} at %s (inode: %u)\n", file_system->class_name(), file_system.ptr(), path.characters(), inode.index()); // FIXME: check that this is not already a mount point - auto mount = make(inode, move(file_system)); + auto mount = make(inode.identifier(), move(file_system)); m_mounts.append(move(mount)); return true; } @@ -430,21 +429,6 @@ KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base) return inode.chown(new_uid, new_gid); } -KResultOr> VFS::resolve_path_to_inode(StringView path, Inode& base, RetainPtr* parent_inode, int options) -{ - // FIXME: This won't work nicely across mount boundaries. - FileSystemPath p(path); - if (!p.is_valid()) - return KResult(-EINVAL); - InodeIdentifier parent_id; - auto result = resolve_path(path, base.identifier(), options, &parent_id); - if (parent_inode && parent_id.is_valid()) - *parent_inode = get_inode(parent_id); - if (result.is_error()) - return result.error(); - return Retained(*get_inode(result.value())); -} - KResult VFS::link(StringView old_path, StringView new_path, Custody& base) { auto old_custody_or_error = resolve_path_to_custody(old_path, base); @@ -717,16 +701,6 @@ KResultOr VFS::resolve_path(StringView path, InodeIdentifier ba return crumb_id; } -InodeIdentifier VFS::old_resolve_path(StringView path, InodeIdentifier base, int& error, int options, InodeIdentifier* parent_id) -{ - auto result = resolve_path(path, base, options, parent_id); - if (result.is_error()) { - error = result.error(); - return { }; - } - return result.value(); -} - VFS::Mount::Mount(InodeIdentifier host, RetainPtr&& guest_fs) : m_host(host) , m_guest(guest_fs->root_inode()) diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 16cd257ac7..cfe4daed08 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -108,9 +108,7 @@ private: bool is_vfs_root(InodeIdentifier) const; void traverse_directory_inode(Inode&, Function); - InodeIdentifier old_resolve_path(StringView path, InodeIdentifier base, int& error, int options = 0, InodeIdentifier* parent_id = nullptr); KResultOr resolve_path(StringView path, InodeIdentifier base, int options = 0, InodeIdentifier* parent_id = nullptr); - KResultOr> resolve_path_to_inode(StringView path, Inode& base, RetainPtr* parent_id = nullptr, int options = 0); KResultOr resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode); Mount* find_mount_for_host(InodeIdentifier);