1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

FileSystem: Get rid of VFS::resolve_path_to_inode() and old_resolve_path().

This commit is contained in:
Andreas Kling 2019-05-30 21:01:16 +02:00
parent 55821c91f8
commit 8e83aac8a3
2 changed files with 4 additions and 32 deletions

View file

@ -39,16 +39,15 @@ InodeIdentifier VFS::root_inode_id() const
bool VFS::mount(RetainPtr<FS>&& file_system, StringView path) bool VFS::mount(RetainPtr<FS>&& file_system, StringView path)
{ {
ASSERT(file_system); ASSERT(file_system);
int error; auto result = resolve_path_to_custody(path, root_custody());
auto inode = old_resolve_path(path, root_inode_id(), error); if (result.is_error()) {
if (!inode.is_valid()) {
kprintf("VFS: mount can't resolve mount point '%s'\n", path.characters()); kprintf("VFS: mount can't resolve mount point '%s'\n", path.characters());
return false; 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()); 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 // FIXME: check that this is not already a mount point
auto mount = make<Mount>(inode, move(file_system)); auto mount = make<Mount>(inode.identifier(), move(file_system));
m_mounts.append(move(mount)); m_mounts.append(move(mount));
return true; 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); return inode.chown(new_uid, new_gid);
} }
KResultOr<Retained<Inode>> VFS::resolve_path_to_inode(StringView path, Inode& base, RetainPtr<Inode>* 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<Inode>(*get_inode(result.value()));
}
KResult VFS::link(StringView old_path, StringView new_path, Custody& base) KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
{ {
auto old_custody_or_error = resolve_path_to_custody(old_path, base); auto old_custody_or_error = resolve_path_to_custody(old_path, base);
@ -717,16 +701,6 @@ KResultOr<InodeIdentifier> VFS::resolve_path(StringView path, InodeIdentifier ba
return crumb_id; 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<FS>&& guest_fs) VFS::Mount::Mount(InodeIdentifier host, RetainPtr<FS>&& guest_fs)
: m_host(host) : m_host(host)
, m_guest(guest_fs->root_inode()) , m_guest(guest_fs->root_inode())

View file

@ -108,9 +108,7 @@ private:
bool is_vfs_root(InodeIdentifier) const; bool is_vfs_root(InodeIdentifier) const;
void traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntry&)>); void traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntry&)>);
InodeIdentifier old_resolve_path(StringView path, InodeIdentifier base, int& error, int options = 0, InodeIdentifier* parent_id = nullptr);
KResultOr<InodeIdentifier> resolve_path(StringView path, InodeIdentifier base, int options = 0, InodeIdentifier* parent_id = nullptr); KResultOr<InodeIdentifier> resolve_path(StringView path, InodeIdentifier base, int options = 0, InodeIdentifier* parent_id = nullptr);
KResultOr<Retained<Inode>> resolve_path_to_inode(StringView path, Inode& base, RetainPtr<Inode>* parent_id = nullptr, int options = 0);
KResultOr<InodeIdentifier> resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode); KResultOr<InodeIdentifier> resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode);
Mount* find_mount_for_host(InodeIdentifier); Mount* find_mount_for_host(InodeIdentifier);