diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index b0e8925dde5..19d6874adf2 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1204,36 +1204,6 @@ RetainPtr Ext2FS::create_inode(InodeIdentifier parent_id, const String& n return get_inode({ fsid(), inode_id }); } -RetainPtr Ext2FSInode::parent() const -{ - LOCKER(m_lock); - if (m_parent_id.is_valid()) - return fs().get_inode(m_parent_id); - - unsigned group_index = fs().group_index_from_inode(index()); - unsigned first_inode_in_group = fs().inodes_per_group() * (group_index - 1); - - Vector> directories_in_group; - - for (unsigned i = 0; i < fs().inodes_per_group(); ++i) { - auto group_member = fs().get_inode({ fsid(), first_inode_in_group + i }); - if (!group_member) - continue; - if (group_member->is_directory()) - directories_in_group.append(*group_member); - } - - for (auto& directory : directories_in_group) { - if (!directory->reverse_lookup(identifier()).is_null()) { - m_parent_id = directory->identifier(); - break; - } - } - - ASSERT(m_parent_id.is_valid()); - return fs().get_inode(m_parent_id); -} - void Ext2FSInode::populate_lookup_cache() const { LOCKER(m_lock); @@ -1262,19 +1232,6 @@ InodeIdentifier Ext2FSInode::lookup(const String& name) return { }; } -String Ext2FSInode::reverse_lookup(InodeIdentifier child_id) -{ - ASSERT(is_directory()); - ASSERT(child_id.fsid() == fsid()); - populate_lookup_cache(); - LOCKER(m_lock); - for (auto it : m_lookup_cache) { - if (it.value == child_id.index()) - return it.key; - } - return { }; -} - void Ext2FSInode::one_retain_left() { // FIXME: I would like to not live forever, but uncached Ext2FS is fucking painful right now. diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index e53d6b2724a..17654f1e24d 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -29,12 +29,10 @@ private: virtual InodeMetadata metadata() const override; virtual bool traverse_as_directory(Function) const override; virtual InodeIdentifier lookup(const String& name) override; - virtual String reverse_lookup(InodeIdentifier) override; virtual void flush_metadata() override; virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescriptor*) override; virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override; virtual KResult remove_child(const String& name) override; - virtual RetainPtr parent() const override; virtual int set_atime(time_t) override; virtual int set_ctime(time_t) override; virtual int set_mtime(time_t) override; @@ -55,7 +53,6 @@ private: mutable Vector m_block_list; mutable HashMap m_lookup_cache; ext2_inode m_raw_inode; - mutable InodeIdentifier m_parent_id; }; class Ext2FS final : public DiskBackedFS { diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 6aa6d5a5eb3..76355218bff 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -42,11 +42,9 @@ public: virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescriptor*) const = 0; virtual bool traverse_as_directory(Function) const = 0; virtual InodeIdentifier lookup(const String& name) = 0; - virtual String reverse_lookup(InodeIdentifier) = 0; virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescriptor*) = 0; virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) = 0; virtual KResult remove_child(const String& name) = 0; - virtual RetainPtr parent() const = 0; virtual size_t directory_entry_count() const = 0; virtual KResult chmod(mode_t) = 0; virtual KResult chown(uid_t, gid_t) = 0; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 517b96d6891..c704d333745 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -739,11 +739,6 @@ RetainPtr ProcFS::create_directory(InodeIdentifier, const String&, mode_t return nullptr; } -RetainPtr ProcFSInode::parent() const -{ - return fs().get_inode(to_parent_id(identifier())); -} - InodeIdentifier ProcFS::root_inode() const { return { fsid(), FI_Root }; @@ -1042,26 +1037,6 @@ InodeIdentifier ProcFSInode::lookup(const String& name) return { }; } -String ProcFSInode::reverse_lookup(InodeIdentifier child_id) -{ - ASSERT(is_directory()); - auto proc_file_type = to_proc_file_type(identifier()); - if (proc_file_type == FI_Root) { - for (auto& entry : fs().m_entries) { - if (child_id == to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type)) { - return entry.name; - } - } - auto child_proc_file_type = to_proc_file_type(child_id); - if (child_proc_file_type == FI_PID) - return String::format("%u", to_pid(child_id)); - return { }; - } - // FIXME: Implement - ASSERT_NOT_REACHED(); - return { }; -} - void ProcFSInode::flush_metadata() { } diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index eff50cd2250..a507ba4ba0b 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -84,12 +84,10 @@ private: virtual InodeMetadata metadata() const override; virtual bool traverse_as_directory(Function) const override; virtual InodeIdentifier lookup(const String& name) override; - virtual String reverse_lookup(InodeIdentifier) override; virtual void flush_metadata() override; virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescriptor*) override; virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override; virtual KResult remove_child(const String& name) override; - virtual RetainPtr parent() const override; virtual size_t directory_entry_count() const override; virtual KResult chmod(mode_t) override; virtual KResult chown(uid_t, gid_t) override; diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp index 79ec6c9968b..12a8e84186d 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.cpp +++ b/Kernel/FileSystem/SyntheticFileSystem.cpp @@ -161,12 +161,6 @@ auto SynthFS::generate_inode_index() -> InodeIndex return m_next_inode_index++; } -RetainPtr SynthFSInode::parent() const -{ - LOCKER(m_lock); - return fs().get_inode(m_parent); -} - RetainPtr SynthFS::get_inode(InodeIdentifier inode) const { LOCKER(m_lock); @@ -252,17 +246,6 @@ InodeIdentifier SynthFSInode::lookup(const String& name) return { }; } -String SynthFSInode::reverse_lookup(InodeIdentifier child_id) -{ - LOCKER(m_lock); - ASSERT(is_directory()); - for (auto& child : m_children) { - if (child->identifier() == child_id) - return child->m_name; - } - return { }; -} - void SynthFSInode::flush_metadata() { } diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h index 825844732fb..844982a7268 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.h +++ b/Kernel/FileSystem/SyntheticFileSystem.h @@ -61,12 +61,10 @@ private: virtual InodeMetadata metadata() const override; virtual bool traverse_as_directory(Function) const override; virtual InodeIdentifier lookup(const String& name) override; - virtual String reverse_lookup(InodeIdentifier) override; virtual void flush_metadata() override; virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescriptor*) override; virtual KResult add_child(InodeIdentifier child_id, const String& name, mode_t) override; virtual KResult remove_child(const String& name) override; - virtual RetainPtr parent() const override; virtual size_t directory_entry_count() const override; virtual KResult chmod(mode_t) override; virtual KResult chown(uid_t, gid_t) override;