mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
FileSystem: Remove now-unused Inode::parent() and Inode::reverse_lookup().
These were only used to implement the old path resolution algorithm.
This commit is contained in:
parent
02e21de20a
commit
2e14e5891c
7 changed files with 0 additions and 94 deletions
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue