summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-01 17:46:37 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-01 17:46:37 +0200
commit2e14e5891cec2176938820eae28754258583b8a2 (patch)
tree3a93b521b7a3ebb204c2b4ad038dac899808c863 /Kernel/FileSystem
parent02e21de20afb46792d0bf03b11b49f198dee1d05 (diff)
downloadserenity-2e14e5891cec2176938820eae28754258583b8a2.zip
FileSystem: Remove now-unused Inode::parent() and Inode::reverse_lookup().
These were only used to implement the old path resolution algorithm.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp43
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.h3
-rw-r--r--Kernel/FileSystem/Inode.h2
-rw-r--r--Kernel/FileSystem/ProcFS.cpp25
-rw-r--r--Kernel/FileSystem/ProcFS.h2
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.cpp17
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.h2
7 files changed, 0 insertions, 94 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index b0e8925dde..19d6874adf 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -1204,36 +1204,6 @@ RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& n
return get_inode({ fsid(), inode_id });
}
-RetainPtr<Inode> 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<Retained<Ext2FSInode>> 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 e53d6b2724..17654f1e24 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<bool(const FS::DirectoryEntry&)>) 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<Inode> 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<unsigned> m_block_list;
mutable HashMap<String, unsigned> 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 6aa6d5a5eb..76355218bf 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<bool(const FS::DirectoryEntry&)>) 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<Inode> 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 517b96d689..c704d33374 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -739,11 +739,6 @@ RetainPtr<Inode> ProcFS::create_directory(InodeIdentifier, const String&, mode_t
return nullptr;
}
-RetainPtr<Inode> 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 eff50cd225..a507ba4ba0 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<bool(const FS::DirectoryEntry&)>) 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<Inode> 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 79ec6c9968..12a8e84186 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<Inode> SynthFSInode::parent() const
-{
- LOCKER(m_lock);
- return fs().get_inode(m_parent);
-}
-
RetainPtr<Inode> 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 825844732f..844982a726 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<bool(const FS::DirectoryEntry&)>) 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<Inode> 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;